From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27689 invoked from network); 10 Jun 2004 17:23:24 -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 17:23:24 -0000 Received: (qmail 11249 invoked from network); 10 Jun 2004 17:21:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Jun 2004 17:21:36 -0000 Received: (qmail 1914 invoked by alias); 10 Jun 2004 17:21:06 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7510 Received: (qmail 1855 invoked from network); 10 Jun 2004 17:21:05 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 10 Jun 2004 17:21:02 -0000 Received: (qmail 9269 invoked from network); 10 Jun 2004 17:21:02 -0000 Received: from madrid10.amenworld.com (62.193.203.32) by a.mx.sunsite.dk with SMTP; 10 Jun 2004 17:21:00 -0000 Received: from DervishD.pleyades.net (212.Red-80-35-44.pooles.rima-tde.net [80.35.44.212]) by madrid10.amenworld.com (8.10.2/8.10.2) with ESMTP id i5AHKwr29157 for ; Thu, 10 Jun 2004 19:20:58 +0200 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1BYTFA-0000CE-00>; Thu, 10 Jun 2004 19:21:36 +0200 Date: Thu, 10 Jun 2004 19:21:36 +0200 From: DervishD To: Zsh Users Subject: Re: Interactive program in Zsh Message-ID: <20040610172136.GC674@DervishD> Mail-Followup-To: Zsh Users References: <20040609143225.GA10606@DervishD> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.1i Organization: Pleyades 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 Hi Bart :) * Bart Schaefer dixit: > > 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.) And doesn't let me implement the navigation... I mean, I can use 'select', no problem, and that will do since it will present me the list of choices, but I would like to do the navigation too, and selects doesn't allow me to do that, since it reads from the keyboard and does it's own output formatting (not configurable AFAIK). > 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. Nice, but very complex if I need to modify the whole keymap. For me would be easy to do the 'print -s', but instead of the list I will print into the history the command to run the chosen option followed by each option. Something like: command option1 command option2 ... Don't know, very... ugly. > 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. That would be nice, too, but limited to zsh 4.2.x No problem for me, but I would like to have this running at least in 4.0.x too. Anyway, I think I will use the 'select' way (I will rarely need more than 20-30 options, and 'select' fills the lines beautifully) or maybe I will try my first solution, using the key codes or bindkey to get the mappings. The problem with that last solution is the speed: slow and weird screen refreshing, etc. In addition to this, 'read -k', when used with keys that generates multiple characters (an escape sequence, for example), will read each character separately, so I must assemble the individual chars and process the result. Very complex... BTW, what I want to do is something like urlview, but with multiple regexes each handled by a different handler. Currently it can be done (but in a very ugly way) using a very BIG regex and using url_handler.sh to do the discrimination, or maybe with multiple configuration files, etc. Or even rewriting it (which I certainly won't do!). But the point is that I would like to do with zsh just for the sake of it, because I want, for learning O:) Thanks a lot for your help :) I'll try the 'select' way, for now. Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/