1
1
mirror of https://github.com/walles/moar.git synced 2024-09-19 07:58:00 +03:00

Handle 8 bit colors

This commit is contained in:
Johan Walles 2019-10-28 20:18:07 +01:00
parent f973ed5c46
commit 8b9e85958c

View File

@ -5,6 +5,7 @@ import (
"fmt"
"log"
"regexp"
"strconv"
"strings"
"github.com/gdamore/tcell"
@ -277,7 +278,6 @@ func consumeCompositeColor(numbers []string, index int) (int, *tcell.Color, erro
}
index++
if index >= len(numbers) {
err := fmt.Errorf(
"Incomplete color sequence: <CSI %sm>",
@ -285,5 +285,23 @@ func consumeCompositeColor(numbers []string, index int) (int, *tcell.Color, erro
return -1, nil, err
}
if numbers[index] == "5" {
index++
if index >= len(numbers) {
err := fmt.Errorf(
"Incomplete 8 bit color sequence: <CSI %sm>",
strings.Join(numbers[baseIndex:], ";"))
return -1, nil, err
}
colorNumber, err := strconv.Atoi(numbers[index])
if err != nil {
return -1, nil, err
}
colorValue := tcell.Color(colorNumber)
return index + 1, &colorValue, nil
}
return -1, nil, errors.New("Unimplemented")
}