From 93ddcf46156887e110ec6299f5b91956b2d88978 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Tue, 17 Nov 2020 08:33:36 -0500 Subject: [PATCH] fix font modifiers test coverage and style nitpicks --- cell/cell_test.go | 4 ++++ terminal/tcell/cell_options.go | 9 ++++++++- terminal/termbox/cell_options.go | 6 +++--- terminal/termbox/cell_options_test.go | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cell/cell_test.go b/cell/cell_test.go index 329fdb7..1447e3f 100644 --- a/cell/cell_test.go +++ b/cell/cell_test.go @@ -80,12 +80,16 @@ func TestNewOptions(t *testing.T) { Italic(), Underline(), Strikethrough(), + Inverse(), + Blink(), }, want: &Options{ Bold: true, Italic: true, Underline: true, Strikethrough: true, + Inverse: true, + Blink: true, }, }, } diff --git a/terminal/tcell/cell_options.go b/terminal/tcell/cell_options.go index 21be5f2..b23fa3c 100644 --- a/terminal/tcell/cell_options.go +++ b/terminal/tcell/cell_options.go @@ -63,6 +63,13 @@ func cellOptsToStyle(opts *cell.Options, colorMode terminalapi.ColorMode) tcell. fg := cellColor(colorToMode(opts.FgColor, colorMode)) bg := cellColor(colorToMode(opts.BgColor, colorMode)) - st = st.Foreground(fg).Background(bg).Bold(opts.Bold).Italic(opts.Italic).Underline(opts.Underline).StrikeThrough(opts.Strikethrough).Reverse(opts.Inverse).Blink(opts.Blink) + st = st.Foreground(fg). + Background(bg). + Bold(opts.Bold). + Italic(opts.Italic). + Underline(opts.Underline). + StrikeThrough(opts.Strikethrough). + Reverse(opts.Inverse). + Blink(opts.Blink) return st } diff --git a/terminal/termbox/cell_options.go b/terminal/termbox/cell_options.go index faa79ce..7386451 100644 --- a/terminal/termbox/cell_options.go +++ b/terminal/termbox/cell_options.go @@ -49,21 +49,21 @@ func cellOptsToFg(opts *cell.Options) (tbx.Attribute, error) { if opts.Bold { a |= tbx.AttrBold } - // FIXME: Termbox doesn't have an italics attribute + // Termbox doesn't have an italics attribute if opts.Italic { return 0, errors.New("Termbox: Unsupported attribute: Italic") } if opts.Underline { a |= tbx.AttrUnderline } - // FIXME: Termbox doesn't have a strikethrough attribute + // Termbox doesn't have a strikethrough attribute if opts.Strikethrough { return 0, errors.New("Termbox: Unsupported attribute: Strikethrough") } if opts.Inverse { a |= tbx.AttrReverse } - // FIXME: Termbox doesn't have a blink attribute + // Termbox doesn't have a blink attribute if opts.Blink { return 0, errors.New("Termbox: Unsupported attribute: Blink") } diff --git a/terminal/termbox/cell_options_test.go b/terminal/termbox/cell_options_test.go index 7c76089..e12c3b9 100644 --- a/terminal/termbox/cell_options_test.go +++ b/terminal/termbox/cell_options_test.go @@ -60,7 +60,7 @@ func TestCellFontModifier(t *testing.T) { {cell.Options{Underline: true}, tbx.AttrUnderline, false}, {cell.Options{Italic: true}, 0, true}, {cell.Options{Strikethrough: true}, 0, true}, - {cell.Options{Inverse: true}, tbx.AttrReverse, true}, + {cell.Options{Inverse: true}, tbx.AttrReverse, false}, {cell.Options{Blink: true}, 0, true}, }