screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using modifier keys other than control in custom keybindings


From: Stephane Chazelas
Subject: Re: Using modifier keys other than control in custom keybindings
Date: Wed, 18 Jun 2008 16:00:29 +0100
User-agent: Mutt/1.5.16 (2007-09-19)

On Wed, Jun 18, 2008 at 08:30:00AM -0500, Samir Unni wrote:
> Hi,
> 
> I'm trying to figure out how to set a keybinding for "switch the input focus
> to the previous region" as C-a shift-tab. However, the "Default Key
> Bindings" section on the man page doesn't show any examples of the syntax
> for using modifier keys other than control that I can base my custom key
> binding off of. So I have 2 questions about custom keybindings:
> 
>    1. Is "switch the input focus to the previous region" a possible action
>    to bind a key to? I'm using the CVS version of screen, and due to the
>    support for vertical splitting, I frequently end up with 4 or 5 terminals 
> in
>    one screen session. It's very frustrating to have to C-a tab 3 or 4 times 
> to
>    get to the previous terminal, when I'm switching between two of those 4 or 
> 5
>    terminals a lot in a short period of time.

From the manual:

 -- Command: focus
     (`C-a <Tab>')
     Move the input focus to the next region. This is done in a cyclic
     way so that the top region is selected after the bottom one. If no
     subcommand is given it defaults to `down'. `up' cycles in the
     opposite order, `top' and `bottom' go to the top and bottom region
     respectively. Useful bindings are (j and k as in vi)
          bind j focus down
          bind k focus up
          bind t focus top
          bind b focus bottom

>    2. Is it even possible to set a key binding with a modifier key other
>    than control?
[...]

Typically no.

The interaction between screen and the terminal is via characters.

When you press a key or combination of keys, the terminal sends
one or more characters that an application like screen can read.

When you press <Ctrl-A>, it sends the ^A (0x1) character, when
you press <Alt-A> it sends either ESC (0x2b) and a or a with the
eighth bit set depending on the version of the terminal.

When you press <Shift-A>, it sends A instead of a... and so on.

Now, for the <Fx> or <PgDwn>, <Tab>... keys, you'll find that
some terminals do send different character sequences when
<Shift> or <Ctrl> is pressed. It's worth checking. When not in
screen, try <Ctrl-V> followed by the key combination to see what
you get.

For instance, here, <Shift-Tab> sends ^[[Z (the 3 characters ESC
[ Z), so that I could bind that to "focus up" if I wanted to.

And actually, it's done by default here. Because the terminfo
entry for my terminal has:

$ infocmp -1L xterm-256color | grep -i back_tab
        back_tab=\E[Z,

And "focus up" is bound to kB (which is the termcap name for
backtab) in screen by default.

-- 
Stéphane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]