From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9327 invoked from network); 9 Oct 2007 03:23:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 9 Oct 2007 03:23:38 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 90176 invoked from network); 9 Oct 2007 03:23:31 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 9 Oct 2007 03:23:31 -0000 Received: (qmail 28668 invoked by alias); 9 Oct 2007 03:23:29 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23924 Received: (qmail 28652 invoked from network); 9 Oct 2007 03:23:28 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 9 Oct 2007 03:23:28 -0000 Received: (qmail 89872 invoked from network); 9 Oct 2007 03:23:28 -0000 Received: from g.primenet.com.au (203.24.36.10) by a.mx.sunsite.dk with SMTP; 9 Oct 2007 03:23:22 -0000 Received: (qmail 331 invoked by uid 100); 9 Oct 2007 03:23:18 -0000 Date: Tue, 9 Oct 2007 13:23:18 +1000 From: Geoff Wing To: Zsh Hackers Subject: Re: PROMPT escape sequences Message-ID: <20071009032318.GA10926@primenet.com.au> References: <20071008042759.GA2413@primenet.com.au> <071008084437.ZM25250@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <071008084437.ZM25250@torch.brasslantern.com> Organization: PrimeNet Computer Consultancy User-Agent: Mutt/1.5.16 (2007-06-09) On Tuesday 2007-10-09 01:45 +1000, Bart Schaefer output: :On Oct 8, 2:27pm, Geoff Wing wrote: :} :PS1='very%Blong%bstring%#%S ' :} :The %S effect begins at the %B, not at the point where it should. :} OK, well, it was broken between 4.2.0 and 4.2.1. :} Quick surface check and I'd say it looks like zle_refresh.c:1.13 :That seems unlikely; there's only a two-line diff in there, and the first :of those lines is "if (trashedzle)". :zsh-workers/20149 may have been the culprit, but I don't see anything :else from around July 2004 that meddles with prompts. I don't use anything that needs to reexpand the prompt in-place, so I'm not entirely sure this covers all that is needed. Regards, Geoff --- Src/Zle/zle_main.c.org 2007-10-09 11:56:26.000000000 +1000 +++ Src/Zle/zle_main.c 2007-10-09 13:00:22.000000000 +1000 @@ -1678,8 +1678,10 @@ reexpandprompt(void) if (!reexpanding++) { free(lpromptbuf); lpromptbuf = promptexpand(raw_lp ? *raw_lp : NULL, 1, NULL, NULL); + pmpt_attr = txtchange; free(rpromptbuf); rpromptbuf = promptexpand(raw_rp ? *raw_rp : NULL, 1, NULL, NULL); + rpmpt_attr = txtchange; } reexpanding--; } --- Src/Zle/zle_refresh.c.org 2007-10-09 11:56:26.000000000 +1000 +++ Src/Zle/zle_refresh.c 2007-10-09 13:11:04.000000000 +1000 @@ -413,6 +413,23 @@ snextline(Rparams rpms) rpms->sen = rpms->s + winw; } +/**/ +static void +settextattributes(void) +{ + if (txtchangeisset(TXTNOBOLDFACE)) + tsetcap(TCALLATTRSOFF, 0); + if (txtchangeisset(TXTNOSTANDOUT)) + tsetcap(TCSTANDOUTEND, 0); + if (txtchangeisset(TXTNOUNDERLINE)) + tsetcap(TCUNDERLINEEND, 0); + if (txtchangeisset(TXTBOLDFACE)) + tsetcap(TCBOLDFACEBEG, 0); + if (txtchangeisset(TXTSTANDOUT)) + tsetcap(TCSTANDOUTBEG, 0); + if (txtchangeisset(TXTUNDERLINE)) + tsetcap(TCUNDERLINEBEG, 0); +} /**/ mod_export void @@ -429,11 +446,9 @@ zrefresh(void) int tmpcs, tmpll; /* ditto cursor position and line length */ int tmpalloced; /* flag to free tmpline when finished */ int remetafy; /* flag that zle line is metafied */ + int fixprompt; /* we still need to reexpand the prompt */ struct rparams rpms; - if (trashedzle) - reexpandprompt(); - /* If this is called from listmatches() (indirectly via trashzle()), and * * that was called from the end of zrefresh(), then we don't need to do * * anything. All this `inlist' code is actually unnecessary, but it * @@ -525,6 +540,7 @@ zrefresh(void) listshown = 0; } #endif + fixprompt = trashedzle; resetvideo(); resetneeded = 0; /* unset */ oput_rpmpt = 0; /* no right-prompt currently on screen */ @@ -533,6 +549,8 @@ zrefresh(void) tsetcap(TCALLATTRSOFF, 0); tsetcap(TCSTANDOUTEND, 0); tsetcap(TCUNDERLINEEND, 0); + /* cheat on attribute unset */ + txtunset(TXTBOLDFACE|TXTSTANDOUT|TXTUNDERLINE|TXTDIRTY); if (!clearflag) { if (tccan(TCCLEAREOD)) @@ -544,26 +562,17 @@ zrefresh(void) } if (t0 > -1) olnct = (t0 < winh) ? t0 : winh; + if (fixprompt) + reexpandprompt(); if (termflags & TERM_SHORT) vcs = 0; - else if (!clearflag && lpromptbuf[0]) { + else if (!clearflag && lpromptbuf[0]) { zputs(lpromptbuf, shout); if (lpromptwof == winw) zputs("\n", shout); /* works with both hasam and !hasam */ } else { txtchange = pmpt_attr; - if (txtchangeisset(TXTNOBOLDFACE)) - tsetcap(TCALLATTRSOFF, 0); - if (txtchangeisset(TXTNOSTANDOUT)) - tsetcap(TCSTANDOUTEND, 0); - if (txtchangeisset(TXTNOUNDERLINE)) - tsetcap(TCUNDERLINEEND, 0); - if (txtchangeisset(TXTBOLDFACE)) - tsetcap(TCBOLDFACEBEG, 0); - if (txtchangeisset(TXTSTANDOUT)) - tsetcap(TCSTANDOUTBEG, 0); - if (txtchangeisset(TXTUNDERLINE)) - tsetcap(TCUNDERLINEBEG, 0); + settextattributes(); } if (clearflag) { zputc(ZWC('\r')); @@ -872,20 +881,8 @@ individually */ /* reset character attributes */ if (clearf && postedit) { - if ((txtchange = pmpt_attr ? pmpt_attr : rpmpt_attr)) { - if (txtchangeisset(TXTNOBOLDFACE)) - tsetcap(TCALLATTRSOFF, 0); - if (txtchangeisset(TXTNOSTANDOUT)) - tsetcap(TCSTANDOUTEND, 0); - if (txtchangeisset(TXTNOUNDERLINE)) - tsetcap(TCUNDERLINEEND, 0); - if (txtchangeisset(TXTBOLDFACE)) - tsetcap(TCBOLDFACEBEG, 0); - if (txtchangeisset(TXTSTANDOUT)) - tsetcap(TCSTANDOUTBEG, 0); - if (txtchangeisset(TXTUNDERLINE)) - tsetcap(TCUNDERLINEBEG, 0); - } + if ((txtchange = pmpt_attr ? pmpt_attr : rpmpt_attr)) + settextattributes(); } clearf = 0; oput_rpmpt = put_rpmpt;