* custom widget / redraw prompt
@ 2003-03-24 12:57 Simon Dassow
2003-03-24 16:36 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Simon Dassow @ 2003-03-24 12:57 UTC (permalink / raw)
To: zsh-workers
Hi all,
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.
What i currently have in my .zshrc is:
switch-rprompt() {
if [[ -z $RPROMPT ]]; then
export RPROMPT=$MYRPROMPT
else
export RPROMPT=""
fi
zle -R
}
zle -N switch-rprompt
bindkey ^P switch-rprompt
but that doesnt works like it should.
Maybe some of you knows whats wrong there, i've already searched the
manpages, but i must be blind or so.
Regards,
Simon
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: custom widget / redraw prompt
2003-03-24 12:57 custom widget / redraw prompt Simon Dassow
@ 2003-03-24 16:36 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2003-03-24 16:36 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-24 16:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-24 12:57 custom widget / redraw prompt Simon Dassow
2003-03-24 16:36 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).