From 29a869d5a8bc0efb5245310d2f12a418bbf64f19 Mon Sep 17 00:00:00 2001 From: Geoff Wing Date: Fri, 19 Oct 2007 01:33:09 +0000 Subject: 23924: Improve synchronising of character attributes with other output routines --- Src/Zle/zle_main.c | 2 ++ Src/Zle/zle_refresh.c | 57 ++++++++++++++++++++++++--------------------------- 2 files changed, 29 insertions(+), 30 deletions(-) (limited to 'Src') diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 463ff157f..a45e63617 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -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--; } diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index a936a1399..2dfafb932 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -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; -- cgit 1.4.1