zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: OG Code Poet <ogcodepoet@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
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	[thread overview]
Message-ID: <CAH+w=7adRQa1NJSw+73n6gVFO=x4YxjfwZ2E7brhoPVoomJyrw@mail.gmail.com> (raw)
In-Reply-To: <CADmFDtVoEiSsLi4DWC22+yW2LzbFUXpAnWL1_0MrmcPtgh6PYg@mail.gmail.com>

On Fri, Dec 30, 2022 at 7:52 PM OG Code Poet <ogcodepoet@gmail.com> 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.


  reply	other threads:[~2022-12-31  5:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-30  5:37 OG Code Poet
2022-12-30  8:58 ` Mikael Magnusson
2022-12-30 17:56 ` Bart Schaefer
2022-12-31  3:52   ` OG Code Poet
2022-12-31  5:20     ` Bart Schaefer [this message]
2022-12-31  5:44       ` OG Code Poet
2022-12-31 13:13       ` Oliver Kiddle
2023-01-01  0:10         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7adRQa1NJSw+73n6gVFO=x4YxjfwZ2E7brhoPVoomJyrw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=ogcodepoet@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).