zsh-workers
 help / color / mirror / code / Atom feed
* Re: PS1 or PS2
@ 1999-06-29 11:16 Sven Wischnowsky
  1999-06-29 11:41 ` Andrej Borsenkow
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Wischnowsky @ 1999-06-29 11:16 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> I already wrote about this: when on PS2 up-line-or-history moves to previous
> history event instead of previous line of current event. It just occured to me,
> that something like
> 
> if we-are-on-PS2
>   zle .push-line-or-edit
> zle .up-line-or-history
> 
> would do quite nicely ... but how can I find out (in user defined widget) that I
> am on PS2? The info is available (push-line-or-edit has it) - is it possible to
> make it available to user widgets as well?

I haven't tried, but [[ -z "$PREBUFFER" ]] should work.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: PS1 or PS2
  1999-06-29 11:16 PS1 or PS2 Sven Wischnowsky
@ 1999-06-29 11:41 ` Andrej Borsenkow
  1999-06-29 13:09   ` Andrej Borsenkow
  0 siblings, 1 reply; 7+ messages in thread
From: Andrej Borsenkow @ 1999-06-29 11:41 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

> > 
> > would do quite nicely ... but how can I find out (in user defined 
> widget) that I
> > am on PS2? The info is available (push-line-or-edit has it) - is it 
> possible to
> > make it available to user widgets as well?
> 
> I haven't tried, but [[ -z "$PREBUFFER" ]] should work.
> 

It almost works ...

bor@itsrm2:~%> _Fn-up-line-or-history () {
function> [[ -n "$PREBUFFER" ]] && zle .push-line-or-edit
function> zle .up-line-or-history
function> }
bor@itsrm2:~%> zle -N up-line-or-history _Fn-up-line-or-history
bor@itsrm2:~%> while true
while> <CursorUp>
beeps and I get
bor@itsrm2:~%> while true
<<< cursor here

That is, zle .up-line-or-history seems to be never executed.

/andrej


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: PS1 or PS2
  1999-06-29 11:41 ` Andrej Borsenkow
@ 1999-06-29 13:09   ` Andrej Borsenkow
  1999-06-29 15:24     ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Andrej Borsenkow @ 1999-06-29 13:09 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> It almost works ...
>
> bor@itsrm2:~%> _Fn-up-line-or-history () {
> function> [[ -n "$PREBUFFER" ]] && zle .push-line-or-edit
> function> zle .up-line-or-history
> function> }

After zle .push-line-or-edit both BUFFER and PREBUFFER are empty. Are they
static values computed on the entry into widget or do they reflect real ZLE
buffers?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PS1 or PS2
  1999-06-29 13:09   ` Andrej Borsenkow
@ 1999-06-29 15:24     ` Bart Schaefer
  1999-07-07 13:34       ` Some help neede :-) " Andrej Borsenkow
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 1999-06-29 15:24 UTC (permalink / raw)
  To: Andrej Borsenkow, Sven Wischnowsky, zsh-workers

On Jun 29,  5:09pm, Andrej Borsenkow wrote:
} Subject: RE: PS1 or PS2
}
} >
} > It almost works ...
} >
} > bor@itsrm2:~%> _Fn-up-line-or-history () {
} > function> [[ -n "$PREBUFFER" ]] && zle .push-line-or-edit
} > function> zle .up-line-or-history
} > function> }
} 
} After zle .push-line-or-edit both BUFFER and PREBUFFER are empty. Are they
} static values computed on the entry into widget or do they reflect real ZLE
} buffers?

I think they reflect real ZLE buffers.  The "problem" is with the way that
push-input/get-line (and consequently push-line-or-edit) are implemented:
They do something similar to

	print -z "$BUFFER"
	BUFFER=""

and then wait for zle_refresh() to come around and yank the buffer back.
So if you're entirely inside a zle widget (or a bindkey -s), you can't do
anything to the pushed input; it simply isn't there anymore until zsh has
a chance to print a prompt again.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Some help neede :-) RE: PS1 or PS2
  1999-06-29 15:24     ` Bart Schaefer
@ 1999-07-07 13:34       ` Andrej Borsenkow
  1999-07-07 15:39         ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Andrej Borsenkow @ 1999-07-07 13:34 UTC (permalink / raw)
  To: Bart Schaefer, Sven Wischnowsky, zsh-workers

