zsh-users
 help / color / mirror / code / Atom feed
* tab completion color inversion
@ 2016-07-05  1:27 Tristan McLeay
  2016-07-07 14:49 ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: Tristan McLeay @ 2016-07-05  1:27 UTC (permalink / raw)
  To: zsh-users

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

For a while now, my zsh has become configured (without my doing) such that
if I use tab to autocomplete, the inserted text is inverted in color. This
is fine; I don't mind it and I can see why someone might like it. But then
any text that I type after that is also inverted, and when I press Enter to
run the command, the output of the command is also inverted. This is really
unpleasant.

Can I fix that, so that either nothing is inverted, or only the
automatically entered text is inverted.

~ % zsh --version
zsh 5.2 (x86_64-debian-linux-gnu)

-- 

Tristan

Application developer
IVT
tristan.mcleay@ivt.com.au <your.email@ivt.com.au> | Ph: +61 3 9723 9399 |
 Fax: +61 3 9723 4899 | Web: www.ivt.com.au
<http://www.ivt.com.au/>
<http://www.ivt.com.au/ivt/news/rss> <http://www.ivt.com.au/usergroup>
<https://twitter.com/IVTWeb>
<http://www.linkedin.com/company/internet-vision-technologies>
<https://www.facebook.com/IVTWeb>
[image: Association Online] <http://www.associationonline.com.au/> [image:
Nonprofit Online] <http://www.nonprofitonline.com.au/>

-- 
This message and its attachments are for the designated recipient only and 
may contain privileged, proprietary, or otherwise private information and 
is intended for the addressee only. If you have received it in error, 
please notify the sender immediately and delete the original. Any other use 
of the email by you is prohibited.

© Copyright 2016. Concepts, ideas and material in this email or its 
attachments remain the property of Internet Vision Technologies.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: tab completion color inversion
  2016-07-05  1:27 tab completion color inversion Tristan McLeay
@ 2016-07-07 14:49 ` Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2016-07-07 14:49 UTC (permalink / raw)
  To: Tristan McLeay; +Cc: zsh-users

On 5 Jul, Tristan McLeay wrote:
> For a while now, my zsh has become configured (without my doing) such that
> if I use tab to autocomplete, the inserted text is inverted in color. This
> is fine; I don't mind it and I can see why someone might like it. But then
> any text that I type after that is also inverted, and when I press Enter to
> run the command, the output of the command is also inverted. This is really
> unpleasant.
>
> Can I fix that, so that either nothing is inverted, or only the
> automatically entered text is inverted.

This really depends on what your prompt contains: does it contain colour
settings, does it use %F/%f or literal escape sequences. Try putting %f
in at the end. You might also put a colour reset sequence in POSTEDIT
though this doesn't support prompt escapes. If that fails set
zle_highlight to your choice of colour:
  zle_highlight=( default:fg=black )
There are other values besides default so perhaps read the
documentation on zle_highlight if doing this.

Also, the following patch may help. This is a bug fix but may not be
related.

For the benefit of -workers, in trying to track this, I noted that
prompt expansion collates final attributes into the pmpt_attr variable.
I'm supposing that whatever is left after PS1 but not RPS1 is what
should be used for zle text in the absence of default in zle_highlight?
But the value of this was clearly not right. To see, try the following
and then try some completion. With a bit of fiddling, you'll get a
yellow background.
  zsh -f
  PROMPT='%K{green}:%K{red} '

red is 1, green 2 and yellow 3. It is ORing the colours.

The patch below resets the saved colour first but I'd actually be
inclined to change the following macro to do the AND before the OR.

#define txtchangeset(T, X, Y)diff((void)(T && (*T |= (X), *T &= ~(Y))))

It might also then be logical to swap the X and Y arguments. Most uses
are just something like:
    txtchangeset(txtchangep, TXTSTANDOUT, TXTNOSTANDOUT);

Oliver

diff --git a/Src/prompt.c b/Src/prompt.c
index 831c4f9..ce3aa17 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -541,6 +541,7 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
 	    case 'F':
 		arg = parsecolorchar(arg, 1);
 		if (arg >= 0 && !(arg & TXTNOFGCOLOUR)) {
+		    *txtchangep &= ~TXT_ATTR_FG_COL_MASK;
 		    txtchangeset(txtchangep, arg & TXT_ATTR_FG_ON_MASK,
 				 TXTNOFGCOLOUR);
 		    txtset(arg & TXT_ATTR_FG_ON_MASK);
@@ -556,6 +557,7 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
 	    case 'K':
 		arg = parsecolorchar(arg, 0);
 		if (arg >= 0 && !(arg & TXTNOBGCOLOUR)) {
+		    *txtchangep &= ~TXT_ATTR_BG_COL_MASK;
 		    txtchangeset(txtchangep, arg & TXT_ATTR_BG_ON_MASK,
 				 TXTNOBGCOLOUR);
 		    txtset(arg & TXT_ATTR_BG_ON_MASK);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-07 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05  1:27 tab completion color inversion Tristan McLeay
2016-07-07 14:49 ` Oliver Kiddle

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