* Jumping to the line above @ 2004-07-01 11:23 Fabiano Sidler 2004-07-01 11:32 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: Fabiano Sidler @ 2004-07-01 11:23 UTC (permalink / raw) To: zsh-users Hello list! I want to implement an "inline cd-keybinding", that means: [Some previous output] ~/bin/foo/bar $ After typing (for example) ^U twice: [Some previous output] ~/bin $ For that I need a command or widget, that deletes the prompt on the next line and moves the cursor back to the line preceeded. However, I haven't found anything like that. Is there another possibility? Thanks! Fips ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Jumping to the line above 2004-07-01 11:23 Jumping to the line above Fabiano Sidler @ 2004-07-01 11:32 ` Peter Stephenson 2004-07-01 12:14 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2004-07-01 11:32 UTC (permalink / raw) To: zsh-users Fabiano Sidler wrote: > I want to implement an "inline cd-keybinding", that means: > > [Some previous output] > ~/bin/foo/bar $ > > After typing (for example) ^U twice: > > [Some previous output] > ~/bin $ > > For that I need a command or widget, that deletes the prompt on the next > line and moves the cursor back to the line preceeded. > However, I haven't found anything like that. Is there another possibility? I think what you *really* want is a way of re-expanding the current prompt. Then everything could be done in a zle widget without any strange display tricks. At the moment the code assumes the prompt won't change during editing, so that would need a bit of an internal rewrite. However, I think it's a useful goal. -- Peter Stephenson <pws@csr.com> Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Jumping to the line above 2004-07-01 11:32 ` Peter Stephenson @ 2004-07-01 12:14 ` Peter Stephenson 2004-07-01 12:30 ` Oliver Kiddle 2004-07-01 19:55 ` Jumping to the line above Fabiano Sidler 0 siblings, 2 replies; 7+ messages in thread From: Peter Stephenson @ 2004-07-01 12:14 UTC (permalink / raw) To: Zsh users list Peter Stephenson wrote: > > [Some previous output] > > ~/bin/foo/bar $ > > > > After typing (for example) ^U twice: > > > > [Some previous output] > > ~/bin $ > > I think what you *really* want is a way of re-expanding the current > prompt. This may be oversimple (in particular, I have no idea what to do about pmpt_attr and rpmpt_attr) ... Further followups on that should go to zsh-workers. After the patch, you can do stuff like PS1="%~%# " zle-pushd() { emulate -L zsh setopt pushdsilent # Use the numeric argument to get a new directory. # Make sure we get an argument in the +/- from expected by pushd. local numeric=${NUMERIC:-+1} [[ $numeric = [-+]* ]] || numeric="+$numeric" pushd $numeric zle reset-prompt } zle -N zle-pushd bindkey '^x^p' zle-pushd Index: Doc/Zsh/zle.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v retrieving revision 1.35 diff -u -r1.35 zle.yo --- Doc/Zsh/zle.yo 22 Jun 2004 07:02:50 -0000 1.35 +++ Doc/Zsh/zle.yo 1 Jul 2004 12:03:19 -0000 @@ -1737,6 +1737,15 @@ item(tt(redisplay) (unbound) (^R) (^R))( Redisplays the edit buffer. ) +tindex(reset-prompt) +item(tt(reset-prompt) (unbound) (unbound) (unbound))( +Force the prompts on both the left and right of the screen to be +re-expanded, then redisplay the edit buffer. Note that this +does not reflect changes to the prompt variables themselves, only changes +in the expansion of the values (for example, changes in time or +directory, or changes to the value of variables referred to by the +prompt). +) tindex(send-break) item(tt(send-break) (^G ESC-^G) (unbound) (unbound))( Abort the current editor function, e.g. tt(execute-named-command), or the Index: Src/Zle/iwidgets.list =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/iwidgets.list,v retrieving revision 1.5 diff -u -r1.5 iwidgets.list --- Src/Zle/iwidgets.list 20 Feb 2004 15:27:53 -0000 1.5 +++ Src/Zle/iwidgets.list 1 Jul 2004 12:03:19 -0000 @@ -88,6 +88,7 @@ "recursive-edit", recursiveedit, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "redisplay", redisplay, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "redo", redo, ZLE_KEEPSUFFIX +"reset-prompt", resetprompt, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "reverse-menu-complete", reversemenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_ISCOMP "run-help", processcmd, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "self-insert", selfinsert, ZLE_MENUCMP | ZLE_KEEPSUFFIX Index: Src/Zle/zle_main.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v retrieving revision 1.45 diff -u -r1.45 zle_main.c --- Src/Zle/zle_main.c 2 Jun 2004 22:15:01 -0000 1.45 +++ Src/Zle/zle_main.c 1 Jul 2004 12:03:20 -0000 @@ -150,6 +150,8 @@ /**/ mod_export char *zlenoargs[1] = { NULL }; +static char *raw_lp, *raw_rp; + #ifdef FIONREAD static int delayzsetterm; #endif @@ -785,8 +787,10 @@ insmode = unset(OVERSTRIKE); eofsent = 0; resetneeded = 0; + raw_lp = lp; lpromptbuf = promptexpand(lp, 1, NULL, NULL); pmpt_attr = txtchange; + raw_rp = rp; rpromptbuf = promptexpand(rp, 1, NULL, NULL); rpmpt_attr = txtchange; free_prepostdisplay(); @@ -1307,6 +1311,18 @@ } /**/ +int +resetprompt(UNUSED(char **args)) +{ + free(lpromptbuf); + lpromptbuf = promptexpand(raw_lp, 1, NULL, NULL); + free(rpromptbuf); + rpromptbuf = promptexpand(raw_rp, 1, NULL, NULL); + + return redisplay(NULL); +} + +/**/ mod_export void trashzle(void) { -- Peter Stephenson <pws@csr.com> Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Jumping to the line above 2004-07-01 12:14 ` Peter Stephenson @ 2004-07-01 12:30 ` Oliver Kiddle 2004-07-01 16:44 ` PATCH: re-expand the prompt automatically Wayne Davison 2004-07-01 19:55 ` Jumping to the line above Fabiano Sidler 1 sibling, 1 reply; 7+ messages in thread From: Oliver Kiddle @ 2004-07-01 12:30 UTC (permalink / raw) To: Zsh users list Peter wrote: > > I think what you *really* want is a way of re-expanding the current > > prompt. > > This may be oversimple (in particular, I have no idea what to do about Is there any chance this could be automatically called before the prompt is reprinted when a background job finishes? That would allow %j prompt expansions to be right. Oliver ^ permalink raw reply [flat|nested] 7+ messages in thread
* PATCH: re-expand the prompt automatically 2004-07-01 12:30 ` Oliver Kiddle @ 2004-07-01 16:44 ` Wayne Davison 0 siblings, 0 replies; 7+ messages in thread From: Wayne Davison @ 2004-07-01 16:44 UTC (permalink / raw) To: Oliver Kiddle; +Cc: Zsh users list [-- Attachment #1: Type: text/plain, Size: 538 bytes --] On Thu, Jul 01, 2004 at 02:30:20PM +0200, Oliver Kiddle wrote: > Is there any chance this could be automatically called before the > prompt is reprinted when a background job finishes? That would allow %j > prompt expansions to be right. I had this same thought. Here's a patch that makes the re-expanding part of the new function get called from zrefresh(). If that turns out to be too pervasive, we could mod_export the new reexpandprompt() function and call it from various other places in the code, such as from jobs.c. ..wayne.. [-- Attachment #2: prompting.patch --] [-- Type: text/plain, Size: 1039 bytes --] --- Src/Zle/zle_main.c 1 Jul 2004 14:55:58 -0000 1.46 +++ Src/Zle/zle_main.c 1 Jul 2004 16:42:30 -0000 @@ -1311,14 +1311,20 @@ recursiveedit(UNUSED(char **args)) } /**/ -int -resetprompt(UNUSED(char **args)) +void +reexpandprompt(void) { free(lpromptbuf); lpromptbuf = promptexpand(raw_lp, 1, NULL, NULL); free(rpromptbuf); rpromptbuf = promptexpand(raw_rp, 1, NULL, NULL); +} +/**/ +int +resetprompt(UNUSED(char **args)) +{ + reexpandprompt(); return redisplay(NULL); } --- Src/Zle/zle_refresh.c 2 Jun 2004 22:15:02 -0000 1.12 +++ Src/Zle/zle_refresh.c 1 Jul 2004 16:42:30 -0000 @@ -291,7 +291,8 @@ zrefresh(void) unsigned char *tmpline; /* line with added pre/post text */ int tmpcs, tmpll; /* ditto cursor position and line length */ int tmpalloced; /* flag to free tmpline when finished */ - + + reexpandprompt(); /* If this is called from listmatches() (indirectly via trashzle()), and * * that was called from the end of zrefresh(), then we don't need to do * ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Jumping to the line above 2004-07-01 12:14 ` Peter Stephenson 2004-07-01 12:30 ` Oliver Kiddle @ 2004-07-01 19:55 ` Fabiano Sidler 2004-07-01 23:45 ` Bart Schaefer 1 sibling, 1 reply; 7+ messages in thread From: Fabiano Sidler @ 2004-07-01 19:55 UTC (permalink / raw) To: zsh-users Peter Stephenson wrote: > [a widget and a patch] Whoah, thanks! But don't break your legs for me! ;) The problem with your solution: It's not portable, but I'm going to use the zsh on other boxes, even where I'm not root on. Hence, there must be a solution entirely written in zsh scripts, not in C. The following does not work, as you said: ~ $ updir() { echo -n $'\r '; cd .. ; zle redisplay } ~ $ zle -N updir ~ $ bindkey '^U' updir ~ $ [^U^U] I must press Return to get the desired prompt: / $ I wouldn't believe it, if there were not a solution. But where? ;) Thanks for reply! Greetings, Fips ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Jumping to the line above 2004-07-01 19:55 ` Jumping to the line above Fabiano Sidler @ 2004-07-01 23:45 ` Bart Schaefer 0 siblings, 0 replies; 7+ messages in thread From: Bart Schaefer @ 2004-07-01 23:45 UTC (permalink / raw) To: zsh-users On Thu, 1 Jul 2004, Fabiano Sidler wrote: > I wouldn't believe it, if there were not a solution. But where? ;) updir() { print -z "$PREBUFFER$BUFFER" BUFFER='' zle redisplay cd .. zle send-break } Problems: It beeps at you. It's crude about handling the input at the PS2 prompt. It doesn't maintain cursor position if you aren't at the end of the input. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-07-01 23:46 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2004-07-01 11:23 Jumping to the line above Fabiano Sidler 2004-07-01 11:32 ` Peter Stephenson 2004-07-01 12:14 ` Peter Stephenson 2004-07-01 12:30 ` Oliver Kiddle 2004-07-01 16:44 ` PATCH: re-expand the prompt automatically Wayne Davison 2004-07-01 19:55 ` Jumping to the line above Fabiano Sidler 2004-07-01 23:45 ` 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).