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

[-- Attachment #1: Type: text/plain, Size: 1558 bytes --]

I had tried tput cup $LINES $((COLUMNS-1)) and tput cup $LINES $COLUMNS.
Vared seems to clear the entire line of cursor, not just from
cursor position to the end of line. Not sure if this has something to do
with xterm-256color and tmux-256color, unlike the description of tput el
"clear to end of line". On all the terminals I have tested this on, they
clear from beginning of current line to the end. My machine is: Apple
Silicon macOS 13.1. Did that really work on your machine?

On Fri, Dec 30, 2022 at 9:20 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:

> 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.
>

[-- Attachment #2: Type: text/html, Size: 2065 bytes --]

  reply	other threads:[~2022-12-31  5:44 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
2022-12-31  5:44       ` OG Code Poet [this message]
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=CADmFDtVFWPukBxegRx-qiG2VeGY1g564K0jkWQY2zHYW3f_qaw@mail.gmail.com \
    --to=ogcodepoet@gmail.com \
    --cc=schaefer@brasslantern.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).