Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: ETA for zsh 5.7? (was: Test release: 5.6.2-test-3)



On Mon, 21 Jan 2019 at 20:32, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:

> With the commit applied,
> % print -P %F{10}hello|cat -v
> ^[[38;5;8;5;10mhello

Following debugs shows that:
1. For color > 7, a termcap-route was being used, ignoring the fg_start_code
2. For color <= 7, the same termap-route was being used ignoring the
fg_start_code.
3. The fg_start_code-route is used only for colors <= 7 in some
other circumstances (I'm occuring this normally for an
region_highlight--&-colors<=7-utilizing code.)

http://sprunge.us/GcRDpx
(also attached as debug.txt)

So basically, Mikachu has following setting:

zle_highlight=( fg_start_code:$'\e[38;5;' )

It's always using termcap for color >= 8,, because of this line ~1983
in prompt.c::

    if (!def && (colour > 7 || use_termcap)) {

But also, the `use_termcap' is apparently always being set if colur > 7.

But the new code, NEVER IGNORES fg_start_code if it's different from
the default «\e[». So the code starts to finally use the fg_start_code
and problems appear. The problems come from the fact that: the are
additional fields needed in zle_highlight, to make it fully usable.
With the new code it IS usable as it is basically USED after all when
set, so e.g. a debugging code (the X04 tests) can use the
zle_highlight mechanism reliably.

> Blindly appending 8;5; to my custom start code seems extremely
> broken and I have no idea under what circumstances it would ever be
> correct to do so. In fact it directly contradicts the documentation:
>
> fg_start_code (\e[3)
>    The  start  of the escape sequence for the foreground colour.  This
> is followed by an ASCII digit representing the colour.
>
> 8;5; is clearly not an ASCII digit.

Ok, but the documentation also misses the fact that in the OLD code,
for col > 7 termcap is used anyway, and also the same for col <= 7, if
the color is invoked in `print -P %F{5}' and possibly other situations
(but not always, region_highlight utilizing the first 8 colors does
use fg_start_code also in the old code).

--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Doing: print -P %F{10}hello | cat -v

The debug logs (code at the bottom):

Yes, using termcap, color:10 / tccolors:256 / use_termcap:268435456
Yes, using termcap, color:10 / tccolors:256 / use_termcap:268435456
NOT, using termcap, 7 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
NOT, using termcap, 0 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
Yes, using termcap, 63 / 256 / 268435456
NOT, using termcap, 0 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
NOT, using termcap, 7 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
NOT, using termcap, 0 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
Yes, using termcap, 63 / 256 / 268435456
NOT, using termcap, 0 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]


Doing: print -P %F{5}hello | cat -v

Yes, using termcap, 5 / 256 / 268435456
Yes, using termcap, 5 / 256 / 268435456
NOT, using termcap, 7 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
NOT, using termcap, 0 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
Yes, using termcap, 63 / 256 / 268435456
NOT, using termcap, 0 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
NOT, using termcap, 7 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
NOT, using termcap, 0 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]
Yes, using termcap, 63 / 256 / 268435456
NOT, using termcap, 0 / 256 / 0
Appended [^[[38;5;] to the colseq_buf[^[[38;5;]




diff --git a/Src/prompt.c b/Src/prompt.c
index 959ed8e3d..1941b8ec9 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1987,6 +1987,14 @@ set_colour_attribute(int atr, int fg_bg, int flags)
 	 */
 	if (tccan(tc) && (tccolours < 0 || colour < tccolours))
 	{
+            
+            FILE *f = fopen("/tmp/reply", "a+");
+            if ( f ) {
+                fprintf(f, "Yes, using termcap, color:%d / tccolours:%d / use_termcap:%d\n", colour, tccolours, use_termcap);
+                fflush(f);
+                fclose(f);
+            }
+
 	    if (is_prompt)
 	    {
 		if (!bv->dontcount) {
@@ -2010,6 +2018,13 @@ set_colour_attribute(int atr, int fg_bg, int flags)
 	 */
 	if (colour > 7)
 	    return;
+    } else {
+        FILE *f = fopen("/tmp/reply", "a+");
+        if ( f ) {
+            fprintf(f, "NOT, using termcap, %d / %d / %d\n", colour, tccolours, use_termcap);
+            fflush(f);
+            fclose(f);
+        }
     }
 
     if ((do_free = (colseq_buf == NULL))) {
@@ -2019,6 +2034,11 @@ set_colour_attribute(int atr, int fg_bg, int flags)
 
     strcpy(colseq_buf, fg_bg_sequences[fg_bg].start);
 
+    FILE *f = fopen("/tmp/reply", "a+");
+    fprintf(f, "Appended [%s] to the colseq_buf[%s]\n", fg_bg_sequences[fg_bg].start, colseq_buf);
+    fflush(f);
+    fclose(f);
+
     ptr = colseq_buf + strlen(colseq_buf);
     if (def) {
 	strcpy(ptr, fg_bg_sequences[fg_bg].def);





Messages sorted by: Reverse Date, Date, Thread, Author