zsh-workers
 help / color / mirror / code / Atom feed
* Qustions about ZLE widgets.
@ 1997-06-10 13:23 Andrej Borsenkow
  1997-06-10 14:12 ` Zefram
  0 siblings, 1 reply; 3+ messages in thread
From: Andrej Borsenkow @ 1997-06-10 13:23 UTC (permalink / raw)
  To: Zsh workers mailing list

I started to experiment with new ZLE fetaures, and am a little confused. 
The following is supposed to create simple function which just replaces
buffer with duplicated input character, creates widget for it and binds it
to some character string:

dup_characters () {
	local char
	BUFFER="" 
	read -k char
	BUFFER="$BUFFER""$char""$char" 
	CURSOR=$#BUFFER 
}

zle -N dup_characters dup_characters

bindkey \^X\^D dup_characters

The result is slightly strange (for me at least):

case 1:

bor@itsrm1:~%> ^X^D =>
zsh: use 'logout' to logout.

case 2:

bor@itsrm1:~%> a^X^Db =>
bor@itsrm1:~%> abb
If I continue with ^X^D =>
bor@itsrm1:~%> abb <- (unprintable symbol follows, NL)
 <- cursor is here

Case 3:

bor@itsrm1:~%> aaaaa^X^Db =>
bor@itsrm1:~%> abb

I tried with and without zsh -f; the version is the latest 3.1.2-beta.

thanks in advance

-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@sni.de
-------------------------------------------------------------------------



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

* Re: Qustions about ZLE widgets.
  1997-06-10 13:23 Qustions about ZLE widgets Andrej Borsenkow
@ 1997-06-10 14:12 ` Zefram
  1997-06-11  5:41   ` Andrej Borsenkow
  0 siblings, 1 reply; 3+ messages in thread
From: Zefram @ 1997-06-10 14:12 UTC (permalink / raw)
  To: borsenkow.msk; +Cc: zsh-workers

Andrej Borsenkow wrote:
>dup_characters () {
>	local char
>	BUFFER="" 
>	read -k char

I do not recommend using `read' in a widget function.  I expect it will
screw up the tty mode.  When I find the time to implement it, there will
be a proper way to input characters within ZLE.  (It would be nice to
make read safe to call from within ZLE anyway.)

>	BUFFER="$BUFFER""$char""$char" 

"$BUFFER" is guaranteed to be empty at this point, as you cleared
it above.  Is this what you intend?

-zefram


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

* Re: Qustions about ZLE widgets.
  1997-06-10 14:12 ` Zefram
@ 1997-06-11  5:41   ` Andrej Borsenkow
  0 siblings, 0 replies; 3+ messages in thread
From: Andrej Borsenkow @ 1997-06-11  5:41 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-workers

On Tue, 10 Jun 1997, Zefram wrote:

> Andrej Borsenkow wrote:
> >dup_characters () {
> >	local char
> >	BUFFER="" 
> >	read -k char
> 
> I do not recommend using `read' in a widget function.  I expect it will
> screw up the tty mode.  When I find the time to implement it, there will
> be a proper way to input characters within ZLE.  (It would be nice to
> make read safe to call from within ZLE anyway.)
>

Yes, thanks. As long as I don't use read, it works quite well (but note,
man to zle builtuin doesn't place any restrictions on what widget function
can do). What happens, when functions calls some external program which
changes tty mode? May be, ZLE has to restore tty settings (and buffer)
after user defined widget exits? 

> >	BUFFER="$BUFFER""$char""$char" 
> 
> "$BUFFER" is guaranteed to be empty at this point, as you cleared
> it above.  Is this what you intend?
> 

Ohh ... I started with something more elanorate, but as it didn't work, I
cut it down to above example. Sorry, looks silly, I know ... :-(

thanx

-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@sni.de
-------------------------------------------------------------------------



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

end of thread, other threads:[~1997-06-11  5:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-10 13:23 Qustions about ZLE widgets Andrej Borsenkow
1997-06-10 14:12 ` Zefram
1997-06-11  5:41   ` 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).