zsh-workers
 help / color / mirror / code / Atom feed
* possible PATCH to colors function
@ 2023-07-17 17:44 Jim
  2023-07-17 18:40 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Jim @ 2023-07-17 17:44 UTC (permalink / raw)
  To: devs

[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]

Hi all,

For the group's consideration.

[bf]g_bold for both <color> and <bright-color> produces  the same result.
  bold with the same "intensity" for both <color> or <bright-color>

I assume this is just the way ansi works.  There is a way of producing two
intensities.
This can be done by adding "faint"(02) to the ansi code to either <color> or
<bright-color>.

If this is something that the group feels could/should be done the following
patch to colors can produce two intensities.

diff --git a/Functions/Misc/colors b/Functions/Misc/colors
index 8a0cec383..fb2548aee 100644
--- a/Functions/Misc/colors
+++ b/Functions/Misc/colors
@@ -120,7 +120,9 @@ bold_color="$lc${color[bold]}$rc"
 typeset -AHg fg fg_bold fg_no_bold
 for k in ${(k)color[(I)fg-*]}; do
     fg[${k#fg-}]="$lc${color[$k]}$rc"
-    fg_bold[${k#fg-}]="$lc${color[bold]};${color[$k]}$rc"
+    [[ $k == *bright* ]] \
+      && fg_bold[${k#fg-}]="$lc${color[bold]};${color[$k]}$rc" \
+      ||
fg_bold[${k#fg-}]="$lc${color[faint]};${color[bold]};${color[$k]}$rc"
     fg_no_bold[${k#fg-}]="$lc${color[normal]};${color[$k]}$rc"
 done

@@ -129,6 +131,8 @@ done
 typeset -AHg bg bg_bold bg_no_bold
 for k in ${(k)color[(I)bg-*]}; do
     bg[${k#bg-}]="$lc${color[$k]}$rc"
-    bg_bold[${k#bg-}]="$lc${color[bold]};${color[$k]}$rc"
+    [[ $k == *bright* ]] \
+      && bg_bold[${k#bg-}]="$lc${color[bold]};${color[$k]}$rc" \
+      ||
bg_bold[${k#bg-}]="$lc${color[faint]};${color[bold]};${color[$k]}$rc"
     bg_no_bold[${k#bg-}]="$lc${color[normal]};${color[$k]}$rc"
 done

Regards,

Jim Murphy

[-- Attachment #2: Type: text/html, Size: 2120 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: possible PATCH to colors function
  2023-07-17 17:44 possible PATCH to colors function Jim
@ 2023-07-17 18:40 ` Bart Schaefer
  2023-07-17 18:48   ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2023-07-17 18:40 UTC (permalink / raw)
  To: linuxtechguy; +Cc: devs

On Mon, Jul 17, 2023 at 10:45 AM Jim <linux.tech.guy@gmail.com> wrote:
>
> [bf]g_bold for both <color> and <bright-color> produces  the same result.
>   bold with the same "intensity" for both <color> or <bright-color>

I get different results for all three faint/normal/bright, in both
Gnome terminal and xterm.  I'm reluctant to change the default
appearance of "normal" everywhere in order to accommodate terminals
that (seemlngly) don't fully support "bright".

Just for interest, try this:
% colors
% print -r $'\e['$color[faint]\;${color[bright-red]}m88888${reset_color}\
$'\e['${color[red]}m88888${reset_color}\
$'\e['${color[bright-red]}m88888${reset_color}

(or with $'\n' before each backslash).  Do you really see no change
from red to bright-red?

I'd be more inclined to create a $fg[faint-*] etc. to match the
addition of $fg[bright-*] although with the bright variants there's no
alternate way to obtain them.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: possible PATCH to colors function
  2023-07-17 18:40 ` Bart Schaefer
@ 2023-07-17 18:48   ` Bart Schaefer
  2023-07-18 10:26     ` Jim
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2023-07-17 18:48 UTC (permalink / raw)
  To: linuxtechguy; +Cc: devs

On Mon, Jul 17, 2023 at 11:40 AM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> Just for interest, try this:
> % colors
> % print -r $'\e['$color[faint]\;${color[bright-red]}m88888${reset_color}\
> $'\e['${color[red]}m88888${reset_color}\
> $'\e['${color[bright-red]}m88888${reset_color}

Might be easier to see with :gs/red/yellow

In fact with yellow I can see a difference between "faint yellow" and
"faint bright-yellow" whereas that's not obvious to me with red.

print -r $'\e['$color[faint]\;${color[yellow]}m#####${reset_color}.\
$'\e['$color[faint]\;${color[bright-yellow]}m#####${reset_color}.\
$'\e['${color[yellow]}m#####${reset_color}.\
$'\e['${color[bright-yellow]}m#####${reset_color}


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: possible PATCH to colors function
  2023-07-17 18:48   ` Bart Schaefer
@ 2023-07-18 10:26     ` Jim
  2023-07-18 11:18       ` Roman Perepelitsa
  0 siblings, 1 reply; 6+ messages in thread
From: Jim @ 2023-07-18 10:26 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: devs

[-- Attachment #1: Type: text/plain, Size: 2902 bytes --]

On Mon, Jul 17, 2023 at 1:48 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:

> On Mon, Jul 17, 2023 at 11:40 AM Bart Schaefer
> <schaefer@brasslantern.com> wrote:
> >
> > Just for interest, try this:
> > % colors
> > % print -r $'\e['$color[faint]\;${color[bright-red]}m88888${reset_color}\
> > $'\e['${color[red]}m88888${reset_color}\
> > $'\e['${color[bright-red]}m88888${reset_color}
>
> Might be easier to see with :gs/red/yellow
>
> In fact with yellow I can see a difference between "faint yellow" and
> "faint bright-yellow" whereas that's not obvious to me with red.
>
> print -r $'\e['$color[faint]\;${color[yellow]}m#####${reset_color}.\
> $'\e['$color[faint]\;${color[bright-yellow]}m#####${reset_color}.\
> $'\e['${color[yellow]}m#####${reset_color}.\
> $'\e['${color[bright-yellow]}m#####${reset_color}
>

Hopefully I didn't miss something with your answers, or misinterpreted it.

I get the same results with your code.  But the patch has to do with
${color[bold]}.
Without faint the result of bold is the same for <color> and
<bright-color>.  With
faint the result is different intensity.

w/o faint both <color> and <bright-color> produces one intensity
with faint both <color> and <bright-color> produces a different intensity

The following should demonstrate what I'm trying to say.  I added
${color[reverse]}
as I believe it makes it a bit easier to see the difference.

print -r \
$'\e['${color[faint]}\;${color[bright-yellow]}\;${color[reverse]}m${(r.10..
.)}${reset_color}\
$'\e['${color[faint]}\;${color[yellow]}\;${color[reverse]}m${(r.10..
.)}${reset_color}\
$'\e['${color[yellow]}\;${color[reverse]}m${(r.10.. .)}${reset_color}\
$'\e['${color[bright-yellow]}\;${color[reverse]}m${(r.10.. .)}${reset_color}
print -r \
$'\e['${color[bold]}\;${color[faint]}\;${color[bright-yellow]}\;${color[reverse]}m${(r.10..
.)}${reset_color}\
$'\e['${color[bold]}\;${color[faint]}\;${color[yellow]}\;${color[reverse]}m${(r.10..
.)}${reset_color}\
$'\e['${color[bold]}\;${color[yellow]}\;${color[reverse]}m${(r.10..
.)}${reset_color}\
$'\e['${color[bold]}\;${color[bright-yellow]}\;${color[reverse]}m${(r.10..
.)}${reset_color}

I do not have gnome-terminal installed on my system but am using
xfce4-terminal as my
primary terminal.  TERM is set to vte-256color except where I am using tmux
then
TERM is set to tmux-256color

BTW, xfce yellows are very different from one another <color> is a brown,
 where <bright-color> is yellow.

Since gnome and xfce are both based on vte, assuming TERM doesn't cause
issues
I would hope both would produce similar results.  But assuming gets me in
hot water
way too often.

Also tested on:
xterm - TERM=xterm-2556color
uxterm - TERM=xterm-256color

tested on kitty, but kitty seems to not deal with faint very well
only installed kitty for testing

Regards,

Jim

[-- Attachment #2: Type: text/html, Size: 3944 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: possible PATCH to colors function
  2023-07-18 10:26     ` Jim
@ 2023-07-18 11:18       ` Roman Perepelitsa
  2023-07-18 12:48         ` Jim
  0 siblings, 1 reply; 6+ messages in thread
From: Roman Perepelitsa @ 2023-07-18 11:18 UTC (permalink / raw)
  To: linuxtechguy; +Cc: Bart Schaefer, devs

[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]

On Tue, Jul 18, 2023 at 12:27 PM Jim <linux.tech.guy@gmail.com> wrote:
>
>
> I get the same results with your code.  But the patch has to do with ${color[bold]}.
> Without faint the result of bold is the same for <color> and <bright-color>.  With
> faint the result is different intensity.

I haven't been following this discussion very closely. It's not
unlikely that my comment will miss the mark.

Most graphical terminal emulators have an option that controls the
meaning of bold. In GNOME Terminal it's the checkbox "Show bold text
in bright colors". It can be found on the "Colors" tab. If unchecked,
bold text is rendered with the bold font and the same color as regular
text. This is similar to the meaning of bold in rich text editors. If
checked, bold text with the colors 0-7 (inclusive) gets rendered with
the original color plus 8. Note that adding 8 to the color doesn't
necessarily result in a brighter color. The actual result depends on
the terminal's color palette.

I've attached two screenshots that show the output of the following
command in GNOME Terminal with Tango palette:

    print -P $'%4F4\n%12F12\n%B%4F4bold\n%12F12bold%f%b'

- bold-is-bold.jpg: "Show bold text in bright colors" unchecked.
- bold-is-bold-and-bright.jpg: "Show bold text in bright colors" checked.

FWIW, I always uncheck "Show bold text in bright colors" or its
equivalent in all terminals that I use. I want "bold" to mean the same
thing in the terminal as everywhere else: use the bold font, keep the
same color. In addition, I find it counterintuitive when bold text
changes its color ONLY if the original color was in 0-7.

Roman.

[-- Attachment #2: bold-is-bold-and-bright.jpg --]
[-- Type: image/jpeg, Size: 14044 bytes --]

[-- Attachment #3: bold-is-bold.jpg --]
[-- Type: image/jpeg, Size: 13843 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: possible PATCH to colors function
  2023-07-18 11:18       ` Roman Perepelitsa
@ 2023-07-18 12:48         ` Jim
  0 siblings, 0 replies; 6+ messages in thread
From: Jim @ 2023-07-18 12:48 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Bart Schaefer, devs


[-- Attachment #1.1: Type: text/plain, Size: 1861 bytes --]

On Tue, Jul 18, 2023 at 6:18 AM Roman Perepelitsa <
roman.perepelitsa@gmail.com> wrote:

> On Tue, Jul 18, 2023 at 12:27 PM Jim <linux.tech.guy@gmail.com> wrote:
> >
> >
> > I get the same results with your code.  But the patch has to do with
> ${color[bold]}.
> > Without faint the result of bold is the same for <color> and
> <bright-color>.  With
> > faint the result is different intensity.
>
> I haven't been following this discussion very closely. It's not
> unlikely that my comment will miss the mark.
>
>
Don't think you missed the mark.  I believe it is all in the way you look
at it.  I see  your point.  The patch adds another intensity that bold
doesn't
do.  Even though gnome, xfce, xterm ... all seem to do somewhat the
same thing with bold, I was looking for a way to get another option with
bold when producing output.  Personally ... I believe if using a different
intensity color you should  get a different intensity bold output. It
appears
I'm somewhat alone in this thinking.

Most graphical terminal emulators have an option that controls the
>
CLIP


> FWIW, I always uncheck "Show bold text in bright colors" or its
> equivalent in all terminals that I use. I want "bold" to mean the same
> thing in the terminal as everywhere else: use the bold font, keep the
> same color. In addition, I find it counterintuitive when bold text
> changes its color ONLY if the original color was in 0-7.
>
> Roman.
>

Need to think about this.  Bold doesn't seem to care if the colors were 0-7
or 8-15. Bold always outputs 8-15. What my patch was trying to do was to
correct this. As I originally said, this is a patch for the group's
consideration.
I'll respect whatever the group believes is correct.

FWIW I also attached some screenshots from xfce with bold turned on and off.

Regards,

Jim

[-- Attachment #1.2: Type: text/html, Size: 2894 bytes --]

[-- Attachment #2: script_text_output_xfcd_bold_off.png --]
[-- Type: image/png, Size: 4124 bytes --]

[-- Attachment #3: script_text_output_xfcd_bold_on.png --]
[-- Type: image/png, Size: 5344 bytes --]

[-- Attachment #4: txt_xfce_bold_off.png --]
[-- Type: image/png, Size: 76082 bytes --]

[-- Attachment #5: script_output_xfce_bold_on.png --]
[-- Type: image/png, Size: 3476 bytes --]

[-- Attachment #6: txt_w_xfce_bold_on.png --]
[-- Type: image/png, Size: 79846 bytes --]

[-- Attachment #7: script_output_xfce_bold_off.png --]
[-- Type: image/png, Size: 3674 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-18 12:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-17 17:44 possible PATCH to colors function Jim
2023-07-17 18:40 ` Bart Schaefer
2023-07-17 18:48   ` Bart Schaefer
2023-07-18 10:26     ` Jim
2023-07-18 11:18       ` Roman Perepelitsa
2023-07-18 12:48         ` Jim

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).