From e87aa8941fd7e13b039bf4d1664c6dc39a09313a Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 8 Jul 2016 22:28:15 +0200 Subject: 38809: fix tracking of colour attributes and restore them when turning bold off --- Src/Zle/zle_refresh.c | 3 +-- Src/prompt.c | 12 ++++++++---- Src/zsh.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'Src') diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index aca676a1c..e78f1e562 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -1143,8 +1143,7 @@ zrefresh(void) tsetcap(TCALLATTRSOFF, 0); tsetcap(TCSTANDOUTEND, 0); tsetcap(TCUNDERLINEEND, 0); - /* cheat on attribute unset */ - txtunset(TXTBOLDFACE|TXTSTANDOUT|TXTUNDERLINE); + txtattrmask = 0; if (trashedzle && !clearflag) reexpandprompt(); diff --git a/Src/prompt.c b/Src/prompt.c index 831c4f948..bb2745358 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -523,8 +523,6 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) break; case 'b': txtchangeset(txtchangep, TXTNOBOLDFACE, TXTBOLDFACE); - txtchangeset(txtchangep, TXTNOSTANDOUT, TXTSTANDOUT); - txtchangeset(txtchangep, TXTNOUNDERLINE, TXTUNDERLINE); txtunset(TXTBOLDFACE); tsetcap(TCALLATTRSOFF, TSC_PROMPT|TSC_DIRTY); break; @@ -542,7 +540,8 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) arg = parsecolorchar(arg, 1); if (arg >= 0 && !(arg & TXTNOFGCOLOUR)) { txtchangeset(txtchangep, arg & TXT_ATTR_FG_ON_MASK, - TXTNOFGCOLOUR); + TXTNOFGCOLOUR | TXT_ATTR_FG_COL_MASK); + txtunset(TXT_ATTR_FG_COL_MASK); txtset(arg & TXT_ATTR_FG_ON_MASK); set_colour_attribute(arg, COL_SEQ_FG, TSC_PROMPT); break; @@ -557,7 +556,8 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) arg = parsecolorchar(arg, 0); if (arg >= 0 && !(arg & TXTNOBGCOLOUR)) { txtchangeset(txtchangep, arg & TXT_ATTR_BG_ON_MASK, - TXTNOBGCOLOUR); + TXTNOBGCOLOUR | TXT_ATTR_BG_COL_MASK); + txtunset(TXT_ATTR_BG_COL_MASK); txtset(arg & TXT_ATTR_BG_ON_MASK); set_colour_attribute(arg, COL_SEQ_BG, TSC_PROMPT); break; @@ -1041,6 +1041,10 @@ tsetcap(int cap, int flags) tsetcap(TCSTANDOUTBEG, flags); if (txtisset(TXTUNDERLINE)) tsetcap(TCUNDERLINEBEG, flags); + if (txtisset(TXTFGCOLOUR)) + set_colour_attribute(txtattrmask, COL_SEQ_FG, TSC_PROMPT); + if (txtisset(TXTBGCOLOUR)) + set_colour_attribute(txtattrmask, COL_SEQ_BG, TSC_PROMPT); } } } diff --git a/Src/zsh.h b/Src/zsh.h index eee31dad1..36fddd000 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -2567,7 +2567,7 @@ struct ttyinfo { #define txtchangeisset(T,X) ((T) & (X)) #define txtchangeget(T,A) (((T) & A ## _MASK) >> A ## _SHIFT) -#define txtchangeset(T, X, Y) ((void)(T && (*T |= (X), *T &= ~(Y)))) +#define txtchangeset(T, X, Y) ((void)(T && (*T &= ~(Y), *T |= (X)))) /* * For outputting sequences to change colour: specify foreground -- cgit 1.4.1