zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@zsh.org>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: Zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: support for italic and faint fonts from region_highlight
Date: Wed, 08 Feb 2023 23:52:21 +0100	[thread overview]
Message-ID: <6545-1675896741.640027@NF2k.rdHi.8Dac> (raw)
In-Reply-To: <CAHYJk3R+ZxTSXVebyV7SZ3T41OriFpoNEHbUMe=QZRxXXLu2kA@mail.gmail.com>

On 20 Jan, Mikael Magnusson wrote:
> Tha patch seems to fix my blue problems (but X04 is unhappy). Thanks!

This requires a change to the zpty_line() function which is one of the
functions handling the tests. With the earlier patch, it now clears the
attributes after the first \r. So stripping [[:space:]]## from the end
of REPLY was leaving the \r\e[0m in $REPLY.

Bart wrote:
> In a shell running in an emacs buffer, I get ...

Given that for TERM=dumb it is quite valid for %s and %u to be empty,
the test can't rely on that so I've removed the two -n conditions in the
test. This does slightly limit the scope of what is being tested: I took
care that ${(%):-%s} does give you the disable standout sequence despite
not having turned it on before.

The patch also does some handling for leaving attributes on at the end
of zstyle ':completion:*:descriptions' format
That was possible before but with behaviour that can only be described
as a mess. Turning them off explicitly solves problems.

Sorry for having been slow to address these things.

Oliver

diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 8bdf1bb29..9cb89a60d 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1305,6 +1305,8 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 	}
     }
     if (dopr) {
+	treplaceattrs(0);
+	applytextattributes(0);
         if (!(cc % zterm_columns))
             fputs(" \010", shout);
         cleareol();
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index f94bfce3c..07fac7144 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2560,6 +2560,8 @@ printfmt(char *fmt, int n, int dopr, int doesc)
 	}
     }
     if (dopr) {
+	treplaceattrs(0);
+	applytextattributes(0);
         if (!(cc % zterm_columns))
             fputs(" \010", shout);
 	if (tccan(TCCLEAREOL))
diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index a0abb7e1d..55861cca1 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -261,7 +261,7 @@
   A1=${(%):-%s}
   A2=${(%):-%u}
   A3=${(%):-%s%u%s}
-  [[ $A3 = $A1$A2 && -n $A1 && -n $A2 ]]
+  [[ $A3 = $A1$A2 ]]
 0:Attribute optimisation - preserve initial disabling of attribute but drop useless later one
 
   : ${(%):-%K{blue}}
diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst
index 296635bf5..87a59fde5 100644
--- a/Test/X04zlehighlight.ztst
+++ b/Test/X04zlehighlight.ztst
@@ -40,7 +40,7 @@
         # Fix e^Mexit - match ((?)\r(?)), if \2 == \3, then replace with \2
         # otherwise replace with \1 stripped out of leading/trailing [[:space:]]
         REPLY=${REPLY//(#b)((?(#c0,1))$cm(?(#c0,1)))/${${${(M)match[2]:#${match[3]}}:+${match[2]}}:-${${match[1]##[[:space:]]##}%%[[:space:]]##}}}
-        [[ -n "$REPLY" ]] && print -r -- ${${REPLY%%[[:space:]]##}##[[:space:]]##}
+        [[ -n "$REPLY" ]] && print -r -- ${${REPLY%%${~cm}*}##[[:space:]]##}
       done
     }
     zpty_stop() {


      reply	other threads:[~2023-02-08 22:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  0:59 Oliver Kiddle
2023-01-06 22:03 ` Oliver Kiddle
2023-01-19 16:22   ` Mikael Magnusson
2023-01-19 21:18     ` Oliver Kiddle
2023-01-20  0:22       ` Mikael Magnusson
2023-02-08 22:52         ` Oliver Kiddle [this message]

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=6545-1675896741.640027@NF2k.rdHi.8Dac \
    --to=opk@zsh.org \
    --cc=mikachu@gmail.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).