mirror of https://github.com/mum4k/termdash.git
add tcell's dim text style
This commit is contained in:
parent
ab8e6dd194
commit
bb460d221d
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue