zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Update man pages to match change to Functions/Misc/colors
@ 2023-12-13 13:25 Jim
  2023-12-14  3:31 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Jim @ 2023-12-13 13:25 UTC (permalink / raw)
  To: devs


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

Hi all,

AFAICT ANSI defines "7" as reverse mode. Changes to the colors function now
uses reverse mode instead of standout mode. Upto and including version 5.8.1
standout was defined here as 03 which is italic. In 5.9 italic was added as
03 and
standout was moved to 07 but was also commented out. Also no-italic was
added as 23 and no-standout was moved to 27 and commented out.

The attached patch updates the man pages and would reflect the change.

The one thing that looks strange about the change is prompt %S and %s,
previously
standout mode, will now mean reverse mode.

What I don't know is if C code behind things like:

zle_highlight=(region:standout special:standout
suffix:bold isearch:underline paste:standout)
would now support
zle_highlight=(region:reverse special:reverse
suffix:bold isearch:underline paste:reverse)

There may also be legacy scripts to consider.

The attached patch is submitted for your consideration.

Regards,

Jim Murphy

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

[-- Attachment #2: standout_to_reverse.patch.txt --]
[-- Type: text/plain, Size: 6707 bytes --]

diff --git a/Doc/Zsh/compctl.yo b/Doc/Zsh/compctl.yo
index d06b31d25..967863838 100644
--- a/Doc/Zsh/compctl.yo
+++ b/Doc/Zsh/compctl.yo
@@ -471,7 +471,7 @@ be shown if there was at least one match added for the explanation
 string.
 
 The sequences tt(%B), tt(%b), tt(%S), tt(%s), tt(%U), and tt(%u) specify
-output attributes (bold, standout, and underline), tt(%F), tt(%f), tt(%K),
+output attributes (bold, reverse, and underline), tt(%F), tt(%f), tt(%K),
 tt(%k) specify foreground and background colours, and tt(%{)var(...)tt(%}) can
 be used to include literal escape sequences as in prompts.
 )
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 3f708eb5a..e232447c6 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -2025,7 +2025,7 @@ width, padded to the  right with spaces, while the lowercase form will
 be replaced by a variable width string.  As in other prompt strings, the
 escape sequences `tt(%S)', `tt(%s)', `tt(%B)', `tt(%b)', `tt(%U)',
 `tt(%u)' for entering and leaving the display modes
-standout, bold and underline, and `tt(%F)', `tt(%f)', `tt(%K)', `tt(%k)' for
+reverse, bold and underline, and `tt(%F)', `tt(%f)', `tt(%K)', `tt(%k)' for
 changing the foreground background colour, are also available, as is the form
 `tt(%{)...tt(%})' for enclosing escape sequences which display with zero
 (or, with a numeric argument, some other) width.
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index f43ac2257..7fce0ac5e 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -4292,11 +4292,11 @@ tt(colors) more than once.
 The eight base colors are: tt(black), tt(red), tt(green), tt(yellow),
 tt(blue), tt(magenta), tt(cyan), and tt(white).  Each of these has codes for
 foreground and background.  In addition there are seven intensity attributes:
-tt(bold), tt(faint), tt(standout), tt(underline), tt(blink), tt(reverse),
+tt(bold), tt(faint),  tt(underline), tt(blink), tt(reverse),
 and tt(conceal).  Finally, there are seven codes used to negate attributes:
 tt(none) (reset all attributes to the defaults), tt(normal)
-(neither bold nor faint), tt(no-standout), tt(no-underline), tt(no-blink),
-tt(no-reverse), and tt(no-conceal).
+(neither bold nor faint), tt(no-reverse), tt(no-underline), tt(no-blink),
+and tt(no-conceal).
 
 Some terminals do not support all combinations of colors and intensities.
 
