From: John Hawkinson <jhawk@alum.mit.edu>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@zsh.org
Subject: Re: Why does zsh clear to end-of-screen after prompt?
Date: Fri, 25 Aug 2023 20:59:20 -0400 [thread overview]
Message-ID: <ZOlOaISfwY6RFrfH@louder-room.local> (raw)
In-Reply-To: <CAH+w=7ZQaJgvk=wLX5mVEC4XR3AP1kxZU+t6O88PZFAZ6p6w9Q@mail.gmail.com>
Bart Schaefer <schaefer@brasslantern.com> wrote on Fri, 25 Aug 2023
at 20:18:01 EDT in <CAH+w=7ZQaJgvk=wLX5mVEC4XR3AP1kxZU+t6O88PZFAZ6p6w9Q@mail.gmail.com>:
> This happens because ZLE is a mult-line editor and also because
> completion uses the space under the editor area to display lists etc.
> If the screen were not cleared, text being edited could mingle with
> the screen contents already present.
Ugh. I suppose it would be too much to ask that it not do this in the (for me) 90+% case where neither completion nor multi-line editing have been used?
Or only to clear as many lines as have been used, rather than to end-of-screen?
Or a knob to just not clear it and let the user deal with the fallout?
I was optimistic that
setopt SINGLE_LINE_ZLE
would solve this, but it does not.
Oddly
setopt noZLE
does so, but it's a worse user experience than TERM=dumb.
At least with TERM=dumb I get up/down arrow, even if the editing is not quite right and overlaps the prompt in weird ways.
> > How can I get cursor positining to work without forgoing, e.g., line editing?
>
> You can try something like this:
>
> PS1=$'%{\e[H%}'$PS1$'%{\e[K%}'
Bah. I mean, yeah, that works, but it feels fairly not-great.
In case it wasn't apparent, the use case is I had a small ad hoc script that produced ~20 lines of key/value output and sometimes the values change and I'd like to keep them in the same position on the screen and just overwrite themselves when they change if I rerun the script with up-arrow/RET.
I guess another way is this:
OPS1="$PS1" # save it for idempotency later
PS1=$'%{\e[40H%}'$OPS1
echo '\e[H'; seq 1 20
which, for an 80x48 window, gives 8 lines for editing and commands that don't do any positioning, and leaves the top 40 lines for stuff that's prefixed by CSI H homing to the top-left. Maybe this is an acceptable balance, I dunno.
> There are also games to be played with save_cursor and restore_cursor,
> e.g., a command that wants to control the screen appearance could move
> to a position, save_cursor, and then move to the end of the screen, if
> the prompt were then programmed to start with a restore_cursor -- but
> you still have to be careful about that "start in the leftmost column"
> and deal with avoiding the restore if the last command didn't save.
Yeah, this feels even more...antithetical to the simplicity I was desiring.
Honestly it feels like just using bash for this particular one-off is the easiest way out :(
It seems to me, also, that the documentation could use some improvement on this point, but perhaps it is so obscure that it is going to be hard to find a good place to insert a straightforward discussion of this concern. If this thread doesn't reach any better resolution I'll do some thinking about ways to improve that.
Thanks, Bart.
--
jhawk@alum.mit.edu
John Hawkinson
next prev parent reply other threads:[~2023-08-26 1:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-25 19:52 John Hawkinson
2023-08-26 0:18 ` Bart Schaefer
2023-08-26 0:59 ` John Hawkinson [this message]
2023-08-26 1:39 ` Bart Schaefer
2023-08-27 8:34 ` Roman Perepelitsa
2023-08-27 15:36 ` Grant Taylor
2023-08-27 16:02 ` Roman Perepelitsa
2023-08-27 18:55 ` Grant Taylor
2023-09-09 23:23 ` 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=ZOlOaISfwY6RFrfH@louder-room.local \
--to=jhawk@alum.mit.edu \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@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).