diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index 85e55e0d4..249d75d71 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -660,6 +660,7 @@ static int more_start, /* more text before start of screen? */ lpromptw, rpromptw, /* prompt widths on screen */ lpromptwof, /* left prompt width with real end position */ lprompth, /* lines taken up by the prompt */ + cursorsaved, /* whether prompt start position was saved */ rprompth, /* right prompt height */ vcs, vln, /* video cursor position column & line */ vmaxln, /* video maximum number of lines */ @@ -994,6 +995,7 @@ zrefresh(void) int remetafy; /* flag that zle line is metafied */ zattr txtchange; /* attributes set after prompts */ int rprompt_off = 1; /* Offset of rprompt from right of screen */ + int savecursorneeded = 0; /* prompt start position needs to be saved */ struct rparams rpms; #ifdef MULTIBYTE_SUPPORT int width; /* width of wide character */ @@ -1133,7 +1135,13 @@ zrefresh(void) zsetterm(); #ifdef TIOCGWINSZ if (winchanged) { - moveto(0, 0); + if (cursorsaved) { + tcout(TCRESTRCURSOR); + zputc(&zr_cr); + vln = vcs = 0; + } else { + moveto(0, 0); + } t0 = olnct; /* this is to clear extra lines even when */ winchanged = 0; /* the terminal cannot TCCLEAREOD */ listshown = 0; @@ -1164,7 +1172,16 @@ zrefresh(void) if (termflags & TERM_SHORT) vcs = 0; else if (!clearflag && lpromptbuf[0]) { - zputs(lpromptbuf, shout); + cursorsaved = 0; + if (tccan(TCSAVECURSOR) && tccan(TCRESTRCURSOR)) { + if (!(termflags & TERM_SHORT)) { + savecursorneeded = 1; + } else if (lprompth <= rwinh) { + tcout(TCSAVECURSOR); + cursorsaved = 1; + } + } + zputs(lpromptbuf, shout); if (lpromptwof == winw) zputs("\n", shout); /* works with both hasam and !hasam */ } else { @@ -1737,6 +1754,12 @@ individually */ clearf = 0; oput_rpmpt = put_rpmpt; + if (savecursorneeded && lprompth + nlnct <= rwinh) { + moveto(1 - lprompth, 0); + tcout(TCSAVECURSOR); + cursorsaved = 1; + } + /* move to the new cursor position */ moveto(rpms.nvln, rpms.nvcs);