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
- X-seq: zsh-workers 51266
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: OG Code Poet <ogcodepoet@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: 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
- Date: Fri, 30 Dec 2022 21:20:48 -0800
- Archived-at: <https://zsh.org/workers/51266>
- In-reply-to: <CADmFDtVoEiSsLi4DWC22+yW2LzbFUXpAnWL1_0MrmcPtgh6PYg@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CADmFDtUiRpYTYh21-aeE_UuSAHqG=c2vcRT0oSND+i9ehu4SOA@mail.gmail.com> <CAH+w=7ZDaLHEP6qa6eV0oSWkJAhj-TbY+sZZM+rUBrkgGoBF-w@mail.gmail.com> <CADmFDtVoEiSsLi4DWC22+yW2LzbFUXpAnWL1_0MrmcPtgh6PYg@mail.gmail.com>
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