Zsh Mailing List Archive
Messages sorted by:
Re: Interactive program in Zsh
- X-seq: zsh-users 7506
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Interactive program in Zsh
- Date: Thu, 10 Jun 2004 08:37:35 -0700 (PDT)
- In-reply-to: <20040609143225.GA10606@DervishD>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Reply-to: Zsh Users <zsh-users@xxxxxxxxxx>
- Sender: schaefer@xxxxxxxxxxxxxxxxxx
On Wed, 9 Jun 2004, DervishD wrote:
> I don't know if this is the proper approach for what I need to
> do: the user is limited to use up arrow and down arrow for travelling
> into the list of options (maybe pg-up and pg-down for scrolling) and
> 'enter' to select the highlighted option. The program must process a
> text, present a list of options containing the text that matched
> certain regex and allow the user to choose one of the options.
I would say the canonical way to do this is using a "select x in ..."
loop -- "select" already being clever enough these days to paginate its
list of choices -- but that doesn't allow the user to scroll up and down
with arrow keys. (I think that's only because the history is disabled,
as it uses the default keymaps.)
Or you could stuff the list of options into the history with "print -s"
and then use "vared -h" to let the user choose one, but then they aren't
actually navigating through the list, just displaying them each in turn.
Maybe that would be good enough, combined with first printing out the
entire list, except then you run into pagination issues. You'll have to
play with key bindings to keep the user from modifying the choices --
that'd be easier in recent zsh that let you redefine the whole keymap.
Also in 4.2.x you might be able to do something with zle-line-init to
start up one of the widgets (previously posted) that invoke menu selection
on the history, which would then be pretty nearly what you asked for.
Messages sorted by: