From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17523 invoked by alias); 7 Jul 2016 14:55:44 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21740 Received: (qmail 22804 invoked from network); 7 Jul 2016 14:55:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1467902941; bh=hPcL33sHpkdPlLel81wEgEY/1PXwVka7zgoAaWd+peo=; h=cc:In-reply-to:From:References:To:Subject:Date:From:Subject; b=e+w5zxS4HAWbsnMNr5Ey8WuHkaSOybyWCXaEkNuTusofRMkemOtFClp4xBHT5CIa5UcEeiMbI6VhhCanokRJLY1d73U9xRitvWprlg30/EAngYUIjmAsiVkCkAcuiaJgkqt/ZDXmQtSrnfG+LuEhROWu6/3VhsLiXbF3A1xU/TK0zzXtKZTtbohtJwuyqz8BzCikDclE7FB5sOV/fb9Tb3doY8RpbdTt7wooe8uNVZVaDq+p0p7yVVrNY54fyaK/RTTMfUy+SJX9SrYHSFHhIfKSYjgteSNiqChR9AxOtP78ps8sAgWpvE+rEygtT2fgQGiZjj0zaYqZNhGXUKBTyw== X-Yahoo-Newman-Id: 926880.63675.bm@smtp115.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: vfc0weYVM1lilr4db8PC0_eHqzJPsOT0bLI8JL.Z1PSciHM xChbJF10WhshFhy6e9WfQUNa82T61QjDIE2jQF6h2_Bret9eMxnKhpGf_om8 xjaRuOGH0mJbp9Hbux0BHPr8tKub.bZN4RxO3sTxh8iw5NoW1iXVi5qTgnU. _AAndFolGEfTudgmqkWyxfSxpa6KdqSnux4Qc_l7jGmCQODXQP1968nmzsHj u8w1Zn4fcxXp0rtXLEEPzP04clHdlwCWjEjq3BqNUSDIubLZ0Hb.yTOca3Sj OTCKVaWALfCW0aqYWSD3rrmN0ieyDQnHIZC3q5lK.XHoQkDq5TWKDDkC6b9Q syeC8i.kJiA1FhRtidIDpE.z_2UwdU_Iad7Euj1kxBavNVjZj_s1eFQN2Hp1 iAOK5T7KQ4NfwMz5KB4zz_kmEEKrlYjsb8BnLsiTZs0Ty4jCAnyqA.wstGmp wHerXdmiTIkVwJ7O4zFWU3xMufxQpdxNLkdA9peD128aSOXj_hc2OsGI4j2U 7PgQGrMlbh_qcfXyrkhUtEzwOYbs4IIzELLFu6B5ji3o- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- cc: zsh-users@zsh.org In-reply-to: From: Oliver Kiddle References: To: Tristan McLeay Subject: Re: tab completion color inversion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <49129.1467902941.1@hydra.kiddle.eu> Date: Thu, 07 Jul 2016 16:49:01 +0200 Message-ID: <49130.1467902941@hydra.kiddle.eu> 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);