Proposed syntax for key sequences



Hello!

Its time to deal with one of the latest problems on the way to the
release.  It has been requested many times to improve the keyboard
support.  Now, when the editor saves the latest position, an easy shortcut
to go to the beginning of the file is a must.

Many terminals have distinctive escape sequences for such key combinations
as Ctrl-PgUp.  Yes mc uses strange hacks to figure out what key
combination was pressed.  Either mc should run on Linux console, or it
should be linked against X libraries and be able to access the X server.

And that's despite the fact that mc has its own key database.  The only 
deficiency of the database is that mc cannot read the modifiers from it.

So far I have rewritten mc.lib to use the new format that supports key 
modifiers.  Before I implement the routines to read and write the new 
format, I'd like to make sure that there are no objections against the 
format itself.

The changes are:

1) The sequence is on the left hand side of the "=".  This is done to make
it clear that there is on interpretation for every sequence, but there may
be the same interpretation for different sequences.  The expression before
"=" becomes unique within section, which is consistent with a common
assumption about this kind of config files.

2) keypad sequences are no longer distinguished from non-keypad sequences
(e.g. pgdn vs. kpnpage).  Right now, the difference is ignored in win.c
anyways.

3) Modifiers "alt-", "shift-" and "ctrl-" can be prepended to the right
hand side of the key definition.  Whenever they are read, they are stored
and used in the same way as the data from Linux console and X11.

4) Keys like "kpslash" become char(/), where / is the character to insert.  
Again, it's more flexible than having this logic in win.c.

5) kpplus becomes alt-plus, kpminus becomes alt-minus, kpasterix becomes
alt-asterisk (note that I'm also fixing the typo).  mc already interprets 
those keys as Alt plus the corresponding non-keypad key.

6) Backspace is now written as \177, not directly, because it's a control
character.  ")" and "=" will also be quoted to simplify parsing the file.

7) New keyword "keys_include" allows to include keys for another terminal.  
xterm-color and rxvt use the same key database as xterm.  I'm not aware of
any sequences that have conflicting meanings on those terminals.

That's the proposed mc.lib:

==============================================
[Special dirs]
list=/afs,/coda,/:,/...,/net,/#smb

[terminal:console]
key(\e[2~)=insert
key(\e[23~)=f11
key(\e[24~)=f12
key(\e[25~)=f13
key(\e[26~)=f14
key(\e[28~)=f15
key(\e[29~)=f16
key(\e[31~)=f17
key(\e[32~)=f18
key(\e[33~)=f19
key(\e[34~)=f20
key(\eOt)=left
key(\eOv)=right
key(\eOx)=up
key(\eOr)=down
key(\eOw)=home
key(\eOq)=end
key(\eOs)=pgdn
key(\eOy)=pgup
key(\eOl)=alt-plus
key(\eOS)=alt-minus
key(\eOR)=alt-asterisk
key(\eOp)=insert
key(\eOn)=delete
key(\eOM)=char(\n)
key(\eOQ)=char(/)
key(\eOP)=char(#)

[terminal:linux]
key(\e[2~)=insert
key(\e[23~)=f11
key(\e[24~)=f12
key(\e[25~)=f13
key(\e[26~)=f14
key(\e[28~)=f15
key(\e[29~)=f16
key(\e[31~)=f17
key(\e[32~)=f18
key(\e[33~)=f19
key(\e[34~)=f20
key(\eOt)=left
key(\eOv)=right
key(\eOx)=up
key(\eOr)=down
key(\eOw)=home
key(\eOq)=end
key(\eOs)=pgdn
key(\eOy)=pgup
key(\eOl)=alt-plus
key(\eOS)=alt-minus
key(\eOR)=alt-asterisk
key(\eOp)=insert
key(\eOn)=delete
key(\eOM)=char(\n)
key(\eOQ)=char(/)
key(\eOP)=char(#)

[terminal:xterm]
key(\e[2~)=insert
key(\e[23~)=f11
key(\e[24~)=f12
key(\e[25~)=f13
key(\e[26~)=f14
key(\e[28~)=f15
key(\e[29~)=f16
key(\e[31~)=f17
key(\e[32~)=f18
key(\e[33~)=f19
key(\e[34~)=f20
key(\eOt)=left
key(\eOv)=right
key(\eOx)=up
key(\eOr)=down
key(\eOw)=home
key(\eOq)=end
key(\eOs)=pgdn
key(\eOy)=pgup
key(\eOk)=alt-plus
key(\eOm)=alt-minus
key(\eOj)=alt-asterisk
key(\e[3~)=delete
key(\177)=bs
key(\e[1~)=home
key(\e[7~)=home
key(\eOF)=end
key(\e[4~)=end
key(\e[8~)=end
key(\eOH)=home
key(\e[6~)=pgdn
key(\e[5~)=pgup

# Sequences below are for Konsole, which also sets TERM=xterm
key(\eO2P)=f11
key(\eO2Q)=f12
key(\eO2R)=f13
key(\eO2S)=f14
key(\e[15;2~)=f15
key(\e[17;2~)=f16
key(\e[18;2~)=f17
key(\e[19;2~)=f18
key(\e[20;2~)=f19
key(\e[21;2~)=f20

# xterm control sequences
key(\e[5;5~)=ctrl-pgup
key(\e[6;5~)=ctrl-pgdn
key(\[2A)=shift-up
key(\[2B)=shift-down
key(\[2C)=shift-right
key(\[2D)=shift-left

# rxvt, sometimes also uses TERM=xterm
key(\e[5^)=ctrl-pgup
key(\e[6^)=ctrl-pgdn
key(\e[7^)=ctrl-home
key(\e[8^)=ctrl-end
key(\[a)=shift-up
key(\[b)=shift-down
key(\[c)=shift-right
key(\[d)=shift-left

[terminal:xterm-color]
keys_include=xterm

[terminal:xterm-color]
keys_include=rxvt

[terminal:ibmpc3]
key(\e[Y)=f11
key(\e[Z)=f12
key(\e[a)=f13
key(\e[b)=f14
key(\e[c)=f15
key(\e[d)=f16
key(\e[e)=f17
key(\e[f)=f18
key(\e[g)=f19
key(\e[h)=f20
key(^h)=bs
key(\e[F)=end
key(\e[+)=alt-plus
key(\e[-)=alt-minus
key(\e[*)=alt-asterisk
==============================================

-- 
Regards,
Pavel Roskin




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