diff --git a/Doc/Zsh/mod_complist.yo b/Doc/Zsh/mod_complist.yo
index 463486ff9..c16437934 100644
--- a/Doc/Zsh/mod_complist.yo
+++ b/Doc/Zsh/mod_complist.yo
@@ -254,7 +254,7 @@ matches to insert into the command line can be selected from this
 list.  In the list one match is highlighted using the value for tt(ma)
 from the tt(ZLS_COLORS) or tt(ZLS_COLOURS) parameter.  The default
 value for this is `tt(7)' which forces the selected match to be
-highlighted using standout mode on a vt100-compatible terminal.  If
+highlighted using reverse mode on a vt100-compatible terminal.  If
 neither tt(ZLS_COLORS) nor tt(ZLS_COLOURS) is set, the same terminal
 control sequence as for the `tt(%S)' escape in prompts is used.
 
diff --git a/Doc/Zsh/mod_curses.yo b/Doc/Zsh/mod_curses.yo
index e2d5690e2..d0002d135 100644
--- a/Doc/Zsh/mod_curses.yo
+++ b/Doc/Zsh/mod_curses.yo
@@ -105,7 +105,7 @@ foreground/background color pair for any successive character output.
 Each var(attribute) given on the line may be prepended by a tt(+) to set
 or a tt(-) to unset that attribute; tt(+) is assumed if absent.  The
 attributes supported are tt(blink), tt(bold), tt(dim), tt(reverse),
