After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 307073 - [patch] ability to selected background for reversed text
[patch] ability to selected background for reversed text
Status: RESOLVED OBSOLETE
Product: vte
Classification: Core
Component: general
unspecified
Other Linux
: Normal enhancement
: vte-0-52
Assigned To: VTE Maintainers
VTE Maintainers
[fixed-next]
Depends on:
Blocks: vte1.0
 
 
Reported: 2005-06-09 22:02 UTC by kir
Modified: 2021-06-10 13:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
adds vte_terminal_set_highlight_reversed() (2.69 KB, patch)
2005-06-09 22:05 UTC, kir
none Details | Review
adds vte_terminal_set_highlight_reversed() function (for 0.16.x branch) (2.72 KB, patch)
2007-10-09 15:56 UTC, kir
none Details | Review
adds vte_terminal_set_color_reversed() (3.16 KB, patch)
2007-11-01 20:01 UTC, kir
none Details | Review
Screenshot demonstrating the effect (60.77 KB, image/png)
2007-12-23 00:05 UTC, kir
  Details
Introduce ability to set colors for reversed text (14.07 KB, patch)
2017-07-14 23:12 UTC, kir
none Details | Review
another screenshot demoing the functionality (at the bottom) (12.01 KB, image/png)
2017-07-16 02:24 UTC, kir
  Details
[PATCH] Introduce an ability to set colors for reversed text (15.73 KB, patch)
2018-02-23 03:04 UTC, kir
none Details | Review

Description kir 2005-06-09 22:02:00 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.
Comment 1 kir 2005-06-09 22:05:07 UTC
Created attachment 47513 [details] [review]
adds vte_terminal_set_highlight_reversed()
Comment 2 kir 2006-09-11 16:42:22 UTC
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?
Comment 3 kir 2007-02-21 21:13:57 UTC
I have checked that the patch still applies cleanly to 0.14.2. Please merge. It won't do any harm.
Comment 4 kir 2007-10-09 15:55:10 UTC
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.
Comment 5 kir 2007-10-09 15:56:57 UTC
Created attachment 96944 [details] [review]
adds vte_terminal_set_highlight_reversed() function (for 0.16.x branch)
Comment 6 kir 2007-10-09 16:08:50 UTC
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
Comment 7 kir 2007-10-09 16:26:37 UTC
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.
Comment 8 Behdad Esfahbod 2007-10-24 03:58:36 UTC
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.
Comment 9 kir 2007-11-01 19:59:54 UTC
(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()
Comment 10 kir 2007-11-01 20:01:21 UTC
Created attachment 98338 [details] [review]
adds vte_terminal_set_color_reversed()
Comment 11 kir 2007-12-08 13:55:44 UTC
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>
Comment 12 Behdad Esfahbod 2007-12-08 22:46:30 UTC
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.
Comment 13 kir 2007-12-22 21:51:48 UTC
(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.''
Comment 14 kir 2007-12-23 00:05:29 UTC
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.
Comment 15 kir 2007-12-23 00:07:19 UTC
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.
Comment 16 kir 2017-07-14 23:12:43 UTC
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

---
Comment 17 kir 2017-07-16 02:24:13 UTC
Created attachment 355696 [details]
another screenshot demoing the functionality (at the bottom)
Comment 18 Christian Persch 2017-12-26 21:32:47 UTC
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.
Comment 19 Christian Persch 2017-12-26 21:34:33 UTC
(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 :-)
Comment 20 kir 2018-02-23 00:42:40 UTC
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.
Comment 21 kir 2018-02-23 03:04:57 UTC
Created attachment 368813 [details] [review]
[PATCH] Introduce an ability to set colors for reversed text

Rebased to the latest git (mostly vte app changes)
Comment 22 GNOME Infrastructure Team 2021-06-10 13:16:57 UTC
-- 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.