patchGNU nano - Patches: patch #10390, rcfile: map gray #RGB codes to...


You are not allowed to post comments on this tracker with your current authentication level.

patch #10390: rcfile: map gray #RGB codes to xterm grayscale

Submitter:  Andy Koppe <ak2>
Submitted:  Tue 12 Sep 2023 08:16:38 PM UTC
Priority:  5 - Normal Status:  Done
Privacy:  Public Assigned to:  bens
Open/Closed:  Open Release:  None

Jump to the original submission

Mon 25 Sep 2023 07:37:01 PM UTC, comment #8: 

Great, thank you!

Andy Koppe <ak2>
Mon 25 Sep 2023 02:21:02 PM UTC, comment #7: 

I've settled on this:

gray[] = { 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 18, 21, 23 };

(Six steps of 1, four steps of 2, two steps of 3, and one step of 2.)

Pushed to master, with some small tweaks of the commit message.  Thanks!

Benno Schulenberg <bens>
Group administrator
Sat 23 Sep 2023 03:42:16 PM UTC, comment #6: 

The formula that xterm and friends use for translating the grayscale to RGB values is 8+10*(index-232).

Hence, the lowest level is only 8, which explains why it's so dark, and I agree with leaving that out.

But the highest level is 238 (aka 0xEE), which is a bit further from white and looks suitable for the guidestripe to me.

So how about:

gray[] = { 1, 2, 3, 4, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23 };

But I'd be happy with your proposal as well.

Andy Koppe <ak2>
Sat 23 Sep 2023 09:37:04 AM UTC, comment #5: 

Thanks.  I've tried the different levels.  In my opinion the darkest and lightest grey are not useful, as practically invisible on black or white.  And the greys near the lower end could use some more steps.  So I would like to propose this array:

gray[] = { 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 17, 19, 22 };

Could you agree to that?

Benno Schulenberg <bens>
Group administrator
Mon 18 Sep 2023 09:26:16 PM UTC, comment #4: 

Patch v2 with minimal changes attached.

(file #55145)

Andy Koppe <ak2>
Mon 18 Sep 2023 11:46:20 AM UTC, comment #3: 

Allowing a darker grey to make the guiding stripe less obtrusive (on a dark background) is a good argument.  Maybe good enough to make it worth the code.

But I don't like the patch: please don't rename things nor change comments -- change only what is necessary to add the functionality.  I can always clean things up afterward.

Benno Schulenberg <bens>
Group administrator
Sat 16 Sep 2023 11:16:11 AM UTC, comment #2: 

I agree that 14 gray levels are complete overkill for syntax highlighting. I'm proposing to add them primarily for use in the color settings of nano UI elements.

For example, I use a dark theme desktop and black terminal background, and something like 'set scrollercolor #555,#222' makes for an indicator bar that fits in nicely with scrollbars across the rest of the desktop.

A very dark grey tone can also be useful for the 'stripecolor', to make the guide stripe visible but unobtrusive, or to set the background of the title, help and mini bars or the line number sidebar apart from the main editing area without creating a large contrast.

Conversely, light gray tones can play similar roles with a light background.

Andy Koppe <ak2>
Thu 14 Sep 2023 03:19:20 PM UTC, comment #1: 

The original patch that added #rgb colors had something similar, but I was against it: these colors are meant for syntax highlighting -- why would anyone want fourteen levels of grey?  Who can distinguish them?  See patch #10131 and search for "gray-scaling".

Benno Schulenberg <bens>
Group administrator
Tue 12 Sep 2023 08:16:38 PM UTC, original submission:  

When the red, green and blue components of a three-digit hex #RGB code are equal and they aren't #000 for black or #FFF for white, map them to xterm-256color's 24-level grayscale ranging from index 232 to 255.

This means that the 14 gray levels available in #RGB codes all map to different levels, whereas previously they mapped to only the four gray levels available in the color cube (when they didn't map to black or white).

Andy Koppe <ak2>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by ak2 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-09-25 bens StatusNone Done
        Assigned toNone bens
    2023-09-18 ak2 Attached File- Added v2-0001-rcfile-map-gray-RGB-codes-to-xterm-grayscale.patch, #55145
    2023-09-12 ak2 Attached File- Added 0001-rcfile-map-gray-RGB-codes-to-xterm-grayscale.patch, #55131

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code