Skip to content

Add opt-in selectedLineFgColor theme option - #839

Open
0x3654 wants to merge 1 commit into
jesseduffield:masterfrom
0x3654:selected-line-contrast
Open

Add opt-in selectedLineFgColor theme option#839
0x3654 wants to merge 1 commit into
jesseduffield:masterfrom
0x3654:selected-line-contrast

Conversation

@0x3654

@0x3654 0x3654 commented Sep 6, 2026

Copy link
Copy Markdown

Fixes #543
Refs #393, #685

Why

Since #372 (2022) the selected line is a coloured background with the cell's
own foreground force-brightened and emboldened by gocui. Two long-standing
complaints follow from that:

There is no knob for the selected line's foreground: the theme exposes a
background only. gocui's View.SelFgColor exists but is ignored by the main
draw path, so lazydocker could not expose one even if it wanted to.

A default can't fix this — so this PR doesn't change one

ANSI colours are defined by the terminal palette, and palettes disagree:

same config value selectedLineBgColor: [blue] renders as
Ghostty, Monokai Pro Ristretto (palette 4 = #f38d70) salmon, readable
classic palettes (ANSI 4 = dark navy) navy + bright text — the #543 wash-out

Any new default would be a lottery across themes. So the new key is strictly
opt-in: unset by default, and with it unset this PR changes nothing
rendering is byte-identical to current master. Users who want a uniform,
predictable selection style opt in with one line and pair it with a background
that fits their palette.

What it does

gui:
  theme:
    selectedLineBgColor:
      - blue        # or any colour / hex
    selectedLineFgColor:
      - black       # opt-in; pair with your bg

When set, the whole selected line renders uniformly in that colour:

  • plain text keeps the classic bold emphasis;
  • cells that carry their own colour (container status, ports, image) are
    overridden, so the row reads as one plate instead of mixed bright colours
    on a coloured background;
  • named colours, hex values and attributes work via the existing
    GetGocuiStyle machinery;
  • if either key contains reverse, the key is ignored and the classic
    inverted look is kept (an explicit fg under reverse would land on a
    terminal-theme-dependent colour after the swap).

Requires the companion gocui change (honour View.SelFgColor in setRune):
jesseduffield/gocui#107

Screenshots

Six shots, one config (selectedLineBgColor: blue, selectedLineFgColor: black),
two terminals — the palette decides everything.

stock

Terminal.app (classic ANSI blue) — bright text on navy, the #543 wash-out:

stock lazydocker in Terminal.app: bright white text on a navy selection bar — the #543 wash-out

Ghostty, Monokai Pro Ristretto — the same blue renders salmon: the palette lottery:

stock lazydocker in Ghostty: the same 'blue' bar renders salmon — the palette lottery

reverse — the existing workaround

Terminal.app — contrast is back, but status colours are inverted into mush:

reverse in Terminal.app: white bar, black text — contrast up, status colours dead

Ghostty — the same destruction, inverted differently:

reverse in Ghostty: warm white bar, black text — same destruction, inverted differently

this PR, fg: black

Terminal.app — a pair that doesn't fit this palette: pick pairs consciously:

this PR in Terminal.app: uniform black text on the blue bar — a pair that doesn't fit this palette, pick pairs consciously

Ghostty — uniform black on salmon: the plate this PR enables:

this PR in Ghostty: uniform black text on the salmon bar — the plate this PR enables

Same key, same config line — readable or broken depending on the terminal.
That is why this PR adds a knob instead of changing a default.

The selected line is a background colour plus a force-brightened,
emboldened foreground (gocui's setRune ignores View.SelFgColor), which
washes out on dark palettes (jesseduffield#543), and the only built-in escape,
reverse, inverts status colours along with everything else.

Add an opt-in selectedLineFgColor theme key: when set, the whole
selected line renders uniformly in that colour (plain cells keep the
classic bold emphasis, per-cell colours such as container status are
overridden). Unset by default: rendering is unchanged. Ignored when the
selection style contains reverse, because an explicit foreground would
land on a terminal-theme-dependent colour after the terminal swaps
fg/bg.

Includes the vendored gocui change honouring SelFgColor in setRune, to
be re-vendored from upstream once it lands there.

Fixes jesseduffield#543
Refs jesseduffield#393, jesseduffield#685

Co-Authored-By: Claude Code <noreply@anthropic.com>
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.

selectedLineBgColor always uses bright colours; default theme is illegible in white-on-black terminals

1 participant