GNOME Bugzilla – Bug 307073
[patch] ability to selected background for reversed text
Last modified: 2021-06-10 13:16:57 UTC
I miss the capability similar to xterm's rvc flag, e.g. to use highlight color (if previously set by vte_terminal_set_color_highlight()) to display reversed text. Example: you use thin font (like Andale Mono) and green text on black background (not an unusual setup), and text highlighted by less or vim when you do search displays as black on green background, which is hardly readable. Using the feature similar to xterm's rvc, such text can instead be highlighted by using grey background. To my mind, this improves usability and therefore quite important. Attached patch implement this functionality by adding vte_terminal_set_highlight_reversed() function. Patch is against vte-0.11.12 but applies cleanly (with fuzz) to latest cvs as well.
Created attachment 47513 [details] [review] adds vte_terminal_set_highlight_reversed()
I have checked that the patch still applies for 0.14.0. Would you mind merging it? The feature is present in good old xterm, why can't vte have it?
I have checked that the patch still applies cleanly to 0.14.2. Please merge. It won't do any harm.
I have a new patch which applies on top of vte-0.16.x (tried with 0.16.1, 0.16.8, 0.16.9). Thus moving version to 0.16.x. I will attach the patch in a moment.
Created attachment 96944 [details] [review] adds vte_terminal_set_highlight_reversed() function (for 0.16.x branch)
Please, can somebody say a word about how do I proceed with this bug. * I keep maintaining this patch for my boxes for more than two years already; * the functionality is simple enough that even xterm has it * the patch does not complicate the code or do any other harm to anybody/anything. Please please merge
Or maybe you want to approach it differently, i.e. having a function similar to vte_terminal_set_color_highlight(), say, vte_terminal_set_color_reversed, which would be something like /** * vte_terminal_set_color_reversed * @terminal: a #VteTerminal * @highlight_background: the new color to use for (otherwise) reversed text * * Sets the background color for text which is reversed (attr.reverse is set). * If %NULL, reversed text will be drawn with foreground and background colors * reversed. */ I could implement that one if you so desire.
Chris, Mariano, other vte hackers, any idea? The API in the patch definitely looks like a hack to me. But then I apprecate some such hacks in xterm, like using a different color for bold text, etc... The API proposed in comment #7 makes more sense to me at least.
(In reply to comment #8) > Chris, Mariano, other vte hackers, any idea? The API in the patch definitely > looks like a hack to me. But then I apprecate some such hacks in xterm, like > using a different color for bold text, etc... The API proposed in comment #7 > makes more sense to me at least. > OK, I'm changing the bug summary and will now attach a tested patch against vte-0.16.9 which adds vte_terminal_set_color_reversed()
Created attachment 98338 [details] [review] adds vte_terminal_set_color_reversed()
I have tested that the patch in comment #10 applies fine and work with vte-0.16.10. Any chances of getting it accepted, or otherwise providing the bit of functionality I miss from vte? <rant> It's been a long time, I am tired of maintaining it off the tree for my 3-4 PCs. More to say, I can not suggest implementing that in programs using VTE (gnome-terminal, XFCE Terminal) since this bit is still not it. So I have to maintain patches against those as well. Please, if it's not clear what I am trying to achieve with this bit of functionality -- please ask, I will provide screenshots and a better explanation. Please, if there is any reason why this can not be included -- please name it and close the bug as WONTFIX or similar, just for the sake of not giving the false hope. </rant>
Now that's bordering on harassing! It's simple: no one has time for this. I have time committing a simple patch, but not enough to review the suggested API first. That's the main problem. For example, why should it set background for reversed text as opposed to foreground which is most other vte_terminal_set_color_*() calls do.
(In reply to comment #12) > For example, why should it set background for > reversed text as opposed to foreground which is most other > vte_terminal_set_color_*() calls do. Well, it's a bit long story. First, we introduced vte_terminal_set_color_highlight(), like this: void vte_terminal_set_color_highlight(VteTerminal *terminal, const GdkColor *highlight_background); By default, highlighted text is drawn by swapping foreground and background. For some fore/back colors this looks ugly, so the function enables drawing highlighted text with the same foreground but different background. I will attach a pic to demonstrate that. Second, some programs also use "reversed" attribute for some text. Example would be "less" which draws status line this way. Again, this brings in the same problem -- with some fore/back colors this looks ugly. So we want to introduce vte_terminal_set_color_reversed(), which does the very same for "reversed" text as vte_terminal_set_color_highlight() does for "highlighted" text. Now, this feature that I want is not unique. Xterm's colorRV and colorRVMode is doing the same thing: colorRV (class ColorRV) This specifies the color to use to display reverse characters if the ``colorRVMode'' resource is enabled. The default is ``XtDefaultForeground.'' colorRVMode (class ColorAttrMode) Specifies whether characters with the reverse attribute should be displayed in color. Note that setting colorMode off dis- ables all colors, including this. The default is ``false.''
Created attachment 101478 [details] Screenshot demonstrating the effect Here is the screenshot demonstrating the effect of using the proposed vte_terminal_set_color_reversed() function. This is a terminal running "ls | less". Upper part is default: "less" status line is displayed by swapping foreground and background colors. Lower part is after we call vte_terminal_set_color_reversed() with reversed_background set to some grey color. As you see, now text with 'reversed' attribute set is displayed not by swapping fore/back, but by using the specified color for background.
I've just added a screenshot which demonstrates what I'm trying to achieve. If you don't like the proposed API, say, you want to be able to set both fore and back for text with 'reversed' attribute, please say so and I will do a patch. PS I have also checked that the proposed patch applies fine and works with vte-0.16.11.
Created attachment 355665 [details] [review] Introduce ability to set colors for reversed text Here is another attempt to solve this. Attached is the patch against latest git (0.49.1-15-gf82a04b). Below is the copy-paste of the commit message: ----- This commit adds an ability to choose colors (bg, fg, or both) for text that has reversed attribute set ("reverse video" in ECMA-48). By definition, such text is displayed by reversing the foreground and background colors used for normal text. There are many applications using this feature -- less, vim, and powertop come to mind. The issue is, for some color and font combinations (such as when using a thin terminal font like Andale Mono or Terminus), reversed text is not easily readable. There are many approaches to solving this. For one thing, xterm offers rvc flag to use highlight color (if previously set) to display reversed text. This patch enables to set arbitrary colors for reversed text foreground and/or background. If both colors are unset, which is the default, text is displayed as before. Examples of how to test this using testvte: ./src/testvte --reverse "--reversed-background-color=#404040" ./src/testvte "--reversed-foreground-color=#FFFF60" Examples of how to produce reversed text: ls -l | less -M echo -e some \\033[7mreversed\\033[27m text ---
Created attachment 355696 [details] another screenshot demoing the functionality (at the bottom)
I've adapted the patch to git master. Egmont, do you have an opinion on this: do we want this, or not? I'm indifferent either way, it's just I want to get this out of the way before the palette rework for bug 655030.
(In reply to Christian Persch from comment #18) > I'm indifferent Actually slightly disfavourable, but not enough that I want to make the decision unilaterally :-)
Today I found an alternative solution (for less only): $ grep LESS_TERM ~/.bashrc export LESS_TERMCAP_so="$(tput setab 8)" export LESS_TERMCAP_se="$(tput sgr0)" Still, it would be great to have a feature parity with a (venerable) xterm.
Created attachment 368813 [details] [review] [PATCH] Introduce an ability to set colors for reversed text Rebased to the latest git (mostly vte app changes)
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vte/-/issues/1061.