From: Geoff Wing <gcw@zsh.org>
To: Zsh Hackers <zsh-workers@sunsite.dk>
Subject: Re: PROMPT escape sequences
Date: Tue, 9 Oct 2007 13:23:18 +1000 [thread overview]
Message-ID: <20071009032318.GA10926@primenet.com.au> (raw)
In-Reply-To: <071008084437.ZM25250@torch.brasslantern.com>
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;
next prev parent reply other threads:[~2007-10-09 3:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20071008034223.GA789@primenet.com.au>
[not found] ` <071007210217.ZM24374@torch.brasslantern.com>
[not found] ` <20071008042759.GA2413@primenet.com.au>
2007-10-08 15:44 ` Bart Schaefer
2007-10-09 3:23 ` Geoff Wing [this message]
1996-10-01 17:11 Prompt " Louis Granboulan
1996-10-02 23:18 ` Zoltan Hidvegi
1996-10-03 6:09 ` Richard Coleman
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=20071009032318.GA10926@primenet.com.au \
--to=gcw@zsh.org \
--cc=zsh-workers@sunsite.dk \
/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).