zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon Richert <marlon.richert@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] complist: Turn off colors before clearing to end of line
Date: Fri, 20 Aug 2021 09:39:47 +0300	[thread overview]
Message-ID: <CAHLkEDt7qxHMfE8U8+JFaR_9=5XkTJ210Pgj6e-jJ3nRe7uqVQ@mail.gmail.com> (raw)
In-Reply-To: <CAHLkEDvzgXRPyv6Fgg8+m96iKz2dd8Rs8jixX1zYkxmS=_wrGQ@mail.gmail.com>

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

On Thu, Aug 19, 2021 at 10:28 PM Marlon Richert
<marlon.richert@gmail.com> wrote:
>
> On Wed, Aug 18, 2021 at 7:07 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
> >
> > On Tue, Aug 17, 2021 at 1:58 AM Marlon Richert <marlon.richert@gmail.com> wrote:
> > >
> > > <Without the patch, when changing selection, highlight continues until
> > > end of line.>
> > > <With the patch, it stops at the end of the match, just like the default.>
> >
> > And the zcoff() is never needed in the compprintfmt() branch?
>
> Hm, good point. How about this patch instead?

Whoops! It looks like I sent the same patch again. Here is now the one
I actually meant to send. Apologies for the confusion.

[-- Attachment #2: 0001-complist-Turn-off-colors-before-clearing-to-end-of-l.txt --]
[-- Type: text/plain, Size: 2915 bytes --]

From ded9c40e54a3efd458cd78d3b0796bac8206f9af Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlonrichert@users.noreply.github.com>
Date: Thu, 19 Aug 2021 17:02:10 +0300
Subject: [PATCH] complist: Turn off colors before clearing to end of line

---
 Src/Zle/complist.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 353cb3562..cccf5d489 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -603,6 +603,16 @@ zcoff(void)
 	zcputs(NULL, COL_NO);
 }
 
+/* Clear to end of line, if possible and necessary. */
+static void
+cleareol()
+{
+    if (mlbeg >= 0 && tccan(TCCLEAREOL)) {
+        if (*last_cap)
+            zcoff();    /* If we used colors, prevent them from bleeding. */
+        tcout(TCCLEAREOL);
+	}
+}
 
 static void
 initiscol(void)
@@ -670,8 +680,7 @@ clprintfmt(char *p, int ml)
 	doiscol(i++);
 	cc++;
 	if (*p == '\n') {
-	    if (mlbeg >= 0 && tccan(TCCLEAREOL))
-		tcout(TCCLEAREOL);
+	    cleareol();
 	    cc = 0;
 	}
 	if (ml == mlend - 1 && (cc % zterm_columns) == zterm_columns - 1)
@@ -693,8 +702,7 @@ clprintfmt(char *p, int ml)
 	    !--mrestlines && (ask = asklistscroll(ml)))
 	    return ask;
     }
-    if (mlbeg >= 0 && tccan(TCCLEAREOL))
-	tcout(TCCLEAREOL);
+    cleareol();
     return 0;
 }
 
@@ -1047,8 +1055,7 @@ compprintnl(int ml)
 {
     int ask;
 
-    if (mlbeg >= 0 && tccan(TCCLEAREOL))
-	tcout(TCCLEAREOL);
+    cleareol();
     putc('\n', shout);
 
     if (mscroll && !--mrestlines && (ask = asklistscroll(ml)))
@@ -1263,8 +1270,8 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
 	    if ((cc >= zterm_columns - 2 || cchar == ZWC('\n')) && stat)
 		dopr = 2;
 	    if (cchar == ZWC('\n')) {
-		if (dopr == 1 && mlbeg >= 0 && tccan(TCCLEAREOL))
-		    tcout(TCCLEAREOL);
+		if (dopr == 1)
+		    cleareol();
 		l += 1 + ((cc - 1) / zterm_columns);
 		cc = 0;
 	    }
@@ -1306,8 +1313,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
     if (dopr) {
         if (!(cc % zterm_columns))
             fputs(" \010", shout);
-        if (mlbeg >= 0 && tccan(TCCLEAREOL))
-            tcout(TCCLEAREOL);
+        cleareol();
     }
     if (stat && n)
 	mfirstl = -1;
@@ -1338,8 +1344,8 @@ compzputs(char const *s, int ml)
 	    c = *s;
 	s++;
 	putc(c, shout);
-	if (c == '\n' && mlbeg >= 0 && tccan(TCCLEAREOL))
-	    tcout(TCCLEAREOL);
+	if (c == '\n')
+	    cleareol();
 	if (mscroll && (++col == zterm_columns || c == '\n')) {
 	    ml++;
 	    if (!--mrestlines && (ask = asklistscroll(ml)))
@@ -1692,8 +1698,7 @@ compprintlist(int showall)
 
 	    lastlistlen = listdat.nlines;
 	} else if ((nl = listdat.nlines + nlnct - 1) < zterm_lines) {
-	    if (mlbeg >= 0 && tccan(TCCLEAREOL))
-		tcout(TCCLEAREOL);
+	    cleareol();
 	    tcmultout(TCUP, TCMULTUP, nl);
 	    showinglist = -1;
 
-- 
2.33.0


  reply	other threads:[~2021-08-20  6:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17  8:57 Marlon Richert
2021-08-18  4:07 ` Bart Schaefer
2021-08-19 19:28   ` Marlon Richert
2021-08-20  6:39     ` Marlon Richert [this message]
2021-08-20 23:42       ` 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='CAHLkEDt7qxHMfE8U8+JFaR_9=5XkTJ210Pgj6e-jJ3nRe7uqVQ@mail.gmail.com' \
    --to=marlon.richert@gmail.com \
    --cc=schaefer@brasslantern.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).