zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: Peter Stephenson <p.stephenson@samsung.com>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: ETA for zsh 5.7? (was: Test release: 5.6.2-test-3)
Date: Mon, 21 Jan 2019 22:56:23 +0100	[thread overview]
Message-ID: <CAKc7PVA2Abs6Nzm+k57=BUU82vivweL+1q8iRU2m5h-o8PAtyA@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3Q3h8GpuAEf3GUxRHXn0cnOTkewocty=2Lb+SNSEPF+gA@mail.gmail.com>

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

On Mon, 21 Jan 2019 at 20:32, Mikael Magnusson <mikachu@gmail.com> 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

[-- Attachment #2: debug.txt --]
[-- Type: text/plain, Size: 2875 bytes --]


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);




  reply	other threads:[~2019-01-21 21:56 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-05  7:08 Test release: 5.6.2-test-3 dana
2019-01-05 17:49 ` Peter Stephenson
2019-01-05 18:42   ` dana
2019-01-05 20:58   ` Martijn Dekker
2019-01-05 21:55     ` Daniel Shahaf
2019-01-06  2:37 ` Axel Beckert
2019-01-06 15:12 ` Jun T.
2019-01-06 16:37   ` dana
2019-01-06 16:43     ` Daniel Shahaf
2019-01-06 16:56       ` dana
2019-01-06 21:34     ` Daniel Tameling
2019-01-07  3:25     ` Jun T
2019-01-07  7:02       ` dana
2019-01-21 12:54 ` ETA for zsh 5.7? (was: Test release: 5.6.2-test-3) Axel Beckert
2019-01-21 14:26   ` Peter Stephenson
2019-01-21 19:14     ` Mikael Magnusson
2019-01-21 19:32       ` Mikael Magnusson
2019-01-21 21:56         ` Sebastian Gniazdowski [this message]
2019-01-22  9:29           ` Peter Stephenson
2019-01-21 19:32       ` Mikael Magnusson
2019-01-21 23:00 ` Bug with traps and exit Martijn Dekker
2019-11-24  5:54   ` Martijn Dekker
2019-11-25 16:42     ` Sebastian Gniazdowski
2019-12-10 19:23     ` Martijn Dekker
2019-12-11  2:40       ` Daniel Shahaf
2019-12-12 10:14       ` Peter Stephenson
2019-12-13 14:26         ` Martijn Dekker
2019-12-13 14:49           ` Peter Stephenson
2019-12-14 11:28             ` Daniel Shahaf
2019-12-15 18:59               ` Peter Stephenson
2019-12-16  5:24                 ` Daniel Shahaf
2019-12-16  6:37                   ` Bart Schaefer
2019-12-17  7:31                     ` Daniel Shahaf
2019-12-17 20:29                       ` Peter Stephenson
2019-12-18  0:31                         ` Daniel Shahaf
2019-12-31  2:03                           ` Daniel Shahaf
2019-12-31 13:46                             ` Daniel Shahaf
2019-12-16 10:09                   ` Peter Stephenson
2019-12-16  5:27     ` The bug from workers/44922 (was: " Daniel Shahaf
2020-01-30 13:49       ` The bug from workers/44922 Martijn Dekker
2020-01-30 14:01     ` Bug with traps and exit Martijn Dekker
2020-01-31  4:29       ` Daniel Shahaf
2022-11-26  3:00       ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKc7PVA2Abs6Nzm+k57=BUU82vivweL+1q8iRU2m5h-o8PAtyA@mail.gmail.com' \
    --to=sgniazdowski@gmail.com \
    --cc=mikachu@gmail.com \
    --cc=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).