From 88126c01103f8dc591e1a4ab15392fddef0b62d0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 6 May 2008 09:23:06 +0000 Subject: 24932: try to fix up code that regularizes attributes after right prompt --- ChangeLog | 3 +++ Src/Zle/zle_refresh.c | 51 +++++++++++++++++++++++++++++++++------------------ Src/zsh.h | 2 ++ 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb76c220a..e8195dc90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-05-06 Peter Stephenson + * 24932: Src/zsh.h, Src/Zle/zle_refresh.c: try to regularize + code that fixes up after right prompt. + * 24927: Phil Pennock: configure.ac: Free BSD only doesn't need _XOPEN_SOURCE_EXTENDED on Free BSD 6. diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index 6be6ca467..d4137f0d2 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -1869,29 +1869,44 @@ zrefresh(void) /* output the right-prompt if appropriate */ if (put_rpmpt && !iln && !oput_rpmpt) { + int attrchange; + moveto(0, winw - 1 - rpromptw); zputs(rpromptbuf, shout); vcs = winw - 1; /* reset character attributes to that set by the main prompt */ txtchange = pmpt_attr; - if (txtchangeisset(txtchange, TXTNOBOLDFACE) && - (rpmpt_attr & TXTBOLDFACE)) - tsetcap(TCALLATTRSOFF, 0); - if (txtchangeisset(txtchange, TXTNOSTANDOUT) && - (rpmpt_attr & TXTSTANDOUT)) - tsetcap(TCSTANDOUTEND, 0); - if (txtchangeisset(txtchange, TXTNOUNDERLINE) && - (rpmpt_attr & TXTUNDERLINE)) - tsetcap(TCUNDERLINEEND, 0); - if (txtchangeisset(txtchange, TXTBOLDFACE) && - (rpmpt_attr & TXTNOBOLDFACE)) - tsetcap(TCBOLDFACEBEG, 0); - if (txtchangeisset(txtchange, TXTSTANDOUT) && - (rpmpt_attr & TXTNOSTANDOUT)) - tsetcap(TCSTANDOUTBEG, 0); - if (txtchangeisset(txtchange, TXTUNDERLINE) && - (rpmpt_attr & TXTNOUNDERLINE)) - tsetcap(TCUNDERLINEBEG, 0); + /* + * Keep attributes that have actually changed, + * which are ones off in rpmpt_attr and on in + * pmpt_attr, and vice versa. + */ + attrchange = txtchange & + (TXT_ATTR_OFF_FROM_ON(rpmpt_attr) | + TXT_ATTR_ON_FROM_OFF(rpmpt_attr)); + /* + * Careful in case the colour changed. + */ + if (txtchangeisset(txtchange, TXTFGCOLOUR) && + (!txtchangeisset(rpmpt_attr, TXTFGCOLOUR) || + ((txtchange ^ rpmpt_attr) & TXT_ATTR_FG_COL_MASK))) + { + attrchange |= + txtchange & (TXTFGCOLOUR | TXT_ATTR_FG_COL_MASK); + } + if (txtchangeisset(txtchange, TXTBGCOLOUR) && + (!txtchangeisset(rpmpt_attr, TXTBGCOLOUR) || + ((txtchange ^ rpmpt_attr) & TXT_ATTR_BG_COL_MASK))) + { + attrchange |= + txtchange & (TXTBGCOLOUR | TXT_ATTR_BG_COL_MASK); + } + /* + * Now feed these changes into the usual function, + * if necessary. + */ + if (attrchange) + settextattributes(attrchange); } } diff --git a/Src/zsh.h b/Src/zsh.h index d83bdd2bb..f3ccd636b 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1983,6 +1983,8 @@ struct ttyinfo { #define TXT_ATTR_OFF_ON_SHIFT 6 #define TXT_ATTR_OFF_FROM_ON(attr) \ (((attr) & TXT_ATTR_ON_MASK) << TXT_ATTR_OFF_ON_SHIFT) +#define TXT_ATTR_ON_FROM_OFF(attr) \ + (((attr) & TXT_ATTR_OFF_MASK) >> TXT_ATTR_OFF_ON_SHIFT) /* * Indicates to zle_refresh.c that the character entry is an * index into the list of multiword symbols. -- cgit 1.4.1