dnkl/foot
41
2.0k
Fork
You've already forked foot
243

feat(render): add configurable attribute colors for bold, italic, and underline #2264

Open
spaceone wants to merge 1 commit from spaceone/foot:color-bold into master
pull from: spaceone/foot:color-bold
merge into: dnkl:master
dnkl:master
dnkl:osc-5522
dnkl:sixel-heap-buffer-overflow
dnkl:releases/1.27
dnkl:releases/1.26
dnkl:releases/1.25
dnkl:releases/1.24
dnkl:multi-cursor
dnkl:releases/1.23
dnkl:pixman-16f-2
dnkl:releases/1.22
dnkl:releases/1.21
dnkl:releases/1.20
dnkl:releases/1.19
dnkl:releases/1.18
dnkl:releases/1.17
dnkl:releases/1.16
dnkl:releases/1.15
dnkl:releases/1.14
dnkl:releases/1.13
dnkl:releases/1.12
dnkl:releases/1.11
dnkl:releases/1.10
dnkl:releases/1.9
dnkl:releases/1.8
dnkl:releases/1.7
dnkl:releases/1.6
dnkl:releases/1.5
dnkl:releases/1.4
dnkl:releases/1.3
dnkl:releases/1.2
dnkl:releases/1.1
dnkl:releases/1.0
First-time contributor
Copy link

Introduce optional color theme entries for bold, italic, and underline text
when the foreground color is default. This allows legacy applications using
SGR attributes instead of explicit colors to be rendered with user-defined
attribute colors. Brightening via bold_in_bright is suppressed when an
explicit attribute color is applied.

This adds compatibility with the rxvt-unicode settings colorBD,
colorIT and colorUL.

Fixes: #2261

Introduce optional color theme entries for bold, italic, and underline text when the foreground color is default. This allows legacy applications using SGR attributes instead of explicit colors to be rendered with user-defined attribute colors. Brightening via `bold_in_bright` is suppressed when an explicit attribute color is applied. This adds compatibility with the rxvt-unicode settings `colorBD`, `colorIT` and `colorUL`. Fixes: #2261
Collaborator
Copy link

I noticed on IRC you mentioned "vim, git, weechat, tmux" as examples of apps where you'd want to use these options. I'm not sure if I missed some extra context, but one question that comes to mind is: why not configure colors/attributes exactly how you want them in the apps themselves?

Is this really about making bold turn into green because "that's what I did in rxvt" or is there more to it than that? The reason I ask is because bold-text-in-bright is much the same thing and already causes lots of confusion.

If these options are added, I think we need a clearer justification on the record than "it's for legacy apps". We need a falsifiable example where we can either say "ok, that's a valid use case" or "no, because you can just configure the app the sensible way". At the very least I think they should be buried in the [tweaks] section and/or have their use clearly discouraged in the manual.

I noticed on IRC you mentioned "vim, git, weechat, tmux" as examples of apps where you'd want to use these options. I'm not sure if I missed some extra context, but one question that comes to mind is: why not configure colors/attributes exactly how you want them in the apps themselves? Is this really about making bold turn into green because "that's what I did in rxvt" or is there more to it than that? The reason I ask is because `bold-text-in-bright` is much the same thing and already causes lots of confusion. If these options are added, I think we need a clearer justification on the record than "it's for legacy apps". We need a falsifiable example where we can either say "ok, that's a valid use case" or "no, because you can just configure the app the sensible way". At the very least I think they should be buried in the `[tweaks]` section and/or have their use clearly discouraged in the manual.
Author
First-time contributor
Copy link

Thank you for the immediate feedback!

why not configure colors/attributes exactly how you want them in the apps themselves?

  1. Because I switch between colorschemes (dark and light) and the colors i would have to configure in each app wouldn't fit for both variants.
  2. Also when selecting text, there is a difference between the concept of configuring the app and the actual effect of switching bold color: foot currently doesn't just switch foreground with background but uses the foreground-color as text and regular7 as background (see second screenshot below).
  3. And I don't think every app supports all settings and I have a lot more config options to maintain instead of just one for the terminal.

Is this really about making bold turn into lime green because "that's what I did in rxvt" or is there more to it than that? The reason I ask is because bold-text-in-bright is much the same thing and already causes lots of confusion.

I think it's just that, yes.
bold-text-in-bright is even more essential to me. It makes bold text easily recognizable. I makes my workflow a lot faster as my brain is used to some kind of speed-reading-with-color-context.

If these options are added, I think we need a clearer justification on the record than "it's for legacy apps". We need a falsifiable example where we can either say "ok, that's a valid use case" or "no, because you can just configure the app the sensible way".

The term "legacy apps" probably don't fit exactly, as the tools I use are common tools.
Hm, how would I give the falsifiable examples?
Let's start with one example here: git.

grafik

On the left, there is the original urxvt and on the right foot without bold option. You can see that the diff-markers are bold-foregorund-green and not easy distinguishable from the text/content (applies to green, grey and blue foreground colors).

