[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In this chapter we shall see how the menus and the key bindings of ne
can
be completely configured. Note that the configuration is parsed at startup
time, and cannot be changed during the execution of the program. This is a
chosen limitation.
5.1 Key Bindings | ||
5.2 Changing Menus |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ne
allows you to associate any keystroke with any command. To
accomplish this task, you have to create a file named `.keys' in your
home directory, or in `~/.ne'. You can change the default name
(possibly specifying a complete path) using the --keys
argument
(see section Arguments).
The format of the file is very simple: each line starting with the `KEY' sequence of capital characters is considered the description of a key binding. All other lines are considered commments. The format of a key binding description is
KEY hexcode command |
The hexcode value is the ASCII code of the keystroke. (For
special keys such as Insert or function keys, you should take a
look at the file `default.keys' that comes with ne
's
distribution: it contains a complete, commented definition of
ne
's standard bindings that you can modify with a trial-and-error
approach.) You can write just the hexadecimal digits, nothing else is
necessary (but a prefixing `0x' is tolerated). For instance,
KEY 1 MoveSOL |
binds to Control-A the action of moving to the start of a line, while
KEY 101 LineUp |
binds to the "cursor-up" key the action of moving the cursor one line up.
command can be any ne
command, including Escape
(which allows reconfiguring the menu activator) and Macro
, which
allows binding complex sequences of actions to a single keystroke. The binding
of a macro is very fast because on the first call the macro is cached in memory.
See section Macro.
Note that you cannot ever redefine Return and Escape. This is a basic issue--however brain damaged is the current configuration, you will always be able to exploit fully the menus and the command line.
Besides the "standard" combinations (e.g.,
Control-letter), it possible to program combinations
based on the Meta key (a.k.a. Alt). The situation in this
case is a bit more involved, because depending on the terminal emulator you are
using, the effect of the Meta key can be widely different. For
instance, xterm
raises the eigth bit of a character, so, for
instance,
KEY 81 MoveSOF |
binds Control-Meta-a to the action of moving to the
start of the document. However, gnome-terminal
will emit the
character of ASCII code 1 prefixed with ESC instead. To handle this case,
ne
provides codes from 180 on for simulated Meta
sequences: for instance,
KEY 181 MoveSOF |
binds the abovementioned sequence to the same action as before. In general, the code 180+x corresponds to the sequence ESC followed by the ASCII character of code x. Note that some of these sequences may be disabled, if they conflict with existing sequences of your terminal (for instance, ESC followed by `O' is always disabled because it prefixes several built-in keyboard sequences).
As a final note, we remark that typing Meta-a on
gnome-terminal
will produce an ESC followed by `a'. Since it
is obviously easier to press just Meta rather than Meta and
Control at the same time, it is a good idea to associated the same
sequence also to this combination, using
KEY 1E1 MoveSOF |
Moreover, this setting provides the user with a second choice: one can press Escape followed by a letter instead of using modififiers.
This is the approach used by default in ne
: this way,
Control with Meta plus a letter should always work, and
Meta should work sometimes (of course, if you're sure to use
always the same kind of emulator you can bind more features). Again, the
best place to look at it's `default.keys'.
The key binding file is parsed at startup. If something does not work,
ne
exits displaying an error message. If you want ne
to skip
parsing the key binding file (for instance, to correct the broken
file), just give ne
the --no-config
argument. See section Arguments.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ne
allows you to change the contents of its menus. To
accomplish this task, you have to create a file named `.menus' in your
home directory, or in `~/.ne'. You can change the default name
(possibly specifying a complete path) using the --menus
argument
(see section Arguments).
Each line of a menu configuration file not starting with the `MENU' or `ITEM' keywords is considered a comment. You should describe the menus as in the following example:
MENU "File" ITEM "Open... ^O" Open ITEM "Close " Close ITEM "DoIt " Macro DoIt |
In other words: a line of this form
MENU "title" |
will start the definition of a new menu, having the given title. Each line of the form
ITEM "text" command |
will then define a menu item, and associate the given command to it.
Any number of menus can be accomodated, but you should consider that many terminals are 80 column wide. There is also a minor restriction on the items--their width has to be constant throughout each menu (but different menus can have different widths). Note that the text of an item, as the name of a menu, is between quotes. Whatever follows the last quote is considered the command associated to the menu.
Warning: the description of key bindings in menus
(`^O' in the previous example) is very important for the beginner;
there is no relation inside ne
about what you say in the menu and how
you configure the key bindings (see section Key Bindings). Please do not say
things in the menus that are not true in the key binding file.
The menu configuration file is parsed at startup. If something does not
work, ne
exits displaying an error message. If you want ne
to
skip the menu configuration phase (for instance, to correct the
broken file), just give ne
the --no-config
argument.
See section Arguments.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Sebastiano Vigna on January, 22 2006 using texi2html 1.76.