Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: reduce number of lines available for completion
- X-seq: zsh-users 30192
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Tomasz Pala <gotar@xxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: reduce number of lines available for completion
- Date: Sun, 2 Feb 2025 12:36:06 -0800
- Archived-at: <https://zsh.org/users/30192>
- In-reply-to: <20250202182731.GA10436@polanet.pl>
- List-id: <zsh-users.zsh.org>
- References: <20250202182731.GA10436@polanet.pl>
On Sun, Feb 2, 2025 at 10:27 AM Tomasz Pala <gotar@xxxxxxxxxx> wrote:
>
> I'm struggling with the idea to use only part of the screen for
> completion results (namely menu-select). [...] the idea
> is to reduce $LINES for completion [e.g. LINES=$((LINES/2))] and then
> restore the original value (saved in some temporary variable).
>
> I cannot find the appropriate place for restoration... When I reduce
> LINES in _main_complete, then it's halving with each use.
> Can I attach anything to run _after_ .menu-select is being issued?
You need to create a wrapper widget around the whole operation, something like
function short-menu-complete {
integer LINES=$((LINES/2))
zle menu-complete
zle -I
}
zle -N short-menu-complete
This provides context for the localized value of LINES to be restored
after the completion finishes. Note this is an ordinary widget (not
created with zle -C) that invokes completion inside. The "zle -I"
alerts the editor that completion changed the display during execution
of the wrapper widget.
As written there, you have to invoke short-menu-complete explicitly
(e.g., with its own separate bindkey) but if you don't mind having
LINES=10 in all completion contexts you should be able to create a
function + bindkey that runs whenever you press TAB, you'd just invoke
complete-word or expand-or-complete instead of menu-complete.
However I can't promise that there aren't some edge cases wherein the
cursor will get moved outside the "half display" and garble up other
parts of the screen.
There are some zsh plugins available that use the zcurses module to
let you split the screen into different "windows", one example is
https://github.com/psprint/n-commodore
That's no longer maintained (and I don't use it), but several other
projects by that author have been picked up at
https://github.com/zdharma-continuum, maybe they'd like to adopt
n-commodore as well.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author