Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Read a line from user without clearing screen below the prompt while allowing user to use arrow keys to make edits in middle of line



On Fri, Dec 30, 2022 at 7:52 PM OG Code Poet <ogcodepoet@xxxxxxxxx> wrote:
>
> Here's some more context.

So ... vared sends the clear-to-end-of-screen before printing the
prompt, then starts ZLE and clears again after ZLE exits.  This means
your job, in creating a workaround, is to move the cursor to the lower
right corner of the screen before calling vared, move it to the
desired position before printing the prompt, and move back to the
lower right again before ending ZLE.

This translates approximately to:

to-lower-right() { tput cup $LINES $((COLUMNS-1)) }
zle -N to-lower-right
tput sc
to-lower-right
vared -f to-lower-right -p "%{$(tput cup 0 0)%}Enter something: " ...
tput rc

Other tricks may be needed to keep a newline from being output when
pressing ENTER to accept the edit.

If this is unsatisfactory, you could try using zcurses to manage the
display, which I think would allow you to always redraw whatever vared
erased.




Messages sorted by: Reverse Date, Date, Thread, Author