Skip to content

fix(svg.go): don't drop explicit colors when settings a foregroundColorOverride#19

Open
danshick wants to merge 1 commit intoMrMarble:v0-oldfrom
danshick:dws/fix-fg-color-override
Open

fix(svg.go): don't drop explicit colors when settings a foregroundColorOverride#19
danshick wants to merge 1 commit intoMrMarble:v0-oldfrom
danshick:dws/fix-fg-color-override

Conversation

@danshick
Copy link
Copy Markdown

@danshick danshick commented Jan 7, 2026

this change keeps all custom color classes in place when setting a foregroundColorOverride and chooses instead to style all vt10x.DefaultFG colored text uniformly using a text element selector. the DefaultFG color is set to the result of GetColor(vt10x.DefaultFG) which gives ANSI color LightGrey. this is the same as the previous implicit behavior regardless of whether or not that was intended. if a foregroundColorOverride is set, that color is used instead. this better matches the behavior of the backgroundColorOverride which still respects explicit CSI SGR signals while changing the DefaultBG where it is encountered.

@danshick
Copy link
Copy Markdown
Author

danshick commented Jan 7, 2026

looks like i broke a few tests by deviating from the golden fixture. will get that fixed and update.

@danshick danshick force-pushed the dws/fix-fg-color-override branch from 5b37ea2 to 8e8a1a2 Compare January 7, 2026 06:10
@danshick
Copy link
Copy Markdown
Author

danshick commented Jan 7, 2026

ok, tests are passing for me now.

…orOverride

this change keeps all custom color classes in place when setting a
foregroundColorOverride and chooses instead to style all vt10x.DefaultFG
colored text uniformly using a text element selector. the DefaultFG
color is set to the result of GetColor(vt10x.DefaultFG) which gives ANSI color
LightGrey. this is the same as the previous implicit behavior regardless
of whether or not that was intended. if a foregroundColorOverride is set, that
color is used instead. this better matches the behavior of the
backgroundColorOverride which still respects explicit CSI SGR signals while
changing the DefaultBG where it is encountered.
@danshick danshick force-pushed the dws/fix-fg-color-override branch from 8e8a1a2 to 21ff277 Compare January 7, 2026 06:12
@danshick
Copy link
Copy Markdown
Author

danshick commented Jan 7, 2026

to demonstrate more visually, here is an export of a session with no foreground color set, just termsvg export session.cast:
test-noargs

here's the same session exported with termsvg export -t "#FF0000" session.cast:
test-fgoverride-before

and finally, here's the same command run with this change:
test-fgoverride-after

still not perfect, explicit background color handling is still buggy, but no different than before the change. i think it's preferable to retain the explicitly set colors rather than render them as black because no classes were added to the styles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant