Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: tab completion color inversion
- X-seq: zsh-workers 38809
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: tab completion color inversion
- Date: Fri, 08 Jul 2016 01:21:21 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1467933682; bh=mx0PqJjc4E2S8I7FiAyf9ZfuFI7dIVlNb1SwzJMvyso=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=h5IV06nJ2OgYG3p65QnCzU9fIp5UqPpWjTG6BY3iF2rf+ig2jf5GBLZ11Hg45J+Qvdz7aZKwbvjReZsOfZGCISBLrMqYbqoHGJSRyRpXypTmwdKkCaqg3wr3ctSZDiGrvL/65SpooPQlvbj+MUZO7dJElLkYl/6OQsFYkg0ZeOeLbQcQDT2IcVIz7lRxVrdMpqeEXXsIAJdFP8AZmP7MLP5Zeol0zK8gcy9o7q50ApOmJPayC01eCdlqNUnN/Q1w3dbfQ3hB65dzGWzHes8E7VIyEx55AEcGOAWO03X96yUrPkzQNETEL2RwHiqX4ynnkC9Q9u01Wi+Q0F38f7i3pg==
- In-reply-to: <160707100125.ZM23567@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CACW6SB6sRKdtsbFe_ikp1zqP3YRd9grq-xABMGutu4fRvCqM2A@mail.gmail.com> <49130.1467902941@hydra.kiddle.eu> <160707100125.ZM23567@torch.brasslantern.com>
Bart wrote:
> Reactions:
>
> (1) Is this related to "End boldface also ends background color" thread
> from back in March?
Somewhat related. You can get the same, completion altering attributes
effect, with PROMPT='%S%U%Bhello%b '
I see that was never addressed. The code clearly originally had handling
to reset attributes. The TSC_DIRTY flag is included for escape sequences
that apparently reset other attributes. That includes standout off,
underline end, bold on and bold off. If standout end is dirty, you
have to wonder about the bold off sequence that lacks a termcap entry
(\e[22m). Any terminal I have access has no such issues.
The following patch addresses this by restoring colours in addition to
other attributes when TSC_DIRTY is set. There's still an issue after
completion where a final space character isn't redrawn in standout.
And completion is still sometimes wiping attributes and returning to
defaults.
> (2) As I said in that thread, I don't really follow the semantics of
> the txtchangep pointer, but AND before OR seems sensible in the macro.
txtchangep and txtattrmask seem to be doing much the same thing -
tracking the current attributes. The need for tracking attributes that
have been turned off such as TXTNOBOLDFACE seems a bit odd - wouldn't
the absence of TXTBOLDFACE do the job?
> (3) Swapping the arguments would touch a lot of code and make it hard
> to compare revisions, so the benefits ought to be carefully weighed.
I've not done that then but I did put the AND before the OR.
Oliver
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index aca676a..e78f1e5 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1143,8 +1143,7 @@ zrefresh(void)
tsetcap(TCALLATTRSOFF, 0);
tsetcap(TCSTANDOUTEND, 0);
tsetcap(TCUNDERLINEEND, 0);
- /* cheat on attribute unset */
- txtunset(TXTBOLDFACE|TXTSTANDOUT|TXTUNDERLINE);
+ txtattrmask = 0;
if (trashedzle && !clearflag)
reexpandprompt();
diff --git a/Src/prompt.c b/Src/prompt.c
index 831c4f9..bb27453 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -523,8 +523,6 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
break;
case 'b':
txtchangeset(txtchangep, TXTNOBOLDFACE, TXTBOLDFACE);
- txtchangeset(txtchangep, TXTNOSTANDOUT, TXTSTANDOUT);
- txtchangeset(txtchangep, TXTNOUNDERLINE, TXTUNDERLINE);
txtunset(TXTBOLDFACE);
tsetcap(TCALLATTRSOFF, TSC_PROMPT|TSC_DIRTY);
break;
@@ -542,7 +540,8 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
arg = parsecolorchar(arg, 1);
if (arg >= 0 && !(arg & TXTNOFGCOLOUR)) {
txtchangeset(txtchangep, arg & TXT_ATTR_FG_ON_MASK,
- TXTNOFGCOLOUR);
+ TXTNOFGCOLOUR | TXT_ATTR_FG_COL_MASK);
+ txtunset(TXT_ATTR_FG_COL_MASK);
txtset(arg & TXT_ATTR_FG_ON_MASK);
set_colour_attribute(arg, COL_SEQ_FG, TSC_PROMPT);
break;
@@ -557,7 +556,8 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
arg = parsecolorchar(arg, 0);
if (arg >= 0 && !(arg & TXTNOBGCOLOUR)) {
txtchangeset(txtchangep, arg & TXT_ATTR_BG_ON_MASK,
- TXTNOBGCOLOUR);
+ TXTNOBGCOLOUR | TXT_ATTR_BG_COL_MASK);
+ txtunset(TXT_ATTR_BG_COL_MASK);
txtset(arg & TXT_ATTR_BG_ON_MASK);
set_colour_attribute(arg, COL_SEQ_BG, TSC_PROMPT);
break;
@@ -1041,6 +1041,10 @@ tsetcap(int cap, int flags)
tsetcap(TCSTANDOUTBEG, flags);
if (txtisset(TXTUNDERLINE))
tsetcap(TCUNDERLINEBEG, flags);
+ if (txtisset(TXTFGCOLOUR))
+ set_colour_attribute(txtattrmask, COL_SEQ_FG, TSC_PROMPT);
+ if (txtisset(TXTBGCOLOUR))
+ set_colour_attribute(txtattrmask, COL_SEQ_BG, TSC_PROMPT);
}
}
}
diff --git a/Src/zsh.h b/Src/zsh.h
index eee31da..36fddd0 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2567,7 +2567,7 @@ struct ttyinfo {
#define txtchangeisset(T,X) ((T) & (X))
#define txtchangeget(T,A) (((T) & A ## _MASK) >> A ## _SHIFT)
-#define txtchangeset(T, X, Y) ((void)(T && (*T |= (X), *T &= ~(Y))))
+#define txtchangeset(T, X, Y) ((void)(T && (*T &= ~(Y), *T |= (X))))
/*
* For outputting sequences to change colour: specify foreground
Messages sorted by:
Reverse Date,
Date,
Thread,
Author