Re: reduce number of lines available for completion
Bart Schaefer <[email protected]>
| Newsgroups | gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAH+w=7ZxzFdpfgzpk4gaOmrC2wNtg0pK+1HZJuRF6w3R7pd=9w@mail.gmail.com> |
On Sun, Feb 2, 2025 at 10:27 AM Tomasz Pala <[email protected]> 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.