fix font modifiers test coverage and style nitpicks

This commit is contained in:
Carson McManus 2020-11-17 08:33:36 -05:00
parent 4946857fbd
commit 93ddcf4615
4 changed files with 16 additions and 5 deletions

View File

@ -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,
},
},
}

View File

@ -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
}

View File

@ -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")
}

View File

@ -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},
}