From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12892 invoked from network); 24 Mar 2003 16:36:45 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 24 Mar 2003 16:36:45 -0000 Received: (qmail 4851 invoked by alias); 24 Mar 2003 16:36:38 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18379 Received: (qmail 4844 invoked from network); 24 Mar 2003 16:36:38 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 24 Mar 2003 16:36:38 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.64.233.231] by sunsite.dk (MessageWall 1.0.8) with SMTP; 24 Mar 2003 16:36:37 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h2OGaaa14906 for zsh-workers@sunsite.dk; Mon, 24 Mar 2003 08:36:36 -0800 From: "Bart Schaefer" Message-Id: <1030324163635.ZM14905@candle.brasslantern.com> Date: Mon, 24 Mar 2003 16:36:35 +0000 In-Reply-To: <20030324125730.GA23684@nexus> Comments: In reply to Simon Dassow "custom widget / redraw prompt" (Mar 24, 1:57pm) References: <20030324125730.GA23684@nexus> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: Re: custom widget / redraw prompt MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 24, 1:57pm, Simon Dassow wrote: } } i'm currently on a custom widget, which will dis/enable the RPROMPT on } keypress (^P), so i can copy the commandline without the RPROMPT. You can't do this in the obvious way. The prompts (both left and right) are computed just after the `precmd' function runs, and then subsequent ZLE refreshes only repaint them; so changes to PROMPT, RPROMPT, et al., during widget execution have no effect. Here are some possible alternatives; the first one both changes and covers up the RPROMPT, the second one merely moves the command onto a line by itself and leaves the prompts alone. switch-rprompt() { if [[ -z "$RPROMPT" ]]; then setopt localoptions extendedglob export RPROMPT="$MYRPROMPT" RBUFFER="${RBUFFER%% #}" else export RPROMPT="" RBUFFER="$RBUFFER${(l:COLUMNS:: :):-}" fi } switch-rprompt() { setopt localoptions noksharrays if [[ "$BUFFER" == $'\\\n'* ]]; then ((CURSOR -= 2)) BUFFER="$BUFFER[3,-1]" else LBUFFER=$'\\\n'"$LBUFFER" fi } -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net