4 Commits
Author SHA1 Message Date
dualfroz c710796982 Describe this repository 2026-10-22 21:04:00 +02:00
dualfroz f78554106d fix(convert): zero-pad each channel in RgbToHex
RgbToHex emitted a single hex digit for channel values below 0x10 because
strconv.FormatInt produces the minimal representation. This broke the
fixed-width hex format, the round-trip with HexToRgb, and the hex2basicMap
fast path in Rgb2basic. Format each channel with %02x, matching RgbTo256.
2026-09-04 09:03:13 +02:00
dualfroz caf059eba7 fix(convert): zero-pad each channel in RgbToHex
RgbToHex emitted a single hex digit for channel values below 0x10 because
strconv.FormatInt produces the minimal representation. This broke the
fixed-width hex format, the round-trip with HexToRgb, and the hex2basicMap
fast path in Rgb2basic. Format each channel with %02x, matching RgbTo256.
2026-09-06 00:44:29 +02:00
dualfroz c92652a003 fix: include escape codes in byte counts from Print, Printf
Color.Print and Color.Printf return the number of bytes written, but only
counted the bytes of the formatted operands. The SGR escape sequence written
before them and the reset sequence written after were silently dropped from
the count, so the returned n was always short whenever color output was
active.

Fprint and Fprintf had the identical bug and were already fixed in cbda2c3d
by switching from the void Set/unset() pair to setWriter/unsetWriter, which
return the byte counts of the escape sequences so they can be accumulated.
That fix was never applied to Print and Printf, which still call Set() and
unset() and discard what they write.

Give Print and Printf the same setWriter/unsetWriter treatment as Fprint and
Fprintf. The private unset() method has no remaining callers after this
change and is removed.

Add TestColor_Print and TestColor_Printf, mirroring the existing
TestColor_Fprint/TestColor_Fprintf byte-count assertions.
2026-09-04 08:25:41 +02:00