Skip to content

WIP: rename default theme to light, rework light+dark themes with consistent colors #2175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jmtd
Copy link
Collaborator

@jmtd jmtd commented Feb 22, 2024

This is Work In Progress, it will take me some time to write up properly what's done and why, and what the caveats are -- but I wanted to raise this now before the branch gets too stale.

Rename the default theme to "light" and rework both it and the dark theme in terms of colours picked from the "fixed" 240-color palette. This should result in consistent colours between terminal emulators, with some caveats

  • the new colours here will likely be different to what people experienced prior to this patch
  • it's not impossible for folks to redefine these palette indexes, but it's much less common than redefining the 16 color indexes used prior, as the former are specified as an RGB triplet, and the latter merely as a name e.g. "yellow"

A drawback of doing this is that the colours will not display at all in terminals which don't support the 240 palette. I think that it's extremely uncommon for modern users to have a Terminal that doesn't support these; but more common would be having a misconfigured terminal (or some intermediary software: ssh, tmux, screen, etc. introducing a problem). This can be simulated by overriding TERM, e.g. with TERM=xterm-color (where xterm-color is a terminfo definition which doesn't support the 240 color palette).

To make this failure mode less catastrophic, many of the "selected" lines have reverseVideo set, and also the fg/bg colors swapped, which should look like a no-op when the color is supported, but is visible as reversevideo when the color is not supported. This means it can still be used. Example:
hledger-256color-nosupport-rv

However, using this reverseVideo hack appears to introduce an unfortunate artifact in the right-hand border of selected lines when color is working:
hledger-256color-line-artifact
I'm not sure yet whether this is a bug in this patch/hledger-ui, brick or vty. (The dark theme isn't affected)

Some TODOs

  • demo screenshot of artifact bug
  • document rework of dark theme in fixed colors
  • rename "terminal" theme to "inherit"?
  • rename "greenterm" to "greenonblack"
  • close GH issue commands into one or more commit msgs
  • add data about color blind / other visual disability experiences

@jmtd jmtd changed the title WIP: rework default theme with consistent colors WIP: rename default theme to light, rework light+dark themes with consistent colors Mar 10, 2024
@jmtd jmtd force-pushed the hui-default-theme-consistent branch from 52d8d14 to e0f7d41 Compare March 10, 2024 21:57
@simonmichael simonmichael added ui The hledger-ui tool. needs-changes To unblock: needs some changes made, in line with recommendations labels Sep 5, 2024
@simonmichael
Copy link
Owner

Hi @jmtd, do you have time to revisit this hledger-ui PR: rename default theme to light, etc.. ?

@jmtd
Copy link
Collaborator Author

jmtd commented May 19, 2025

Hi @simonmichael

Hi @jmtd, do you have time to revisit this hledger-ui PR: rename default theme to light, etc.. ?

Yeah I can pick it up. Are you particularly interested in the theme renaming, or the consistent colours, or both?

For the latter, at least with the approach used in the PR as it stands, do you think the visual artifact (second pic in original comment) is a blocker? If so I need to look at VTE I think and see if it's a bug at that level.

@simonmichael
Copy link
Owner

As it happens I have used hledger-ui very little in recent months. Right now I'm mainly interested in resolving open PRs. Generally, I'm interested in

  1. any cleanup/improvement of what we have now
  2. more visual appeal that delights and attracts users - especially if it's effective and practical
  3. more/easier customisability of colours and styles - for tinkerers and devs, and supporting 2.

I don't think the miscoloured margin character need be a blocker.

jmtd added 4 commits May 22, 2025 08:55
Define the default theme in terms of colors from the fixed 240-color
(almost 8-bit) palette. This should ensure consistency between different
terminal applications.

If a terminal does not support the 240-color palette (very unlikely
these days. Simulate with TERM=xterm-color) the UI is unusable. To
mitigate this, selections are also marked as "reverse video", which
will ensure they are differentiated even with colours disabled.

Signed-off-by: Jonathan Dowland <jon@dow.land>
Signed-off-by: Jonathan Dowland <jon@dow.land>
Fixes: simonmichael#2168.

Signed-off-by: Jonathan Dowland <jon@dow.land>
@jmtd jmtd force-pushed the hui-default-theme-consistent branch from e0f7d41 to c2dd3b7 Compare May 22, 2025 08:01
@jmtd
Copy link
Collaborator Author

jmtd commented May 22, 2025

I've rebased, cleaned up and tested the branch.

@simonmichael simonmichael added needs-testing To unblock: needs more developer testing or general usage needs-review To unblock: needs more code/docs/design review by someone and removed needs-changes To unblock: needs some changes made, in line with recommendations labels May 24, 2025
@simonmichael
Copy link
Owner

simonmichael commented May 24, 2025

Thanks @jmtd. Some testing notes:

Use of the 240-color palette to improve consistency between terminals - this is working.
In my VS Code terminal panes (which have TERM=256color, COLORTERM=truecolor), the default theme was showing as white on dark grey; now it shows black on white, as in apple terminal and wezterm. And the yellow and red now look darker - yellow is gold not lemon, red is red not pink. Good.

With TERM=xterm, implying 8 color support, hledger-ui has always showed the usual colors:

image

Now it shows almost monochrome. Shouldn't it show the 8 color approximation as before ?

image

Also the header and footer lines now have a white bg, I guess because their intended reverse video is being reversed.
Is that new reversing behaviour needed - have you got an example where it helps ?

I noticed some other TERM cases we should probably handle more gracefully, but they aren't caused by this PR:

~$ TERM=dumb hledger-ui --bs -2
hledger-ui: Error: user error (Terminal does not define required capability "cup")

~$ TERM= hledger-ui --bs -2
hledger-ui: setupTerm: Couldn't look up terminfo entry ""

~$ env -u TERM hledger-ui-1.42.1 --bs -2
hledger-ui-1.42.1: TERM environment variable not set

@simonmichael
Copy link
Owner

Let's keep supporting --theme=default as a (undocumented) alias for --theme=light, to avoid breakage.

You suggested renaming greenterm to greenonblack - I'd be ok with it (with a compatibility alias).

I'd also be ok with renaming terminal. I have a hard time finding a name that communicates intuitively what it will look like. I guess "inherit" is another reasonable choice, though will be a little unclear to some. Looking at the code, it just sets the borders to white on black, and sets the selected item to reverse video. I'm not sure how useful that is. The goal was a theme that disturbs your usual terminal colours as little as possible. Perhaps your monochrome-with-reverse-video mode should be used here. Would "mono" or "monochrome" also be reasonable names ?

@simonmichael simonmichael added needs-discussion To unblock: needs more discussion/review/exploration and removed needs-testing To unblock: needs more developer testing or general usage needs-review To unblock: needs more code/docs/design review by someone labels May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-discussion To unblock: needs more discussion/review/exploration ui The hledger-ui tool.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants