From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22884 invoked from network); 10 Jun 2004 15:38:54 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 10 Jun 2004 15:38:54 -0000 Received: (qmail 23656 invoked from network); 10 Jun 2004 15:38:05 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Jun 2004 15:38:05 -0000 Received: (qmail 21251 invoked by alias); 10 Jun 2004 15:37:56 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7506 Received: (qmail 21240 invoked from network); 10 Jun 2004 15:37:56 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 10 Jun 2004 15:37:53 -0000 Received: (qmail 23072 invoked from network); 10 Jun 2004 15:37:52 -0000 Received: from moonbase.zanshin.com (root@64.84.47.139) by a.mx.sunsite.dk with SMTP; 10 Jun 2004 15:37:51 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.12.11/8.12.11) with ESMTP id i5AFbmig024886 for ; Thu, 10 Jun 2004 08:37:48 -0700 Date: Thu, 10 Jun 2004 08:37:35 -0700 (PDT) From: Bart Schaefer Sender: schaefer@toltec.zanshin.com Reply-To: Zsh Users To: Zsh Users Subject: Re: Interactive program in Zsh In-Reply-To: <20040609143225.GA10606@DervishD> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 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.