diff --git a/cell/cell.go b/cell/cell.go index 08a7ab0..ae3db0a 100644 --- a/cell/cell.go +++ b/cell/cell.go @@ -31,6 +31,7 @@ type Options struct { Strikethrough bool Inverse bool Blink bool + Dim bool } // Set allows existing options to be passed as an option. @@ -110,3 +111,10 @@ func Blink() Option { co.Blink = true }) } + +// Dim makes the cell foreground color dim. Only works when using the tcell backend. +func Dim() Option { + return option(func(co *Options) { + co.Dim = true + }) +} diff --git a/cell/cell_test.go b/cell/cell_test.go index 1447e3f..3651b25 100644 --- a/cell/cell_test.go +++ b/cell/cell_test.go @@ -82,6 +82,7 @@ func TestNewOptions(t *testing.T) { Strikethrough(), Inverse(), Blink(), + Dim(), }, want: &Options{ Bold: true, @@ -90,6 +91,7 @@ func TestNewOptions(t *testing.T) { Strikethrough: true, Inverse: true, Blink: true, + Dim: true, }, }, } diff --git a/terminal/tcell/cell_options.go b/terminal/tcell/cell_options.go index b23fa3c..a28e005 100644 --- a/terminal/tcell/cell_options.go +++ b/terminal/tcell/cell_options.go @@ -70,6 +70,7 @@ func cellOptsToStyle(opts *cell.Options, colorMode terminalapi.ColorMode) tcell. Underline(opts.Underline). StrikeThrough(opts.Strikethrough). Reverse(opts.Inverse). - Blink(opts.Blink) + Blink(opts.Blink). + Dim(opts.Dim) return st } diff --git a/terminal/tcell/cell_options_test.go b/terminal/tcell/cell_options_test.go index 03b9b92..0b0c229 100644 --- a/terminal/tcell/cell_options_test.go +++ b/terminal/tcell/cell_options_test.go @@ -325,6 +325,11 @@ func TestCellOptsToStyle(t *testing.T) { opts: cell.Options{Blink: true}, want: tcell.StyleDefault.Blink(true), }, + { + colorMode: terminalapi.ColorModeNormal, + opts: cell.Options{Dim: true}, + want: tcell.StyleDefault.Dim(true), + }, } for _, tc := range tests { diff --git a/terminal/termbox/cell_options.go b/terminal/termbox/cell_options.go index 7386451..bae9f08 100644 --- a/terminal/termbox/cell_options.go +++ b/terminal/termbox/cell_options.go @@ -67,6 +67,11 @@ func cellOptsToFg(opts *cell.Options) (tbx.Attribute, error) { if opts.Blink { return 0, errors.New("Termbox: Unsupported attribute: Blink") } + + if opts.Dim { + return 0, errors.New("Termbox: Unsupported attribute: Dim") + } + return a, nil } diff --git a/terminal/termbox/cell_options_test.go b/terminal/termbox/cell_options_test.go index e12c3b9..0fe00a2 100644 --- a/terminal/termbox/cell_options_test.go +++ b/terminal/termbox/cell_options_test.go @@ -62,6 +62,7 @@ func TestCellFontModifier(t *testing.T) { {cell.Options{Strikethrough: true}, 0, true}, {cell.Options{Inverse: true}, tbx.AttrReverse, false}, {cell.Options{Blink: true}, 0, true}, + {cell.Options{Dim: true}, 0, true}, } for _, tc := range tests {