1
1
mirror of https://github.com/walles/moar.git synced 2024-11-22 21:50:43 +03:00

Handle reading underline color

This commit is contained in:
Johan Walles 2024-08-12 20:53:16 +02:00
parent 065b95a653
commit f69e58d9b3
2 changed files with 3 additions and 3 deletions

View File

@ -585,9 +585,9 @@ func joinUints(ints []uint) string {
// * A color value that can be applied to a style
func consumeCompositeColor(numbers []uint, index int) (int, *twin.Color, error) {
baseIndex := index
if numbers[index] != 38 && numbers[index] != 48 {
if numbers[index] != 38 && numbers[index] != 48 && numbers[index] != 58 {
err := fmt.Errorf(
"unknown start of color sequence <%d>, expected 38 (foreground) or 48 (background): <CSI %sm>",
"unknown start of color sequence <%d>, expected 38 (foreground), 48 (background) or 58 (underline): <CSI %sm>",
numbers[index],
joinUints(numbers[baseIndex:]))
return -1, nil, err

View File

@ -216,7 +216,7 @@ func TestConsumeCompositeColorBadPrefix(t *testing.T) {
// 8 bit color
// Example from: https://github.com/walles/moar/issues/14
_, color, err := consumeCompositeColor([]uint{29}, 0)
assert.Equal(t, err.Error(), "unknown start of color sequence <29>, expected 38 (foreground) or 48 (background): <CSI 29m>")
assert.Equal(t, err.Error(), "unknown start of color sequence <29>, expected 38 (foreground), 48 (background) or 58 (underline): <CSI 29m>")
assert.Assert(t, color == nil)
}