source: keys.c @ 1403ee9

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 1403ee9 was 6794f72, checked in by James M. Kretchmar <kretch@mit.edu>, 22 years ago
Refixed 'login or login' typo in help Fixed M-u description Removed 'first' and 'last' from basic command help Added M-N to basic key help Added M-D, M-u to basic key help Fixed a quoting problem in configure.in Changed top of help to use 'show' instead of M-x
  • Property mode set to 100644
File size: 11.8 KB
Line 
1#include "owl.h"
2
3static const char fileIdent[] = "$Id$";
4
5#define BIND_CMD(kpress, command, desc) \
6         owl_keymap_create_binding(km, kpress, command, NULL, desc);
7
8#define BIND_FNV(kpress, fn, desc) \
9         owl_keymap_create_binding(km, kpress, NULL, fn, desc);
10
11
12/* sets up the default keymaps */
13void owl_keys_setup_keymaps(owl_keyhandler *kh) {
14  owl_keymap *km, *km_global, *km_editwin, *km_mainwin,
15    *km_ew_multi, *km_ew_onel, *km_viewwin;
16
17 
18  /****************************************************************/
19  /*************************** GLOBAL *****************************/
20  /****************************************************************/
21
22  km_global = km = owl_keyhandler_create_and_add_keymap(kh, "global",
23       "System-wide default key bindings", 
24       owl_keys_default_invalid, NULL, NULL);
25  BIND_CMD("C-z",      "suspend",            "Suspend owl");
26
27  /****************************************************************/
28  /***************************** EDIT *****************************/
29  /****************************************************************/
30
31  km_editwin = km = owl_keyhandler_create_and_add_keymap(kh, "edit",
32       "Text editing and command window", 
33       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
34  owl_keymap_set_submap(km_editwin, km_global);
35  BIND_CMD("F1",          "help",            "");
36  BIND_CMD("HELP",        "help",            "");
37  BIND_CMD("M-[ 2 8 ~",   "help",            "");
38
39  BIND_CMD("C-c",         "edit:cancel", "");
40  BIND_CMD("C-g",         "edit:cancel", "");
41
42  BIND_CMD("M-f",         "edit:move-next-word", "");
43  BIND_CMD("M-O 3 C",     "edit:move-next-word", "");
44  BIND_CMD("M-b",         "edit:move-prev-word", "");
45  BIND_CMD("M-O 3 D",     "edit:move-prev-word", "");
46
47  BIND_CMD("LEFT",        "edit:move-left", "");
48  BIND_CMD("C-b",         "edit:move-left", "");
49  BIND_CMD("RIGHT",       "edit:move-right", "");
50  BIND_CMD("C-f",         "edit:move-right", "");
51
52  BIND_CMD("M-<",         "edit:move-to-buffer-start", "");
53  BIND_CMD("HOME",        "edit:move-to-buffer-start", "");
54  BIND_CMD("M->",         "edit:move-to-buffer-end", "");
55  BIND_CMD("END",         "edit:move-to-buffer-end", "");
56
57  BIND_CMD("C-a",         "edit:move-to-line-start", "");
58  BIND_CMD("C-e",         "edit:move-to-line-end", "");
59
60  BIND_CMD("M-d",         "edit:delete-next-word", "");
61  BIND_CMD("M-[ 3 ; 3 ~", "edit:delete-next-word", "");
62
63  BIND_CMD("C-h",         "edit:delete-prev-char", "");
64  BIND_CMD("BACKSPACE",   "edit:delete-prev-char", "");
65  BIND_CMD("DC",          "edit:delete-prev-char", "");
66  BIND_CMD("DELETE",      "edit:delete-prev-char", "");
67
68  BIND_CMD("C-k",         "edit:delete-to-line-end", "");
69
70  BIND_CMD("M-q",         "edit:fill-paragraph", "");
71
72  BIND_CMD("C-l",         "( edit:recenter ; redisplay )", "");
73
74  BIND_CMD("C-d",     "edit:delete-next-char", "");
75
76
77  /****************************************************************/
78  /**************************** EDITMULTI *************************/
79  /****************************************************************/
80
81  km_ew_multi = km = owl_keyhandler_create_and_add_keymap(kh, "editmulti",
82       "Multi-line text editing", 
83       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
84  owl_keymap_set_submap(km_ew_multi, km_editwin);
85
86  BIND_CMD("UP",      "editmulti:move-up-line", "");
87  BIND_CMD("C-p",     "editmulti:move-up-line", "");
88  BIND_CMD("DOWN",    "editmulti:move-down-line", "");
89  BIND_CMD("C-n",     "editmulti:move-down-line", "");
90
91  /* This would be nice, but interferes with C-c to cancel */
92  /*BIND_CMD("C-c C-c", "editmulti:done", "sends the zephyr");*/
93
94  /* note that changing "disable-ctrl-d" will change this to
95   * edit:delete-next-char */
96  BIND_CMD("C-d",     "editmulti:done", "sends the zephyr");
97
98
99  /****************************************************************/
100  /**************************** EDITLINE **************************/
101  /****************************************************************/
102
103  km_ew_onel = km = owl_keyhandler_create_and_add_keymap(kh, "editline",
104       "Single-line text editing", 
105       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
106  owl_keymap_set_submap(km_ew_onel, km_editwin);
107
108  BIND_CMD("C-u",         "edit:delete-all", "Clears the entire line");
109
110  BIND_CMD("UP",          "edit:history-prev", "");
111  BIND_CMD("C-p",         "edit:history-prev", "");
112  BIND_CMD("M-p",         "edit:history-prev", "");
113
114  BIND_CMD("DOWN",        "edit:history-next", "");
115  BIND_CMD("C-n",         "edit:history-next", "");
116  BIND_CMD("M-n",         "edit:history-next", "");
117
118  BIND_CMD("LF",          "editline:done", "executes the command");
119  BIND_CMD("CR",          "editline:done", "executes the command");
120
121
122  /****************************************************************/
123  /**************************** POPLESS ***************************/
124  /****************************************************************/
125
126  km_viewwin = km = owl_keyhandler_create_and_add_keymap(kh, "popless",
127       "Pop-up window (eg, help)", 
128       owl_keys_default_invalid, NULL, owl_keys_popless_postalways);
129  owl_keymap_set_submap(km_viewwin, km_global);
130
131  BIND_CMD("SPACE",       "popless:scroll-down-page", "");
132  BIND_CMD("NPAGE",       "popless:scroll-down-page", "");
133  BIND_CMD("M-n",         "popless:scroll-down-page", "");
134
135  BIND_CMD("b",           "popless:scroll-up-page", "");
136  BIND_CMD("PPAGE",       "popless:scroll-up-page", "")
137  BIND_CMD("M-p",         "popless:scroll-up-page", "");
138
139  BIND_CMD("CR",          "popless:scroll-down-line", "");
140  BIND_CMD("LF",          "popless:scroll-down-line", "");
141  BIND_CMD("DOWN",        "popless:scroll-down-line", "");
142  BIND_CMD("C-n",         "popless:scroll-down-page", "");
143
144  BIND_CMD("UP",          "popless:scroll-up-line", "");
145  BIND_CMD("C-h",         "popless:scroll-up-line", "");
146  BIND_CMD("C-p",         "popless:scroll-up-line", "");
147  BIND_CMD("DELETE",      "popless:scroll-up-line", "");
148  BIND_CMD("BACKSPACE",   "popless:scroll-up-line", "");
149  BIND_CMD("DC",          "popless:scroll-up-line", "");
150
151  BIND_CMD("RIGHT",       "popless:scroll-right 10", "scrolls right");
152  BIND_CMD("LEFT",        "popless:scroll-left  10", "scrolls left");
153
154  BIND_CMD("HOME",        "popless:scroll-to-top", "");
155  BIND_CMD("<",           "popless:scroll-to-top", "");
156  BIND_CMD("M-<",         "popless:scroll-to-top", "");
157
158  BIND_CMD(">",           "popless:scroll-to-bottom", "");
159  BIND_CMD("M->",         "popless:scroll-to-bottom", "");
160
161  BIND_CMD("q",           "popless:quit", "");
162  BIND_CMD("C-c",         "popless:quit", "");
163  BIND_CMD("C-g",         "popless:quit", "");
164
165  BIND_CMD("C-l",         "redisplay", "");
166
167
168  /****************************************************************/
169  /***************************** RECV *****************************/
170  /****************************************************************/
171
172  km_mainwin = km = owl_keyhandler_create_and_add_keymap(kh, "recv",
173        "Main window / message list",
174        owl_keys_default_invalid, owl_keys_recwin_prealways, NULL);
175  owl_keymap_set_submap(km_mainwin, km_global);
176  BIND_CMD("C-x C-c", "quit",           "");
177  BIND_CMD("F1",      "help",           "");
178  BIND_CMD("h",       "help",           "");
179  BIND_CMD("HELP",    "help",           "");
180  BIND_CMD("M-[ 2 8 ~",   "help",       "");
181
182  BIND_CMD(":",       "start-command",  "start a new command");
183  BIND_CMD("M-x",     "start-command",  "start a new command");
184
185  BIND_CMD("x",       "expunge",        "");
186  BIND_CMD("u",       "undelete",       "");
187  BIND_CMD("M-u",     "undelete view",  "undelete all messages in view");
188  BIND_CMD("d",       "delete",         "mark message for deletion");
189  BIND_CMD("M-D",     "delete view",    "mark all messages in view for deletion");
190  BIND_CMD("C-x k",   "smartzpunt -i",  "zpunt current <class,instance>");
191
192  BIND_CMD("X",   "( expunge ; view --home )", "expunge deletions and switch to home view");
193
194  BIND_CMD("v",   "start-command view ", "start a view command");
195  BIND_CMD("V",   "view --home",      "change to the home view ('all' by default)");
196  BIND_CMD("M-n", "smartnarrow",      "narrow to a view based on the current message");
197  BIND_CMD("M-N", "smartnarrow -i",   "narrow to a view based on the current message, and consider instance pair");
198
199  BIND_CMD("LEFT",   "recv:shiftleft", "");
200  BIND_CMD("RIGHT",  "recv:shiftright","");
201  BIND_CMD("DOWN",   "recv:next",      "");
202  BIND_CMD("C-n",    "recv:next",      "");
203  BIND_CMD("M-C-n",  "recv:next --smart-filter", "move to next message matching the current one"); 
204  BIND_CMD("UP",     "recv:prev",      "");
205  BIND_CMD("n",      "recv:next-notdel", "");
206  BIND_CMD("p",      "recv:prev-notdel", "");
207  BIND_CMD("C-p",    "recv:prev",        "");
208  BIND_CMD("M-C-p",  "recv:prev --smart-filter", "move to previous message matching the current one");
209  BIND_CMD("P",      "recv:next-personal", "");
210  BIND_CMD("M-P",    "recv:prev-personal", "");
211  BIND_CMD("M-<",    "recv:first",     "");
212  BIND_CMD("<",      "recv:first",     "");
213  BIND_CMD("M->",    "recv:last",      "");
214  BIND_CMD(">",      "recv:last",      "");
215  BIND_CMD("C-v",    "recv:pagedown",  "");
216  BIND_CMD("NPAGE",  "recv:pagedown",  "");
217  BIND_CMD("M-v",    "recv:pageup",    "");
218  BIND_CMD("PPAGE",  "recv:pageup",    "");
219
220  BIND_CMD("SPACE",     "recv:scroll  10", "scroll message down a page");
221  BIND_CMD("CR",        "recv:scroll   1", "scroll message down a line");
222  BIND_CMD("LF",        "recv:scroll   1", "scroll message down a line");
223  BIND_CMD("C-h"  ,     "recv:scroll  -1", "scroll message up a line");
224  BIND_CMD("DELETE",    "recv:scroll  -1", "scroll message up a line");
225  BIND_CMD("BACKSPACE", "recv:scroll  -1", "scroll message up a line");
226  BIND_CMD("DC",        "recv:scroll  -1", "scroll message up a line");
227  BIND_CMD("b",         "recv:scroll -10", "scroll message up a page");
228
229  BIND_CMD("C-l",       "redisplay",       "");
230
231  BIND_CMD("i",   "info",             "");
232  BIND_CMD("M",   "pop-message",      "");
233  BIND_CMD("T",   "delete trash",     "mark all 'trash' messages for deletion");
234
235  BIND_CMD("A",   "zaway toggle",     "toggles zaway on and off");
236
237  BIND_CMD("z",   "start-command zwrite ", "start a zwrite command");
238  BIND_CMD("r",   "reply",            "reply to the current message");
239  BIND_CMD("R",   "reply sender",     "reply to sender of the current message");
240  BIND_CMD("C-r", "reply -e",         "reply to the current message, but allow editing of recipient");
241  BIND_CMD("C-R", "reply -e sender",  "reply to sender of the current message, but allow editing of recipient");
242                 
243  BIND_CMD("w",   "openurl",          "open a URL using a webbrowser");
244
245  BIND_CMD("C-c",  "",                "no effect in this mode");
246  BIND_CMD("C-g",  "",                "no effect in this mode");
247
248
249  /**********************/
250
251  owl_function_activate_keymap("recv");
252
253}
254
255
256/****************************************************************/
257/********************* Support Functions ************************/
258/****************************************************************/
259
260void owl_keys_recwin_prealways(int j) {
261  /* Clear the message line on subsequent key presses */
262  owl_function_makemsg("");
263}
264
265void owl_keys_editwin_default(int j) {
266  owl_editwin *e;
267  if (NULL != (e=owl_global_get_typwin(&g))) {
268    owl_editwin_process_char(e, j);
269  }
270}
271
272void owl_keys_editwin_postalways(int j) {
273  owl_editwin *e;
274  if (NULL != (e=owl_global_get_typwin(&g))) {
275    owl_editwin_post_process_char(e, j);
276  } 
277  owl_global_set_needrefresh(&g);
278}
279
280void owl_keys_popless_postalways(int j) {
281  owl_viewwin *v = owl_global_get_viewwin(&g);
282  owl_popwin *pw = owl_global_get_popwin(&g);
283
284  if (pw && owl_popwin_is_active(pw) && v) {
285    owl_viewwin_redisplay(v, 1);
286  } 
287}
288
289void owl_keys_default_invalid(int j) {
290  if (j==ERR) return;
291  if (j==410) return;
292  owl_keyhandler_invalidkey(owl_global_get_keyhandler(&g));
293}
294
Note: See TracBrowser for help on using the repository browser.