From cc28002e5411af5c33a6d91c5edcf1860cc2dcf6 Mon Sep 17 00:00:00 2001 From: Geoff Wing Date: Wed, 24 Oct 2001 07:00:49 +0000 Subject: 16063: add transientrprompt option to remove right prompt from display when accepting commands --- Doc/Zsh/options.yo | 5 +++++ Src/Zle/zle_main.c | 1 + Src/Zle/zle_refresh.c | 39 +++++++++++++++++++++++++++++++-------- Src/options.c | 1 + Src/zsh.h | 1 + 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index 72de9e8d3..d880ebb4a 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -1153,6 +1153,11 @@ of backquotes on the line, ignore the trailing backquote. This is useful on some keyboards where the return key is too small, and the backquote key lies annoyingly close to it. ) +pindex(TRANSIENT_RPROMPT) +item(tt(TRANSIENT_RPROMPT))( +Remove any right prompt from display when accepting a command +line. This may be useful with terminals with other cut/paste methods. +) pindex(UNSET) cindex(parameters, substituting unset) cindex(unset parameters, substituting) diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index cec6c1b4e..42c7a6bb3 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1057,6 +1057,7 @@ trashzle(void) * extra `inlist' check]). */ int sl = showinglist; showinglist = 0; + trashedzle = 1; zrefresh(); showinglist = sl; moveto(nlnct, 0); diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index c432907d1..7b4178ee8 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -76,6 +76,11 @@ mod_export int clearflag; /**/ mod_export int clearlist; +/* Zle in trashed state - updates may be subtly altered */ + +/**/ +int trashedzle; + #ifdef HAVE_SELECT /* cost of last update */ /**/ @@ -167,6 +172,7 @@ resetvideo(void) olnct = nlnct = 0; if (showinglist > 0) showinglist = -2; + trashedzle = 0; } /* @@ -357,6 +363,20 @@ zrefresh(void) 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); } if (clearflag) { zputc('\r', shout); @@ -504,11 +524,14 @@ zrefresh(void) zfree(nbuf[ln], winw + 2), nbuf[ln] = NULL; /* determine whether the right-prompt exists and can fit on the screen */ - if (!more_start) - put_rpmpt = rprompth == 1 && rpromptbuf[0] && - !strchr(rpromptbuf, '\t') && - (int)strlen(nbuf[0]) + rpromptw < winw - 1; - else { + if (!more_start) { + if (trashedzle && opts[TRANSIENTRPROMPT]) + put_rpmpt = 0; + else + put_rpmpt = rprompth == 1 && rpromptbuf[0] && + !strchr(rpromptbuf, '\t') && + (int)strlen(nbuf[0]) + rpromptw < winw - 1; + } else { /* insert >.... on first line if there is more text before start of screen */ memset(nbuf[0], ' ', lpromptw); t0 = winw - lpromptw; @@ -518,7 +541,7 @@ zrefresh(void) nbuf[0][winw] = nbuf[0][winw + 1] = '\0'; } - for (ln = 0; !clearf && (ln < nlnct); ln++) { + for (ln = 0; ln < nlnct; ln++) { /* if we have more lines than last time, clear the newly-used lines */ if (ln >= olnct) cleareol = 1; @@ -526,7 +549,7 @@ zrefresh(void) /* if old line and new line are different, see if we can insert/delete a line to speed up update */ - if (ln > 0 && ln < olnct - 1 && !(hasam && vcs == winw) && + if (!clearf && ln > 0 && ln < olnct - 1 && !(hasam && vcs == winw) && nbuf[ln] && obuf[ln] && strncmp(nbuf[ln], obuf[ln], 16)) { if (tccan(TCDELLINE) && obuf[ln + 1] && obuf[ln + 1][0] && @@ -558,6 +581,7 @@ zrefresh(void) /* output the right-prompt if appropriate */ if (put_rpmpt && !ln && !oput_rpmpt) { + oput_rpmpt = put_rpmpt; moveto(0, winw - 1 - rpromptw); zputs(rpromptbuf, shout); vcs = winw - 1; @@ -616,7 +640,6 @@ individually */ /* store current values so we can use them next time */ ovln = nvln; olnct = nlnct; - oput_rpmpt = put_rpmpt; onumscrolls = numscrolls; if (nlnct > vmaxln) vmaxln = nlnct; diff --git a/Src/options.c b/Src/options.c index cd45b31e9..fe0b8da30 100644 --- a/Src/options.c +++ b/Src/options.c @@ -199,6 +199,7 @@ static struct optname optns[] = { {NULL, "singlecommand", OPT_SPECIAL, SINGLECOMMAND}, {NULL, "singlelinezle", OPT_KSH, SINGLELINEZLE}, {NULL, "sunkeyboardhack", 0, SUNKEYBOARDHACK}, +{NULL, "transientrprompt", 0, TRANSIENTRPROMPT}, {NULL, "unset", OPT_EMULATE|OPT_BSHELL, UNSET}, {NULL, "verbose", 0, VERBOSE}, {NULL, "xtrace", 0, XTRACE}, diff --git a/Src/zsh.h b/Src/zsh.h index 74d0753bb..5e18c0ade 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1439,6 +1439,7 @@ enum { SINGLECOMMAND, SINGLELINEZLE, SUNKEYBOARDHACK, + TRANSIENTRPROMPT, UNSET, VERBOSE, XTRACE, -- cgit 1.4.1