diff options
Diffstat (limited to 'Src/Zle')
| -rw-r--r-- | Src/Zle/complist.c | 2 | ||||
| -rw-r--r-- | Src/Zle/zle.h | 4 | ||||
| -rw-r--r-- | Src/Zle/zle_main.c | 4 | ||||
| -rw-r--r-- | Src/Zle/zle_refresh.c | 44 | ||||
| -rw-r--r-- | Src/Zle/zle_tricky.c | 2 |
5 files changed, 34 insertions, 22 deletions
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index ea18434a3..4c87c15d7 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -1183,7 +1183,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) break; case ZWC('H'): if (*p == '{') { - p = parsehighlight(p + 1, '}', &atr); + p = parsehighlight(p + 1, '}', &atr, NULL); if (atr != TXT_ERROR && dopr) treplaceattrs(atr); } diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h index 91eefc9e5..bf479d4cc 100644 --- a/Src/Zle/zle.h +++ b/Src/Zle/zle.h @@ -433,8 +433,10 @@ enum { * and mark. */ struct region_highlight { - /* Attributes turned on in the region */ + /* Attributes for the region */ zattr atr; + /* Explicitly set attributes for the region */ + zattr atrmask; /* Priority for this region relative to others that overlap */ int layer; /* Start of the region */ diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index d7b2ca21c..46d0e07d2 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1277,7 +1277,7 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish) raw_rp = rp; rpromptbuf = promptexpand(rp ? *rp : NULL, 1, markers[2], NULL, NULL); rpmpt_attr = txtcurrentattrs; - prompt_attr = mixattrs(pmpt_attr, rpmpt_attr); + prompt_attr = mixattrs(pmpt_attr, pmpt_attr, rpmpt_attr); free_prepostdisplay(); zlereadflags = flags; @@ -2032,7 +2032,7 @@ reexpandprompt(void) new_rprompt = promptexpand(raw_rp ? *raw_rp : NULL, 1, markers[2], NULL, NULL); rpmpt_attr = txtcurrentattrs; - prompt_attr = mixattrs(pmpt_attr, rpmpt_attr); + prompt_attr = mixattrs(pmpt_attr, pmpt_attr, rpmpt_attr); free(rpromptbuf); rpromptbuf = new_rprompt; } while (looping != reexpanding); diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index 943eda672..8a89be333 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -208,7 +208,7 @@ int predisplaylen, postdisplaylen; * and for ellipsis continuation markers. */ -static zattr default_attr, special_attr, ellipsis_attr; +static zattr default_attr, special_attr, special_mask, ellipsis_attr; /* * Layer applied to highlighting for special characters @@ -359,28 +359,33 @@ zle_set_highlight(void) paste_attr_set = region_attr_set = isearch_attr_set = suffix_attr_set = 1; } else if (strpfx("default:", *atrs)) { - match_highlight(*atrs + 8, &default_attr, NULL); + match_highlight(*atrs + 8, &default_attr, NULL, NULL); } else if (strpfx("special:", *atrs)) { - match_highlight(*atrs + 8, &special_attr, &special_layer); + match_highlight(*atrs + 8, &special_attr, &special_mask, + &special_layer); special_attr_set = 1; } else if (strpfx("region:", *atrs)) { match_highlight(*atrs + 7, &(region_highlights[0].atr), + &(region_highlights[0].atrmask), &(region_highlights[0].layer)); region_attr_set = 1; } else if (strpfx("isearch:", *atrs)) { match_highlight(*atrs + 8, &(region_highlights[1].atr), + &(region_highlights[1].atrmask), &(region_highlights[1].layer)); isearch_attr_set = 1; } else if (strpfx("suffix:", *atrs)) { match_highlight(*atrs + 7, &(region_highlights[2].atr), + &(region_highlights[2].atrmask), &(region_highlights[2].layer)); suffix_attr_set = 1; } else if (strpfx("paste:", *atrs)) { match_highlight(*atrs + 6, &(region_highlights[3].atr), + &(region_highlights[3].atrmask), &(region_highlights[3].layer)); paste_attr_set = 1; } else if (strpfx("ellipsis:", *atrs)) { - match_highlight(*atrs + 9, &ellipsis_attr, NULL); + match_highlight(*atrs + 9, &ellipsis_attr, NULL, NULL); ellipsis_attr_set = 1; } } @@ -388,15 +393,15 @@ zle_set_highlight(void) /* Default attributes */ if (!special_attr_set) - special_attr = TXTSTANDOUT; + special_attr = special_mask = TXTSTANDOUT; if (!region_attr_set) - region_highlights[0].atr = TXTSTANDOUT; + region_highlights[0].atr = region_highlights[0].atrmask = TXTSTANDOUT; if (!isearch_attr_set) - region_highlights[1].atr = TXTUNDERLINE; + region_highlights[1].atr = region_highlights[1].atrmask = TXTUNDERLINE; if (!suffix_attr_set) - region_highlights[2].atr = TXTBOLDFACE; + region_highlights[2].atr = region_highlights[2].atrmask = TXTBOLDFACE; if (!paste_attr_set) - region_highlights[3].atr = TXTSTANDOUT; + region_highlights[3].atr = region_highlights[3].atrmask = TXTSTANDOUT; if (!ellipsis_attr_set) ellipsis_attr = TXTBGCOLOUR | ((zattr) 3 << TXT_ATTR_BG_COL_SHIFT) | TXTFGCOLOUR | ((zattr) 4 << TXT_ATTR_FG_COL_SHIFT); @@ -442,7 +447,7 @@ get_region_highlight(UNUSED(Param pm)) int offset; const char memo_equals[] = " memo="; int alloclen = sprintf(digbuf, "%d %d", rhp->start, rhp->end) + - output_highlight(rhp->atr, NULL) + + output_highlight(rhp->atr, rhp->atrmask, NULL) + 2; /* space and terminating NUL */ if (rhp->flags & ZRH_PREDISPLAY) alloclen++; /* "P" */ @@ -461,7 +466,7 @@ get_region_highlight(UNUSED(Param pm)) offset = sprintf(*arrp, "%s%s ", (rhp->flags & ZRH_PREDISPLAY) ? "P" : "", digbuf); - (void)output_highlight(rhp->atr, *arrp + offset); + (void)output_highlight(rhp->atr, rhp->atrmask, *arrp + offset); if (rhp->layer != 10) strcat(*arrp, layerbuf); @@ -537,7 +542,8 @@ set_region_highlight(UNUSED(Param pm), char **aval) strp++; rhp->layer = 10; /* default */ - strp = (char*) match_highlight(strp, &rhp->atr, &rhp->layer); + strp = (char*) match_highlight(strp, &rhp->atr, &rhp->atrmask, + &rhp->layer); while (inblank(*strp)) strp++; @@ -1155,6 +1161,9 @@ zrefresh(void) zputs("\n", shout); /* works with both hasam and !hasam */ /* lpromptbuf includes literal escapes so we need to update for it */ txtcurrentattrs = txtpendingattrs = pmpt_attr; + /* Unknown attributes remain so but if sequences were embedded + * directly in the prompt, let's not needlessly reset them. */ + txtunknownattrs = 0; } if (clearflag) { zputc(&zr_cr); @@ -1197,7 +1206,7 @@ zrefresh(void) rpms.s = nbuf[rpms.ln = 0] + lpromptw; rpms.sen = *nbuf + winw; for (t = tmpline, tmppos = 0; tmppos < tmpll; t++, tmppos++) { - zattr base_attr = mixattrs(default_attr, prompt_attr); + zattr base_attr = mixattrs(default_attr, default_attr, prompt_attr); zattr all_attr = 0; struct region_highlight *rhp; int layer, nextlayer = 0; @@ -1219,9 +1228,10 @@ zrefresh(void) offset = predisplaylen; /* increment over it */ if (rhp->start + offset <= tmppos && tmppos < rhp->end + offset) { - base_attr = mixattrs(rhp->atr, base_attr); + base_attr = mixattrs(rhp->atr, rhp->atrmask, base_attr); if (layer > special_layer) - all_attr = mixattrs(rhp->atr, all_attr); + all_attr = mixattrs(rhp->atr, rhp->atrmask, + all_attr); } } else if (rhp->layer > layer && (rhp->layer < nextlayer || nextlayer <= layer)) { @@ -1229,7 +1239,7 @@ zrefresh(void) } } if (special_layer == layer) { - all_attr = mixattrs(special_attr, base_attr); + all_attr = mixattrs(special_attr, special_mask, base_attr); } } while (nextlayer > layer); @@ -2467,7 +2477,7 @@ singlerefresh(ZLE_STRING_T tmpline, int tmpll, int tmpcs) } } } - all_attr = mixattrs(special_attr, base_attr); + all_attr = mixattrs(special_attr, special_mask, base_attr); if (t0 == tmpcs) nvcs = vp - vbuf; diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index aa3c71bc2..f399ebd00 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -2503,7 +2503,7 @@ printfmt(char *fmt, int n, int dopr, int doesc) break; case 'H': if (p[1] == '{') { - p = parsehighlight(p + 2, '}', &atr); + p = parsehighlight(p + 2, '}', &atr, NULL); --p; if (atr != TXT_ERROR) treplaceattrs(atr); |