>
> I think they reflect real ZLE buffers.  The "problem" is with the way that
> push-input/get-line (and consequently push-line-or-edit) are implemented:
> They do something similar to
>
> 	print -z "$BUFFER"
> 	BUFFER=""
>
> and then wait for zle_refresh() to come around and yank the buffer back.
> So if you're entirely inside a zle widget (or a bindkey -s), you can't do
> anything to the pushed input; it simply isn't there anymore until zsh has
> a chance to print a prompt again.
>

Yes, something like it.  Currently I managed it so far, that it does redisplay a
line ... with a small problem :-(

Looking in pushlineoredit() I found, that it unconditionally set both
``errflag'' (why?) and ``done''. Obviously, this confused Zle (but I do not know
why). I thought, that I could pass parameter that says "do not set them" - and
here you are! now my small widget really redisplays the input:

(($#PREBUFFER)) && {
zle .push-line-or-edit bla-bla-bla
zle .get-line
zle -R
}

with the sad problem, that it still thinks it is on PS2 and won't return to PS1
(even if I press ^L to redisplay the whole). That is, after

bor@itsrm2:~%> {
cursh> ESC-x foo-widget

I get the following display

bor@itsrm2:~%> {
cursh> {
<= cursor here

and after ^L I get

cursh> {
<= cursor here

Unforunately, here I am lost. I tried it with vanilla push-input/get-line with
the same effect. Obviously, all of them just rely on zleread() to do the work
... sigh.

/andrej



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Some help neede :-) RE: PS1 or PS2
  1999-07-07 13:34       ` Some help neede :-) " Andrej Borsenkow
@ 1999-07-07 15:39         ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 1999-07-07 15:39 UTC (permalink / raw)
  To: Andrej Borsenkow, zsh-workers

Hello; back from my vacation now and buried under Sven and Peter's latest
patch fest ...

On Jul 7,  5:34pm, Andrej Borsenkow wrote:
} Subject: Some help neede :-) RE: PS1 or PS2
}
} Looking in pushlineoredit() I found, that it unconditionally set both
} ``errflag'' (why?) and ``done''. Obviously, this confused Zle (but I
} do not know why). I thought, that I could pass parameter that says "do
} not set them" - and here you are! [...]
}
} with the sad problem, that it still thinks it is on PS2 and won't
} return to PS1 (even if I press ^L to redisplay the whole).

Um, yes.  The reason it sets errflag and done is to force it to leave
the PS2 prompt and go back to PS1.  If you don't set both, it doesn't
work.  The only other way to do it would be to add another new global,
set it in pushlineoredit(), and test it at several spots where `errflag'
and `done' are tested.  It wasn't worth messing with that back when I
originally implemented pushlineoredit(), but maybe it is now.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* PS1 or PS2
@ 1999-06-29 10:54 Andrej Borsenkow
  0 siblings, 0 replies; 7+ messages in thread
From: Andrej Borsenkow @ 1999-06-29 10:54 UTC (permalink / raw)
  To: ZSH workers mailing list

I already wrote about this: when on PS2 up-line-or-history moves to previous
history event instead of previous line of current event. It just occured to me,
that something like

if we-are-on-PS2
  zle .push-line-or-edit
zle .up-line-or-history

would do quite nicely ... but how can I find out (in user defined widget) that I
am on PS2? The info is available (push-line-or-edit has it) - is it possible to
make it available to user widgets as well?

/andrej



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1999-07-07 15:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-29 11:16 PS1 or PS2 Sven Wischnowsky
1999-06-29 11:41 ` Andrej Borsenkow
1999-06-29 13:09   ` Andrej Borsenkow
1999-06-29 15:24     ` Bart Schaefer
1999-07-07 13:34       ` Some help neede :-) " Andrej Borsenkow
1999-07-07 15:39         ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
1999-06-29 10:54 Andrej Borsenkow

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).