mirror of https://github.com/mum4k/termdash.git
fix font modifiers test coverage and style nitpicks
This commit is contained in:
parent
4946857fbd
commit
93ddcf4615
|
@ -80,12 +80,16 @@ func TestNewOptions(t *testing.T) {
|
||||||
Italic(),
|
Italic(),
|
||||||
Underline(),
|
Underline(),
|
||||||
Strikethrough(),
|
Strikethrough(),
|
||||||
|
Inverse(),
|
||||||
|
Blink(),
|
||||||
},
|
},
|
||||||
want: &Options{
|
want: &Options{
|
||||||
Bold: true,
|
Bold: true,
|
||||||
Italic: true,
|
Italic: true,
|
||||||
Underline: true,
|
Underline: true,
|
||||||
Strikethrough: true,
|
Strikethrough: true,
|
||||||
|
Inverse: true,
|
||||||
|
Blink: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,13 @@ func cellOptsToStyle(opts *cell.Options, colorMode terminalapi.ColorMode) tcell.
|
||||||
fg := cellColor(colorToMode(opts.FgColor, colorMode))
|
fg := cellColor(colorToMode(opts.FgColor, colorMode))
|
||||||
bg := cellColor(colorToMode(opts.BgColor, 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
|
return st
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,21 +49,21 @@ func cellOptsToFg(opts *cell.Options) (tbx.Attribute, error) {
|
||||||
if opts.Bold {
|
if opts.Bold {
|
||||||
a |= tbx.AttrBold
|
a |= tbx.AttrBold
|
||||||
}
|
}
|
||||||
// FIXME: Termbox doesn't have an italics attribute
|
// Termbox doesn't have an italics attribute
|
||||||
if opts.Italic {
|
if opts.Italic {
|
||||||
return 0, errors.New("Termbox: Unsupported attribute: Italic")
|
return 0, errors.New("Termbox: Unsupported attribute: Italic")
|
||||||
}
|
}
|
||||||
if opts.Underline {
|
if opts.Underline {
|
||||||
a |= tbx.AttrUnderline
|
a |= tbx.AttrUnderline
|
||||||
}
|
}
|
||||||
// FIXME: Termbox doesn't have a strikethrough attribute
|
// Termbox doesn't have a strikethrough attribute
|
||||||
if opts.Strikethrough {
|
if opts.Strikethrough {
|
||||||
return 0, errors.New("Termbox: Unsupported attribute: Strikethrough")
|
return 0, errors.New("Termbox: Unsupported attribute: Strikethrough")
|
||||||
}
|
}
|
||||||
if opts.Inverse {
|
if opts.Inverse {
|
||||||
a |= tbx.AttrReverse
|
a |= tbx.AttrReverse
|
||||||
}
|
}
|
||||||
// FIXME: Termbox doesn't have a blink attribute
|
// Termbox doesn't have a blink attribute
|
||||||
if opts.Blink {
|
if opts.Blink {
|
||||||
return 0, errors.New("Termbox: Unsupported attribute: Blink")
|
return 0, errors.New("Termbox: Unsupported attribute: Blink")
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ func TestCellFontModifier(t *testing.T) {
|
||||||
{cell.Options{Underline: true}, tbx.AttrUnderline, false},
|
{cell.Options{Underline: true}, tbx.AttrUnderline, false},
|
||||||
{cell.Options{Italic: true}, 0, true},
|
{cell.Options{Italic: true}, 0, true},
|
||||||
{cell.Options{Strikethrough: 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},
|
{cell.Options{Blink: true}, 0, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue