zsh-users
 help / color / mirror / code / Atom feed
* bindkey and widgets
@ 2004-03-21 14:31 David Gómez
  2004-03-21 17:01 ` Bart Schaefer
  2004-03-21 18:18 ` DervishD
  0 siblings, 2 replies; 8+ messages in thread
From: David Gómez @ 2004-03-21 14:31 UTC (permalink / raw)
  To: Zsh-users

Hi all ;),

I've been reading zsh users guide and documentation, but cannot find any
responses to these doubts, hope you can help me out ;). Two questions:

It is possible to map the "Ctrl+RePag" combination using bindkey? I just
can bind the "RePag" key alone, but i want to associate combinations
of RePag/AvPag keys to different widgets. Some expressions i've tried are
'^\e[5~' and '\C-\e[5~'. The first one behaves just like '\e[5~'.

On the other hand, how can i map one action with two widgets?. When
the Control-K combination is pressed, i want two widgets to be executed,
namely kill-line and end-of-history. Do i need to create an user defined
widgets to do this, calling zle to execute these widgets, or it can be
done in a simpler way?

Thanks,

-- 
David Gómez

"The question of whether computers can think is just like the question of
 whether submarines can swim." -- Edsger W. Dijkstra


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

* Re: bindkey and widgets
  2004-03-21 14:31 bindkey and widgets David Gómez
@ 2004-03-21 17:01 ` Bart Schaefer
  2004-03-21 21:26   ` David Gómez
  2004-03-21 18:18 ` DervishD
  1 sibling, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2004-03-21 17:01 UTC (permalink / raw)
  To: Zsh-users

On Mar 21,  3:31pm, David ( Text in unknown character set ISO-8859-15  wrote:
} 
} It is possible to map the "Ctrl+RePag" combination using bindkey?

Only if your terminal or emulator sends a different escape sequence for
the RePag key when "modifier" keys like shift/ctrl/meta/alt are pressed.

} '^\e[5~' and '\C-\e[5~'

No.  \e[5~ is the four-character sequence (escape left-bracket five tilde)
that is sent when the unmodified RePag key is pressed.  For function keys
that send multi-character sequences, pressing the control key often has
no effect, but if it has any effect at all it will be to cause another,
different multi-character sequence to be sent.

So you need to find out what that sequence is.  The easiest way may be
to type Ctrl+v (which usually means "quote next character") and then
Ctrl+RePag and see what appears.  If it looks like ^[[5~ (^[ is another
way to write \e), then your keyboard and/or terminal emulator does not
distinguish the ctrl modifier for function keys.  If it looks different,
then that is the sequence you use for bindkey.

It may be possible to program your terminal emulator to recognize ctrl
with function keys, but that's beyond what I'm prepared to explain here.

} On the other hand, how can i map one action with two widgets?. When
} the Control-K combination is pressed, i want two widgets to be executed,
} namely kill-line and end-of-history.

Creating a widget is probably the best way because it doesn't depend on
any other bindings.  However, you can use "bindkey -s".

First, assuming Ctrl+k is presently bound to kill-line, you have to make
a new binding for kill-line.  Escape left-curly-bracket is an unlikely
combination and not usually bound, so:

    bindkey '\e{' kill-line

Then you need a binding for end-of-history, which isn't attached to a key
by default.  I'll choose escape right-curly-bracket for this example:

    bindkey '\e}' end-of-history

Finally, rebind Ctrl+k with:

    bindkey -s '\C-k' '\e{\e}'

The widget, on the other hand, would look like this:

    kill-line-and-end-history () {
      zle .kill-line && zle .end-of-history
    }
    zle -N kill-line kill-line-and-end-history

That actually renames kill-line to your new widget, so all bindings for
kill-line now include jumping to the end of the history.  If you want to
change Ctrl+k only, use:

    zle -N kill-line-and-end-history
    bindkey '\C-k' kill-line-and-end-history


-- 
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] 8+ messages in thread

* Re: bindkey and widgets
  2004-03-21 14:31 bindkey and widgets David Gómez
  2004-03-21 17:01 ` Bart Schaefer
@ 2004-03-21 18:18 ` DervishD
  2004-03-21 21:51   ` David Gómez
  1 sibling, 1 reply; 8+ messages in thread
From: DervishD @ 2004-03-21 18:18 UTC (permalink / raw)
  To: David Gómez; +Cc: Zsh-users

    Hi David :)

 * Davilín <david@pleyades.net> dixit:
> It is possible to map the "Ctrl+RePag" combination using bindkey?

    No. If you want to use 'Ctrl+RePag' combo you must edit your
/etc/keymap and modify the lines that bind that combo to the
scrollback facility under Linux. You should bind them to a string:

string F20 = "\033[98~"
string F21 = "\033[99~"
keycode 104 = PageUp   F20
keycode 109 = PageDown F21

    The above will generate sequences so if you press 'C-PgUp' or
'C-PgDn' you will send '\e[98~' and '\e[99~'. You can bind them under
Zsh using bindkey:

    bindkey -s "^[[25~" " |\$pager\n"

    is what I use to bind that... well, key, at the right of the
infamous WinDOS logo, at the right side of my keyboard (in my
/etc/keymap file I have that key generate '^[[25~').

> On the other hand, how can i map one action with two widgets?

    See Bart's message for that. Is a very good explanation :) IMHO
the easiest one if you don't want to create new widgets is the one I
told you yesterday: bind some strange key combo to each widget and
after that use bindkey to bind your usual 'kill-line' combo to the
string corresponding to the two strange key combos (in Bart's
explanation, they are '\e{' and '\e}')

    Nonetheless, if you plan to make something more complicated in
the future regarding kill-line (e.g. adding more widgets to run after
kill-line, making the killing depending on the contents of the
$BUFFER, etc.) I encourage you to create a new widget. Is pretty
straightforward (if I can do it, anyone can XDD) and very, very
powerful ;)

    Have fun with Zle :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


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

* Re: bindkey and widgets
  2004-03-21 17:01 ` Bart Schaefer
@ 2004-03-21 21:26   ` David Gómez
  0 siblings, 0 replies; 8+ messages in thread
From: David Gómez @ 2004-03-21 21:26 UTC (permalink / raw)
  To: Zsh-users

Hi Bart ;);

> So you need to find out what that sequence is.  The easiest way may be
> to type Ctrl+v (which usually means "quote next character") and then
> Ctrl+RePag and see what appears.  If it looks like ^[[5~ (^[ is another
> way to write \e), then your keyboard and/or terminal emulator does not
> distinguish the ctrl modifier for function keys. 

Yes, it looks the same, whether the Control key is pressed or not, so
it seems my terminal emulator is sending the same sequence in both
cases.

> It may be possible to program your terminal emulator to recognize ctrl
> with function keys, but that's beyond what I'm prepared to explain here.

You explained enough and have been very helpful, thanks ;). I've just seen
another response from Raúl that explains a solution to modify my keymap
to generate a different sequence to ctrl+repag, so i'll try that.

> Creating a widget is probably the best way because it doesn't depend on
> any other bindings.  However, you can use "bindkey -s".

It's a better solution, that's true. But i think that a keybinding like
'\e{' is also a good solution, and i my case i don't have custom keybindings
with the escape sequence, so it's a rather safe solution.

Thanks again ;) 

-- 
David Gómez

"The question of whether computers can think is just like the question of
 whether submarines can swim." -- Edsger W. Dijkstra


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

* Re: bindkey and widgets
  2004-03-21 18:18 ` DervishD
@ 2004-03-21 21:51   ` David Gómez
  2004-03-22 14:52     ` DervishD
  0 siblings, 1 reply; 8+ messages in thread
From: David Gómez @ 2004-03-21 21:51 UTC (permalink / raw)
  To: Zsh-users

Hi Raúl ;),

>     No. If you want to use 'Ctrl+RePag' combo you must edit your
> /etc/keymap and modify the lines that bind that combo to the
> scrollback facility under Linux. You should bind them to a string:

Thanks ;), it works nicely. I should have think at first that i didn't
have that key combination in my keymap... instead of trying to make zsh
to map an unknow key sequence :-/

>     See Bart's message for that. Is a very good explanation :) IMHO
> the easiest one if you don't want to create new widgets is the one I
> told you yesterday: bind some strange key combo to each widget and

I understood you wrong O:), i thought that what you explained me about 
bindkey -s was to invocate zle directly. But i've find out diggin in
then manuals that zle widgets only can be called from inside a shell
function...

>     Nonetheless, if you plan to make something more complicated in
> the future regarding kill-line (e.g. adding more widgets to run after
> kill-line, making the killing depending on the contents of the
> $BUFFER, etc.) I encourage you to create a new widget.

Right now i just want to run two widgets, but i feel confident
enough to do a widget if in a near future i have some 'dark' ideas XDDDDDD

cheers,

-- 
David Gómez

"The question of whether computers can think is just like the question of
 whether submarines can swim." -- Edsger W. Dijkstra


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

* Re: bindkey and widgets
  2004-03-21 21:51   ` David Gómez
@ 2004-03-22 14:52     ` DervishD
  2004-03-22 16:02       ` David Gómez
  0 siblings, 1 reply; 8+ messages in thread
From: DervishD @ 2004-03-22 14:52 UTC (permalink / raw)
  To: Zsh-users

    Hi David :)

 * Davilín <david@pleyades.net> dixit:
> >     No. If you want to use 'Ctrl+RePag' combo you must edit your
> > /etc/keymap and modify the lines that bind that combo to the
> > scrollback facility under Linux. You should bind them to a string:
> Thanks ;), it works nicely. I should have think at first that i didn't
> have that key combination in my keymap... instead of trying to make zsh
> to map an unknow key sequence :-/

    I'm very used to have Shift-PgUp/PgDn mapped to the scrollback
facility, in fact I consider it a 'system mapping' (which is not, you
can remap that keycombo...). Bart suggested you a very good idea:
C-v. This combination is mapped to 'quoted-insert' by default. This
function inserts the next pressed character or key combo literally.
It is very useful to discover which sequence is emitted by a certain
key combination.

    In the case of C-PgUp, I prefer shift-PgUp for the scrollback
facility, but many systems have Ctrl mapped, instead.

> >     Nonetheless, if you plan to make something more complicated in
> > the future regarding kill-line (e.g. adding more widgets to run after
> > kill-line, making the killing depending on the contents of the
> > $BUFFER, etc.) I encourage you to create a new widget.
> Right now i just want to run two widgets, but i feel confident
> enough to do a widget if in a near future i have some 'dark' ideas XDDDDDD

    Nice XDDD

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


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

* Re: bindkey and widgets
  2004-03-22 14:52     ` DervishD
@ 2004-03-22 16:02       ` David Gómez
  2004-03-22 17:53         ` Eric Mangold
  0 siblings, 1 reply; 8+ messages in thread
From: David Gómez @ 2004-03-22 16:02 UTC (permalink / raw)
  To: Zsh-users

Hi Raúl ;),

>     In the case of C-PgUp, I prefer shift-PgUp for the scrollback
> facility, but many systems have Ctrl mapped, instead.

Indeed i use it that way, shift+pag keys for scrollback and control+pag
keys for zsh history functions. This mail is making a new question
arose in my head... ;). It's not related to Zsh, so sorry for the noise ;).
How can the size of the scrollback buffer be incremented? I guess it is
in the kernel console driver, but where? I looked for it some time ago
and didn't find it...

thanks

-- 
David Gómez

"The question of whether computers can think is just like the question of
 whether submarines can swim." -- Edsger W. Dijkstra


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

* Re: bindkey and widgets
  2004-03-22 16:02       ` David Gómez
@ 2004-03-22 17:53         ` Eric Mangold
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Mangold @ 2004-03-22 17:53 UTC (permalink / raw)
  To: David Gómez, Zsh-users

On Mon, 22 Mar 2004 17:02:49 +0100, David Gómez <david@pleyades.net> wrote:

> Hi Raúl ;),
>
>>     In the case of C-PgUp, I prefer shift-PgUp for the scrollback
>> facility, but many systems have Ctrl mapped, instead.
>
> Indeed i use it that way, shift+pag keys for scrollback and control+pag
> keys for zsh history functions. This mail is making a new question
> arose in my head... ;). It's not related to Zsh, so sorry for the noise 
> ;).
> How can the size of the scrollback buffer be incremented? I guess it is
> in the kernel console driver, but where? I looked for it some time ago
> and didn't find it...

I don't know about setting it at a kernel console, but setting a larger 
scrollback for something like xterm is easy.

	-Eric



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

end of thread, other threads:[~2004-03-22 16:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-21 14:31 bindkey and widgets David Gómez
2004-03-21 17:01 ` Bart Schaefer
2004-03-21 21:26   ` David Gómez
2004-03-21 18:18 ` DervishD
2004-03-21 21:51   ` David Gómez
2004-03-22 14:52     ` DervishD
2004-03-22 16:02       ` David Gómez
2004-03-22 17:53         ` Eric Mangold

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