The selected text below is also displayed differently, previously easier to read.

Additionally I use a very small font (DeJaVu 9 point), which in other contexts make bold indistinguishable from regular foreground.

Let's try to configure git accordingly:

[color "diff"]
 meta = white bold
 frag = cyan
 old = red bold
 new = brightgreen bold

grafik

→ As mentioned above, the selection differs much.

At the very least I think they should be buried in the [tweaks] section and/or have their use clearly discouraged in the manual.

I do whatever you(maintainers) want, but it feels like that's a direct color related setting. Also foot now offers dark and light color themes. In another colorscheme I don't use bold-to-text.
Also if it makes the code/tests more complex (didn't have a look, but there were some color-specific-functions), I wouldn't prefer this.

The reason being that it weakens the whole terminal ecosystem when authors of TUI apps have to consider things like "but what if bold is actually mapped to a color that's invisible against this background"?

OK, I would see the user of that config-option as the risk taker here. I am using that since 15 years and I never saw any problems before.

Thank you for the immediate feedback! > why not configure colors/attributes exactly how you want them in the apps themselves? 1. Because I switch between colorschemes (dark and light) and the colors i would have to configure in each app wouldn't fit for both variants. 2. Also when selecting text, there is a difference between the concept of configuring the app and the actual effect of switching bold color: foot currently doesn't just switch foreground with background but uses the foreground-color as text and `regular7` as background (see second screenshot below). 3. And I don't think every app supports all settings and I have a lot more config options to maintain instead of just one for the terminal. > Is this really about making bold turn into lime green because "that's what I did in rxvt" or is there more to it than that? The reason I ask is because `bold-text-in-bright` is much the same thing and already causes lots of confusion. I think it's just that, yes. `bold-text-in-bright` is even more essential to me. It makes bold text easily recognizable. I makes my workflow a lot faster as my brain is used to some kind of speed-reading-with-color-context. > If these options are added, I think we need a clearer justification on the record than "it's for legacy apps". We need a falsifiable example where we can either say "ok, that's a valid use case" or "no, because you can just configure the app the sensible way". The term "legacy apps" probably don't fit exactly, as the tools I use are common tools. Hm, how would I give the falsifiable examples? Let's start with one example here: git. ![grafik](/attachments/a535fc8d-925e-4439-9b37-b579c5234135) On the left, there is the original urxvt and on the right foot without bold option. You can see that the diff-markers are bold-foregorund-green and not easy distinguishable from the text/content (applies to green, grey and blue foreground colors). The selected text below is also displayed differently, previously easier to read. Additionally I use a very small font (DeJaVu 9 point), which in other contexts make bold indistinguishable from regular foreground. Let's try to configure `git` accordingly: ``` [color "diff"] meta = white bold frag = cyan old = red bold new = brightgreen bold ``` ![grafik](/attachments/5f0f37a1-5430-4d80-a9d0-b35738529286) → As mentioned above, the selection differs much. > At the very least I think they should be buried in the [tweaks] section and/or have their use clearly discouraged in the manual. I do whatever you(maintainers) want, but it feels like that's a direct color related setting. Also foot now offers dark and light color themes. In another colorscheme I don't use bold-to-text. Also if it makes the code/tests more complex (didn't have a look, but there were some color-specific-functions), I wouldn't prefer this. > The reason being that it weakens the whole terminal ecosystem when authors of TUI apps have to consider things like "but what if bold is actually mapped to a color that's invisible against this background"? OK, I would see the user of that config-option as the risk taker here. I am using that since 15 years and I never saw any problems before.
Collaborator
Copy link

The reason being that it weakens the whole terminal ecosystem when authors of TUI apps have to consider things like "but what if bold is actually mapped to a color that's invisible against this background"?

In case anyone is wondering, I deleted this quoted comment shortly after sending because I feel like it's a weak example. It kind of puts across my general concern1 , but I don't think that example in particular is likely to be a problem.

OK, I would see the user of that config-option as the risk taker here. I am using that since 15 years and I never saw any problems before.

Fair enough. I'm not against these options existing per se and I guess they already do in other terminals anyway. I just think the example use case in the docs should be removed, because the way it's worded currently could be taken as legitimizing it instead of discouraging it. IMO it would be better to just discourage its use in general and not mention any use cases.


  1. i.e. that there's a certain level of understanding/cooperation between terminals and apps ("the ecosystem"), not just between the terminal and the user ↩︎

> The reason being that it weakens the whole terminal ecosystem when authors of TUI apps have to consider things like "but what if bold is actually mapped to a color that's invisible against this background"? In case anyone is wondering, I deleted this [quoted comment] shortly after sending because I feel like it's a weak example. It kind of puts across my general concern[^1], but I don't think that example in particular is likely to be a problem. > OK, I would see the user of that config-option as the risk taker here. I am using that since 15 years and I never saw any problems before. Fair enough. I'm not against these options existing per se and I guess they already do in other terminals anyway. I just think the example use case in the docs should be removed, because the way it's worded currently could be taken as legitimizing it instead of discouraging it. IMO it would be better to just discourage its use in general and not mention any use cases. [^1]: i.e. that there's a certain level of understanding/cooperation between terminals and apps ("the ecosystem"), not just between the terminal and the user [quoted comment]: https://codeberg.org/dnkl/foot/pulls/2264#issuecomment-9938901:~:text=The%20reason%20being,-that
Owner
Copy link

I see two aspects to this:

  1. What @craigbarnes have mentioned already; the contract between the terminal emulator and the terminal application. Terminal applications need to be able to count on bold being bold. We want to encourage applications to use the bold attribute when bold is the font effect they're going after. We don't want them to use bold instead of brighter colors.

  2. While many terminal applications are theme:able, not all are. A user can configure the 256 default terminal colors, and thus "theme" the application anyway. But they cannot easily change bold/italic/underline formatting. This PR "fixes" that.

We don't want to break the terminal emulator/application contract. But I think these options are fine as long as they are clearly documented to state they are for 2), not 1). We don't have to go all out discouraging their use (it'd be better to simply not merge this at all).

In short, I don't really have anything against this PR. That said, it is likely a fairly exotic feature, in the sense that most applications can be themed (which imho is the correct way to "solve" this), and that most people are fine with bold being bold, and nothing else.

I see two aspects to this: 1. What @craigbarnes have mentioned already; the contract between the terminal emulator and the terminal application. Terminal applications need to be able to count on bold being bold. We want to encourage applications to use the bold attribute when bold is the font effect they're going after. We don't want them to use bold instead of brighter colors. 2. While many terminal applications are theme:able, not all are. A user can configure the 256 default terminal colors, and thus "theme" the application anyway. But they cannot easily change bold/italic/underline formatting. This PR "fixes" that. We don't want to break the terminal emulator/application contract. But I think these options are fine as long as they are clearly documented to state they are for 2), not 1). We don't have to go all out discouraging their use (it'd be better to simply not merge this at all). In short, I don't really have anything against this PR. That said, it is likely a fairly exotic feature, in the sense that _most_ applications can be themed (which imho is the correct way to "solve" this), and that most people are fine with bold being bold, and nothing else.
dnkl left a comment
Copy link

I'd also be interrested in a before/after comparison of the vtebench, of LTO-release builds.

I'd also be interrested in a before/after comparison of the [vtebench](https://github.com/alacritty/vtebench), of LTO-release builds.
@ -1112,0 +1113,4 @@
Specifies the color to use for bold characters when the foreground color is the default (undefined).
This setting applies primarily to legacy applications that utilize SGR 1 codes instead of SGR 9 codes.
If not set, the behavior defaults to the terminals standard bold rendering. Default: unset.
Owner
Copy link

Please replace with plain '

Please replace `’` with plain `'`
spaceone marked this conversation as resolved
render.c Outdated
@ -724,0 +729,4 @@
} else if (cell->attrs.italic && term->colors.italic >> 24 == 0) {
_fg = term->colors.italic;
allow_brighten = false;
} else if (cell->attrs.underline && term->colors.underline >> 24 == 0) {
Owner
Copy link

Can you tag these with unlikely? I.e.

if (unlikely(cell->attrs.bold && term->colors.bold >> 24 == 0))
 ...
Can you tag these with `unlikely`? I.e. ```c if (unlikely(cell->attrs.bold && term->colors.bold >> 24 == 0)) ... ```
spaceone marked this conversation as resolved
spaceone force-pushed color-bold from 4864140c10
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
builds.sr.ht/freebsd-x64 Job completed
to f64ee82d3f
All checks were successful
builds.sr.ht/freebsd-x64 Job completed
2026年03月02日 16:16:03 +01:00
Compare
Author
First-time contributor
Copy link

FYI: I integrated your wished changes last week.
I think I don't have the infrastructure to do the vtebench benchmark comparision.

FYI: I integrated your wished changes last week. I think I don't have the infrastructure to do the vtebench benchmark comparision.
spaceone force-pushed color-bold from f64ee82d3f
All checks were successful
builds.sr.ht/freebsd-x64 Job completed
to bccc12b3fb
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
builds.sr.ht/freebsd-x64 Job completed
2026年04月13日 21:51:19 +02:00
Compare
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
builds.sr.ht/freebsd-x64 Job completed
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u color-bold:spaceone-color-bold
git switch spaceone-color-bold

Merge

Merge the changes and update on Forgejo.
git switch master
git merge --no-ff spaceone-color-bold
git switch spaceone-color-bold
git rebase master
git switch master
git merge --ff-only spaceone-color-bold
git switch spaceone-color-bold
git rebase master
git switch master
git merge --no-ff spaceone-color-bold
git switch master
git merge --squash spaceone-color-bold
git switch master
git merge --ff-only spaceone-color-bold
git switch master
git merge spaceone-color-bold
git push origin master
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/foot!2264
Reference in a new issue
dnkl/foot
No description provided.
Delete branch "spaceone/foot:color-bold"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?