More cleanups for color parsing

Using rounding when converting float to uint8 for more accuracy.
Fix rgb:3 and rgbi: parsing in Go code. Various other minor cleanups.
This commit is contained in:
Kovid Goyal
2025-12-31 09:35:09 +05:30
parent 051b0ff30d
commit e14e34948e
6 changed files with 151 additions and 187 deletions

View File

@@ -39,7 +39,7 @@ func TestANSIStyleSprint(t *testing.T) {
test("fg=15", "\x1b[97m", "\x1b[39m")
test("bg=15", "\x1b[107m", "\x1b[49m")
test("fg=#123", "\x1b[38:2:17:34:51m", "\x1b[39m")
test("fg=rgb:1/2/3", "\x1b[38:2:1:2:3m", "\x1b[39m")
test("fg=rgb:1/2/3", "\x1b[38:2:17:34:51m", "\x1b[39m")
test("bg=123", "\x1b[48:5:123m", "\x1b[49m")
test("uc=123", "\x1b[58:5:123m", "\x1b[59m")
test("uc=1", "\x1b[58:5:1m", "\x1b[59m")