File: Key-Bindings.html

package info (click to toggle)
ne 2.1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,540 kB
  • ctags: 3,408
  • sloc: ansic: 24,666; perl: 500; makefile: 207; sh: 9
file content (129 lines) | stat: -rw-r--r-- 6,760 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<html lang="en">
<head>
<title>Key Bindings - ne's manual</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="ne's manual">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Configuration.html#Configuration" title="Configuration">
<link rel="next" href="Changing-Menus.html#Changing-Menus" title="Changing Menus">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Key-Bindings"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Changing-Menus.html#Changing-Menus">Changing Menus</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Configuration.html#Configuration">Configuration</a>
<hr>
</div>

<h3 class="section">5.1 Key Bindings</h3>

<p><a name="index-Key-bindings-218"></a><a name="index-Configuring-the-keyboard-219"></a>
<code>ne</code> allows you to associate any keystroke with any command. To
accomplish this task, you have to create a (possibly UTf-8) file named
<samp><span class="file">.keys</span></samp> in your home directory, or in <samp><span class="file">~/.ne</span></samp>. You can change
the default name (possibly specifying a complete path) using the
<code>--keys</code> argument (see <a href="Arguments.html#Arguments">Arguments</a>).

   <p>The format of the file is very simple: each line starting with the &lsquo;<samp><span class="samp">KEY</span></samp>&rsquo;
sequence of capital characters is considered the description of a key binding. 
All other lines are considered comments. The format of a key binding
description is

<pre class="example">     KEY <var>hexcode</var> <var>command</var>
</pre>
   <p>The <var>hexcode</var> value is the <span class="sc">ascii</span> code of the keystroke. (For
special keys such as &lt;Insert&gt; or function keys, you should take a
look at the file <samp><span class="file">default.keys</span></samp> that comes with <code>ne</code>'s
distribution: it contains a complete, commented definition of
<code>ne</code>'s standard bindings that you can modify with a trial-and-error
approach.) The easiest way to see the code <code>ne</code> uses for a given
key is by using the <a href="KeyCode.html#KeyCode">KeyCode</a> command. It prompts you to press a
key, then reports the code for that key on the status bar.

   <p>You can write just the hexadecimal digits, nothing else is
necessary (but a prefixing &lsquo;<samp><span class="samp">0x</span></samp>&rsquo; is tolerated).  For instance,

<pre class="example">     KEY 1 MoveSOL
</pre>
   <p class="noindent">binds to <kbd>&lt;Control&gt;-A</kbd> the action of moving to the start
of a line, while

<pre class="example">     KEY 101 LineUp
</pre>
   <p class="noindent">binds to the &ldquo;cursor-up&rdquo; key the action of moving the cursor
one line up.

   <p><var>command</var> can be any <code>ne</code> command, including <code>Escape</code>
(which allows reconfiguring the menu activator) and <code>Macro</code>, 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 <a href="Macro.html#Macro">Macro</a>.

   <p>Note that you cannot <em>ever</em> redefine &lt;Return&gt; or &lt;Escape&gt;. This
is a basic issue&mdash;however brain damaged is the current configuration, you will
always be able to exploit fully the menus and the command line.

   <p>Besides the &ldquo;standard&rdquo; combinations (e.g.,
<kbd>&lt;Control&gt;-</kbd><var>letter</var>), it possible to program combinations
based on the &lt;Meta&gt; key (a.k.a. &lt;Alt&gt;). The situation in this
case is a bit more involved, because depending on the terminal emulator you are
using, the effect of the &lt;Meta&gt; key can be widely different. For
instance, <code>xterm</code> raises the eighth bit of a character, so, for
instance,

<pre class="example">     KEY 81 MoveSOF
</pre>
   <p class="noindent">binds <kbd>&lt;Control&gt;-&lt;Meta&gt;-a</kbd> to the action of moving to the
start of the document. However, <code>gnome-terminal</code> will emit the
character of ASCII code 1 prefixed with ESC instead. To handle this case,
<code>ne</code> provides codes from 180 on for <em>simulated &lt;Meta&gt;
sequences</em>: for instance,

<pre class="example">     KEY 181 MoveSOF
</pre>
   <p class="noindent">binds the abovementioned sequence to the same action as
before. In general, the code 180+<var>x</var> corresponds to the sequence
ESC followed by the ASCII character of code <var>x</var>. Note that some of
these sequences may be disabled, if they conflict with existing sequences
of your terminal (for instance, ESC followed by &lsquo;<samp><span class="samp">O</span></samp>&rsquo; is always
disabled because it prefixes several built-in keyboard sequences).

   <p>As a final note, we remark that typing <kbd>&lt;Meta&gt;-a</kbd> on
<code>gnome-terminal</code> will produce an ESC followed by &lsquo;<samp><span class="samp">a</span></samp>&rsquo;. Since it
is obviously easier to press just &lt;Meta&gt; rather than &lt;Meta&gt; and
&lt;Control&gt; at the same time, it is a good idea to associate the same
sequence also to this combination, using

<pre class="example">     KEY 1E1 MoveSOF
</pre>
   <p>Moreover, this setting provides the user with a second choice: one can
press &lt;Escape&gt; followed by a letter instead of using modifiers.

   <p>This is the approach used by default in <code>ne</code>: this way,
&lt;Control&gt; with &lt;Meta&gt; plus a letter should always work, and
&lt;Meta&gt; 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 <samp><span class="file">default.keys</span></samp>.

   <p>The key binding file is parsed at startup. If something does not work,
<code>ne</code> exits displaying an error message. If you want <code>ne</code> to skip
parsing the key binding file (for instance, to correct the broken
file), just give <code>ne</code> the <code>--no-config</code> argument. See <a href="Arguments.html#Arguments">Arguments</a>.

   </body></html>