-tt(standout), and tt(underline).
+and tt(underline).
 
 Each var(fg_col)tt(/)var(bg_col) attribute (to be read as
 `var(fg_col) on var(bg_col)') sets the foreground and background color
diff --git a/Doc/Zsh/mod_watch.yo b/Doc/Zsh/mod_watch.yo
index d97a41d13..3afa410f5 100644
--- a/Doc/Zsh/mod_watch.yo
+++ b/Doc/Zsh/mod_watch.yo
@@ -72,7 +72,7 @@ item(tt(%K{)var(color)tt(}) LPAR()tt(%k)RPAR())(
 Start (stop) using a different background color.
 )
 item(tt(%S) LPAR()tt(%s)RPAR())(
-Start (stop) standout mode.
+Start (stop) reverse mode.  Previously known as standout mode.
 )
 item(tt(%U) LPAR()tt(%u)RPAR())(
 Start (stop) underline mode.
diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo
index 909012c8e..31d9c4595 100644
--- a/Doc/Zsh/prompt.yo
+++ b/Doc/Zsh/prompt.yo
@@ -229,7 +229,7 @@ item(tt(%U) LPAR()tt(%u)RPAR())(
 Start (stop) underline mode.
 )
 item(tt(%S) LPAR()tt(%s)RPAR())(
-Start (stop) standout mode.
+Start (stop) reverse mode.  Previously known as standout mode.
 )
 item(tt(%F) LPAR()tt(%f)RPAR())(
 Start (stop) using a different foreground colour, if supported
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 495bd86a8..987d688ac 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -997,7 +997,7 @@ itemiz(A highlight specification in the same format as
 used for contexts in the parameter tt(zle_highlight), see
 ifnzman(noderef(Character Highlighting))\
 ifzman(the section `Character Highlighting' below);
-for example, tt(standout) or tt(fg=red,bold).)
+for example, tt(reverse) or tt(fg=red,bold).)
 itemiz(Optionally, a string of the form `tt(memo=)var(token)'.
 The var(token) consists of everything between the `tt(=)' and the next
 whitespace, comma, NUL, or the end of the string.
@@ -2790,11 +2790,11 @@ item(tt(faint))(
 The characters in the given context are shown with a faint font weight.
 Not all terminals distinguish faint fonts.
 )
-item(tt(standout))(
-The characters in the given context are shown in the terminal's standout
+item(tt(reverse))(
+The characters in the given context are shown in the terminal's reverse
 mode.  The actual effect is specific to the terminal; on many terminals it
 is inverse video.  On some such terminals, where the cursor does not blink
-it appears with standout mode negated, making it less than clear where
+it appears with reverse mode negated, making it less than clear where
 the cursor actually is.  On such terminals one of the other effects
 may be preferable for highlighting the region and matched search string.
 )
@@ -2856,10 +2856,10 @@ enditem()
 If tt(zle_highlight) is not set or no value applies to a particular
 context, the defaults applied are equivalent to
 
-example(zle_highlight=LPAR()region:standout special:standout
-suffix:bold isearch:underline paste:standout+RPAR())
+example(zle_highlight=LPAR()region:reverse special:reverse
+suffix:bold isearch:underline paste:reverse+RPAR())
 
-i.e. both the region and special characters are shown in standout mode.
+i.e. both the region and special characters are shown in reverse mode.
 
 Within widgets, arbitrary regions may be highlighted by setting the
 special array parameter tt(region_highlight); see

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

* Re: [PATCH] Update man pages to match change to Functions/Misc/colors
  2023-12-13 13:25 [PATCH] Update man pages to match change to Functions/Misc/colors Jim
@ 2023-12-14  3:31 ` Bart Schaefer
  2023-12-17 14:05   ` Jim
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2023-12-14  3:31 UTC (permalink / raw)
  To: linuxtechguy; +Cc: devs

On Wed, Dec 13, 2023 at 5:27 AM Jim <linux.tech.guy@gmail.com> wrote:
>
> The one thing that looks strange about the change is prompt %S and %s, previously
> standout mode, will now mean reverse mode.

The "colors" function should not be conflated with the prompt escapes.
They have almost nothing to do with one another.  Changes to the
function do not affect prompts unless you are using the PROMPT_SUBST
option to interpolate variables defined by "colors".  What's emitted
by the prompt escapes has not changed as a result of any updates to
zsh:

% echo $ZSH_VERSION
5.8
% print -r ${(V%):-%Sstandout%s}
^[[7mstandout^[[27m
% Src/zsh -f
% echo $ZSH_VERSION
5.9.0.1-dev
% print -r ${(V%):-%Sstandout%s}
^[[7mstandout^[[27m
%

The trouble here is that what "standout" means is not well-defined --
from the zle_highlight doc:
     The characters in the given context are shown in the terminal's
     standout mode.  The actual effect is specific to the terminal; on
     many terminals it is inverse video.
If you're seeing %S change appearance, it's probably the result of a
terminal definition or other difference outside of zsh.  Prompts still
use whatever the terminal (or its terminfo file) defines as "standout"
for %S, and it would be wrong to assert that it always means
"reverse".

> AFAICT ANSI defines "7" as reverse mode. Changes to the colors function now
> uses reverse mode instead of standout mode. Upto and including version 5.8.1
> standout was defined here as 03 which is italic. In 5.9 italic was added as 03 and
> standout was moved to 07 but was also commented out. Also no-italic was
> added as 23 and no-standout was moved to 27 and commented out.

The lack of a firm definition of "standout" is why this change was
made.  Even "italic" remains a bit iffy; from
 https://en.wikipedia.org/wiki/ANSI_escape_code
 3  Italic  Not widely supported. Sometimes treated as inverse or blink.

(That wikipedia page also has some useful color charts, I'd not found
those before.)

In any case you're right that the contrib.yo doc should be updated,
but none of your other changes would be correct.

> What I don't know is if C code behind things

C code is behind everything, unless you've loaded the "colors"
function and made explicit reference to its variables.


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

* Re: [PATCH] Update man pages to match change to Functions/Misc/colors
  2023-12-14  3:31 ` Bart Schaefer
@ 2023-12-17 14:05   ` Jim
  0 siblings, 0 replies; 3+ messages in thread
From: Jim @ 2023-12-17 14:05 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: devs


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

Still trying to digest.

On Wed, Dec 13, 2023 at 9:31 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:

> On Wed, Dec 13, 2023 at 5:27 AM Jim <linux.tech.guy@gmail.com> wrote:
> >
> > The one thing that looks strange about the change is prompt %S and %s,
> previously
> > standout mode, will now mean reverse mode.
>
> The "colors" function should not be conflated with the prompt escapes.
> They have almost nothing to do with one another.  Changes to the
> function do not affect prompts unless you are using the PROMPT_SUBST
> option to interpolate variables defined by "colors".  What's emitted
> by the prompt escapes has not changed as a result of any updates to
> zsh:
>
> I was associating  the two, thanks for clarifying.

>
> The lack of a firm definition of "standout" is why this change was
> made.  Even "italic" remains a bit iffy; from
>  https://en.wikipedia.org/wiki/ANSI_escape_code
>  3  Italic  Not widely supported. Sometimes treated as inverse or blink.
>
> (That wikipedia page also has some useful color charts, I'd not found
> those before.)
>
> Very familiar with this page, but way TLDR all of it. But a great
reference.

In any case you're right that the contrib.yo doc should be updated,
> but none of your other changes would be correct.
>
> I agree. But something I believe is lacking is the absence of usable
predefined
attributes in the color function. bold_color and reset_color are the only
ones
even though the color associative array has many others uncommented.
Would another associative array for the user to use be helpful? Something
along the lines of ${attribute[<attribute name>}}

e.g.  attribute[reverse] attribute[no-reverse]
   attribute[bold] attribute[faint] attribute[normal]
   ...

The attached patch is offered as a possible enhancement. It generates
the ANSI code for all uncommented attributes. Some attributes may not
be implemented in the user's prefered terminal emulator but would for
others. VTE derived terminals support most if not all of those in colors.

If the patch is acceptable, I would try to generate the man page additions
and changes. Not that familiar with yodl and the "zsh definitions", but
would
be willing to take a stab at it.

Regards,

Jim Murphy

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

[-- Attachment #2: colors_func_attribute_enhancement.patch.txt --]
[-- Type: text/plain, Size: 2350 bytes --]

diff --git a/Functions/Misc/colors b/Functions/Misc/colors
index 8a0cec383..d5933c9a9 100644
--- a/Functions/Misc/colors
+++ b/Functions/Misc/colors
@@ -21,7 +21,7 @@ color=(
   07 reverse                27 no-reverse
 # 07 standout               27 no-standout
   08 conceal                28 no-conceal
-# 09 strikethrough        # 29 no-strikethrough
+  09 strikethrough          29 no-strikethrough

 # Font selection:
 # 10 font-default
@@ -51,9 +51,9 @@ color=(
 # 50 no-proportional
 # 51 border-rectangle
 # 52 border-circle
-# 53 overline
+  53 overline
 # 54 no-border
-# 55 no-overline
+  55 no-overline
 # 56 through 59 reserved

 # Ideogram markings:
@@ -84,7 +84,11 @@ color=(
 # Map in both directions; could do this with e.g. ${(k)colors[(i)normal]},
 # but it's clearer to include them all both ways.

-local k
+local k Pattern
+local -a color_names
+print -- "color_names:  $color_names"
+color_names=(${${${(Mk)color:#bg-*}:#*bright*}#*-})   # get all color names
+print -- "color_names:  $color_names"
 for k in ${(k)color}; do color[${color[$k]}]=$k; done

 # Add "fg-" keys for all the text colors, for clarity.
@@ -105,15 +109,29 @@ for k in '' fg- bg-; do
   color[${k}bright-grey]=${color[${k}bright-gray]}
 done

-colour=(${(kv)color})	# A case where ksh namerefs would be useful ...
+colour=(${(kv)color}) # A case where ksh namerefs would be useful ...

 # The following are terminal escape sequences used by colored prompt themes.

-local lc=$'\e[' rc=m	# Standard ANSI terminal escape values
+local lc=$'\e[' rc=m  # Standard ANSI terminal escape values
+
+# Attributes

 typeset -Hg reset_color bold_color
-reset_color="$lc${color[none]}$rc"
-bold_color="$lc${color[bold]}$rc"
+typeset -AHg attribute
+
+reset_color="$lc${color[none]}$rc"    # legacy attributes so existing scripts
+bold_color="$lc${color[bold]}$rc"     # won't fail
+
+# Get list of all attributes, generate ANSI code for each and add to the
+# associative array "attribute".
+Pattern="${(j.|.)color_names}"
+#for k in ${${(ok)color:#(<->|bg-|fg-|bright)*}:#(${(j.|.)~color_names})}; do
+#for k in ${(ok)color:#(<->|bg-|fg-|bright)*}:#($~Pattern)})}; do
+for k in ${(ok)color:#(<->|bg-|fg-|bright|$~Pattern)*}; do
+  attribute[$k]="$lc${color[$k]}$rc"
+done
+attribute[reset]=${attribute[none]}   # add additional name reset(aka none)

 # Foreground


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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13 13:25 [PATCH] Update man pages to match change to Functions/Misc/colors Jim
2023-12-14  3:31 ` Bart Schaefer
2023-12-17 14:05   ` 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).