diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/zle_refresh.c | 51 | ||||
-rw-r--r-- | Src/zsh.h | 2 |
2 files changed, 35 insertions, 18 deletions
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. |