source: keys.c @ 601733d

barnowl_perlaimdebianrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 601733d was db0ac7e, checked in by Alejandro R. Sedeño <asedeno@mit.edu>, 13 years ago
Merged revisions 983-1032 via svnmerge from file:///afs/sipb.mit.edu/project/barnowl/src/svn/trunk ........ r985 | nelhage | 2008-03-11 12:38:20 -0400 (Tue, 11 Mar 2008) | 2 lines Generate less ugly error spew if a module fails to load ........ r986 | geofft | 2008-03-13 15:56:20 -0400 (Thu, 13 Mar 2008) | 1 line Added :webzephyr command with keybinding W. ........ r987 | asedeno | 2008-03-18 23:57:24 -0400 (Tue, 18 Mar 2008) | 2 lines Fix a race condition in which zephyrs received during init are not noticed until the next zephyr after entering the mainloop. ........ r988 | geofft | 2008-03-19 15:46:43 -0400 (Wed, 19 Mar 2008) | 6 lines IRC: explicitly include the network (-a $alias) in reply commands. This may be unnecessary because :irc-msg looks at getcurmsg() if it cannot automatically determine the network. ........ r989 | geofft | 2008-03-21 14:47:51 -0400 (Fri, 21 Mar 2008) | 1 line syntax error. ........ r990 | nelhage | 2008-03-26 02:24:26 -0400 (Wed, 26 Mar 2008) | 2 lines Fix sending jabbers to JIDs beginning with `+' ........ r994 | nelhage | 2008-03-29 17:02:05 -0400 (Sat, 29 Mar 2008) | 3 lines Compile zcrypt.c with -w so I don't get all these warnings in my compile output whenever I change any headers ........ r998 | geofft | 2008-03-31 01:59:47 -0400 (Mon, 31 Mar 2008) | 1 line Implement /me for outgoing IRC messages ........ r999 | geofft | 2008-03-31 09:58:56 -0400 (Mon, 31 Mar 2008) | 1 line I think this fixes the resizing bug. ........ r1000 | nelhage | 2008-03-31 11:29:29 -0400 (Mon, 31 Mar 2008) | 2 lines Make `svkversion' handle exported trees better ........ r1001 | nelhage | 2008-03-31 11:52:39 -0400 (Mon, 31 Mar 2008) | 2 lines Add a makefile rule to support emacs flymake-mode ........ r1015 | nelhage | 2008-04-04 14:58:45 -0400 (Fri, 04 Apr 2008) | 3 lines Bind the combinations the iPhone sends for arrow keys [probably other terminals, too] ........ r1018 | shadow | 2008-04-08 13:57:49 -0400 (Tue, 08 Apr 2008) | 2 lines avoid null pointer dereference if msg is NULL (or a 0 length is claimed) ........ r1019 | nelhage | 2008-04-09 18:08:26 -0400 (Wed, 09 Apr 2008) | 2 lines Fix some stupid typos ........ r1020 | chmrr | 2008-04-09 18:16:02 -0400 (Wed, 09 Apr 2008) | 3 lines r29300@kohr-ah: chmrr | 2008-04-09 18:14:37 -0400 * It's apparently a popular typo ........ r1022 | asedeno | 2008-04-16 17:05:36 -0400 (Wed, 16 Apr 2008) | 2 lines Jabber reply bugfix. Reported by several people, resolved by arolfe. ........ r1023 | nelhage | 2008-04-28 23:33:03 -0400 (Mon, 28 Apr 2008) | 3 lines Initialized merge tracking via "svnmerge" with revisions "735" from svn+ssh://lunatique.mit.edu/mit/barnowl/src/svn/branches/barnowl_unicode ........ r1024 | nelhage | 2008-04-28 23:33:12 -0400 (Mon, 28 Apr 2008) | 3 lines Initialized merge tracking via "svnmerge" with revisions "735" from svn+ssh://lunatique.mit.edu/mit/barnowl/src/svn/branches/barnowl_sqlite ........ r1025 | nelhage | 2008-04-29 01:21:12 -0400 (Tue, 29 Apr 2008) | 2 lines Clone owl_perl from the sqlite branch because I'm about to make use of it. ........ r1026 | nelhage | 2008-04-29 01:21:13 -0400 (Tue, 29 Apr 2008) | 4 lines Initial step of moving styles from the current mishmash of different options to a unified object interface. No backwards-compatibility support yet. ........ r1027 | nelhage | 2008-04-29 01:21:15 -0400 (Tue, 29 Apr 2008) | 2 lines Implement back-compat with old-style owl::format_msg() styles ........ r1028 | nelhage | 2008-04-29 01:21:16 -0400 (Tue, 29 Apr 2008) | 2 lines Remove nearly all references to the "basic" style. ........ r1029 | nelhage | 2008-04-29 01:21:17 -0400 (Tue, 29 Apr 2008) | 2 lines Support the `style' command again. Note that it is deprecated. ........ r1031 | nelhage | 2008-04-30 13:29:45 -0400 (Wed, 30 Apr 2008) | 2 lines Refactor default style code somewhat to be more easily extensible ........
  • Property mode set to 100644
File size: 13.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  /*
36  BIND_CMD("F1",          "help",            "");
37  BIND_CMD("HELP",        "help",            "");
38  BIND_CMD("M-[ 2 8 ~",   "help",            "");
39  */
40
41  BIND_CMD("C-c",         "edit:cancel", "");
42  BIND_CMD("C-g",         "edit:cancel", "");
43
44  BIND_CMD("M-f",         "edit:move-next-word", "");
45  BIND_CMD("M-O 3 C",     "edit:move-next-word", "");
46  BIND_CMD("M-LEFT",      "edit:move-next-word", "");
47  BIND_CMD("M-b",         "edit:move-prev-word", "");
48  BIND_CMD("M-O 3 D",     "edit:move-prev-word", "");
49  BIND_CMD("M-RIGHT",     "edit:move-prev-word", "");
50
51  BIND_CMD("LEFT",        "edit:move-left", "");
52  BIND_CMD("C-b",         "edit:move-left", "");
53  BIND_CMD("RIGHT",       "edit:move-right", "");
54  BIND_CMD("C-f",         "edit:move-right", "");
55
56  BIND_CMD("M-<",         "edit:move-to-buffer-start", "");
57  BIND_CMD("HOME",        "edit:move-to-buffer-start", "");
58  BIND_CMD("M->",         "edit:move-to-buffer-end", "");
59  BIND_CMD("END",         "edit:move-to-buffer-end", "");
60
61  BIND_CMD("C-a",         "edit:move-to-line-start", "");
62  BIND_CMD("C-e",         "edit:move-to-line-end", "");
63
64  BIND_CMD("M-BACKSPACE", "edit:delete-prev-word", "");
65  BIND_CMD("M-DELETE",    "edit:delete-prev-word", "");
66  BIND_CMD("M-d",         "edit:delete-next-word", "");
67  BIND_CMD("M-[ 3 ; 3 ~", "edit:delete-next-word", "");
68
69  BIND_CMD("C-h",         "edit:delete-prev-char", "");
70  BIND_CMD("BACKSPACE",   "edit:delete-prev-char", "");
71  BIND_CMD("DC",          "edit:delete-prev-char", "");
72  BIND_CMD("DELETE",      "edit:delete-prev-char", "");
73
74  BIND_CMD("C-k",         "edit:delete-to-line-end", "");
75
76  BIND_CMD("C-t",         "edit:transpose-chars", "");
77
78  BIND_CMD("M-q",         "edit:fill-paragraph", "");
79
80  BIND_CMD("C-l",         "( edit:recenter ; redisplay )", "");
81
82  BIND_CMD("C-d",     "edit:delete-next-char", "");
83
84
85  /****************************************************************/
86  /**************************** EDITMULTI *************************/
87  /****************************************************************/
88
89  km_ew_multi = km = owl_keyhandler_create_and_add_keymap(kh, "editmulti",
90       "Multi-line text editing", 
91       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
92  owl_keymap_set_submap(km_ew_multi, km_editwin);
93
94  BIND_CMD("UP",      "editmulti:move-up-line", "");
95  BIND_CMD("C-p",     "editmulti:move-up-line", "");
96  BIND_CMD("DOWN",    "editmulti:move-down-line", "");
97  BIND_CMD("C-n",     "editmulti:move-down-line", "");
98
99  /* This would be nice, but interferes with C-c to cancel */
100  /*BIND_CMD("C-c C-c", "editmulti:done", "sends the zephyr");*/
101
102  BIND_CMD("M-p",         "edit:history-prev", "");
103  BIND_CMD("M-n",         "edit:history-next", "");
104
105  /* note that changing "disable-ctrl-d" to "on" will change this to
106   * edit:delete-next-char */
107  BIND_CMD("C-d",     "editmulti:done-or-delete", "sends the zephyr if at the end of the message");
108
109
110  /****************************************************************/
111  /**************************** EDITLINE **************************/
112  /****************************************************************/
113
114  km_ew_onel = km = owl_keyhandler_create_and_add_keymap(kh, "editline",
115       "Single-line text editing", 
116       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
117  owl_keymap_set_submap(km_ew_onel, km_editwin);
118
119  BIND_CMD("C-u",         "edit:delete-all", "Clears the entire line");
120
121  BIND_CMD("UP",          "edit:history-prev", "");
122  BIND_CMD("C-p",         "edit:history-prev", "");
123  BIND_CMD("M-p",         "edit:history-prev", "");
124
125  BIND_CMD("DOWN",        "edit:history-next", "");
126  BIND_CMD("C-n",         "edit:history-next", "");
127  BIND_CMD("M-n",         "edit:history-next", "");
128
129  BIND_CMD("LF",          "editline:done", "executes the command");
130  BIND_CMD("CR",          "editline:done", "executes the command");
131
132 
133  /****************************************************************/
134  /**************************** EDITRESPONSE **********************/
135  /****************************************************************/
136
137  km_ew_onel = km = owl_keyhandler_create_and_add_keymap(kh, "editresponse",
138       "Single-line response to question", 
139       owl_keys_editwin_default, NULL, owl_keys_editwin_postalways);
140  owl_keymap_set_submap(km_ew_onel, km_editwin);
141
142  BIND_CMD("C-u",         "edit:delete-all", "Clears the entire line");
143
144  BIND_CMD("LF",          "editresponse:done", "executes the command");
145  BIND_CMD("CR",          "editresponse:done", "executes the command");
146
147
148  /****************************************************************/
149  /**************************** POPLESS ***************************/
150  /****************************************************************/
151
152  km_viewwin = km = owl_keyhandler_create_and_add_keymap(kh, "popless",
153       "Pop-up window (eg, help)", 
154       owl_keys_default_invalid, NULL, owl_keys_popless_postalways);
155  owl_keymap_set_submap(km_viewwin, km_global);
156
157  BIND_CMD("SPACE",       "popless:scroll-down-page", "");
158  BIND_CMD("NPAGE",       "popless:scroll-down-page", "");
159  BIND_CMD("M-n",         "popless:scroll-down-page", "");
160
161  BIND_CMD("b",           "popless:scroll-up-page", "");
162  BIND_CMD("PPAGE",       "popless:scroll-up-page", "")
163  BIND_CMD("M-p",         "popless:scroll-up-page", "");
164
165  BIND_CMD("CR",          "popless:scroll-down-line", "");
166  BIND_CMD("LF",          "popless:scroll-down-line", "");
167  BIND_CMD("DOWN",        "popless:scroll-down-line", "");
168  BIND_CMD("C-n",         "popless:scroll-down-line", "");
169
170  BIND_CMD("UP",          "popless:scroll-up-line", "");
171  BIND_CMD("C-h",         "popless:scroll-up-line", "");
172  BIND_CMD("C-p",         "popless:scroll-up-line", "");
173  BIND_CMD("DELETE",      "popless:scroll-up-line", "");
174  BIND_CMD("BACKSPACE",   "popless:scroll-up-line", "");
175  BIND_CMD("DC",          "popless:scroll-up-line", "");
176
177  BIND_CMD("RIGHT",       "popless:scroll-right 10", "scrolls right");
178  BIND_CMD("LEFT",        "popless:scroll-left  10", "scrolls left");
179
180  BIND_CMD("HOME",        "popless:scroll-to-top", "");
181  BIND_CMD("<",           "popless:scroll-to-top", "");
182  BIND_CMD("M-<",         "popless:scroll-to-top", "");
183
184  BIND_CMD("END",         "popless:scroll-to-bottom", "");
185  BIND_CMD(">",           "popless:scroll-to-bottom", "");
186  BIND_CMD("M->",         "popless:scroll-to-bottom", "");
187
188  BIND_CMD("q",           "popless:quit", "");
189  BIND_CMD("C-c",         "popless:quit", "");
190  BIND_CMD("C-g",         "popless:quit", "");
191
192  BIND_CMD("C-l",         "redisplay", "");
193
194
195  /****************************************************************/
196  /***************************** RECV *****************************/
197  /****************************************************************/
198
199  km_mainwin = km = owl_keyhandler_create_and_add_keymap(kh, "recv",
200        "Main window / message list",
201        owl_keys_default_invalid, owl_keys_recwin_prealways, NULL);
202  owl_keymap_set_submap(km_mainwin, km_global);
203  BIND_CMD("C-x C-c", "start-command quit", "");
204  BIND_CMD("F1",      "help",           "");
205  BIND_CMD("h",       "help",           "");
206  BIND_CMD("HELP",    "help",           "");
207  BIND_CMD("M-[ 2 8 ~",   "help",       "");
208
209  BIND_CMD(":",       "start-command",  "start a new command");
210  BIND_CMD("M-x",     "start-command",  "start a new command");
211
212  BIND_CMD("x",       "expunge",        "");
213  BIND_CMD("u",       "undelete",       "");
214  BIND_CMD("M-u",     "undelete view",  "undelete all messages in view");
215  BIND_CMD("d",       "delete",         "mark message for deletion");
216  BIND_CMD("M-D",     "delete view",    "mark all messages in view for deletion");
217  BIND_CMD("C-x k",   "smartzpunt -i",  "zpunt current <class,instance>");
218
219  BIND_CMD("X",   "( expunge ; view --home )", "expunge deletions and switch to home view");
220
221  BIND_CMD("v",   "start-command view ", "start a view command");
222  BIND_CMD("V",   "view --home",      "change to the home view ('all' by default)");
223  BIND_CMD("!",   "view -r",          "invert the current view filter");
224  BIND_CMD("M-n", "smartnarrow",      "narrow to a view based on the current message");
225  BIND_CMD("M-N", "smartnarrow -i",   "narrow to a view based on the current message, and consider instance pair");
226  BIND_CMD("M-p", "view personal", "");
227 
228  BIND_CMD("/",   "start-command search ", "start a search command");
229  BIND_CMD("?",   "start-command search -r ", "start a reverse search command");
230
231  BIND_CMD("LEFT",   "recv:shiftleft", "");
232  BIND_CMD("M-[ D",  "recv:shiftleft", "");
233  BIND_CMD("RIGHT",  "recv:shiftright","");
234  BIND_CMD("M-[ C",  "recv:shiftleft", "");
235  BIND_CMD("DOWN",   "recv:next",      "");
236  BIND_CMD("C-n",    "recv:next",      "");
237  BIND_CMD("M-[ B",  "recv:next",      "");
238  BIND_CMD("M-C-n",  "recv:next --smart-filter", "move to next message matching the current one"); 
239  BIND_CMD("UP",     "recv:prev",      "");
240  BIND_CMD("M-[ A",  "recv:prev",      "");
241  BIND_CMD("n",      "recv:next-notdel", "");
242  BIND_CMD("p",      "recv:prev-notdel", "");
243  BIND_CMD("C-p",    "recv:prev",        "");
244  BIND_CMD("M-C-p",  "recv:prev --smart-filter", "move to previous message matching the current one");
245  BIND_CMD("P",      "recv:next-personal", "");
246  BIND_CMD("M-P",    "recv:prev-personal", "");
247  BIND_CMD("M-<",    "recv:first",     "");
248  BIND_CMD("<",      "recv:first",     "");
249  BIND_CMD("M->",    "recv:last",      "");
250  BIND_CMD(">",      "recv:last",      "");
251  BIND_CMD("C-v",    "recv:pagedown",  "");
252  BIND_CMD("NPAGE",  "recv:pagedown",  "");
253  BIND_CMD("M-v",    "recv:pageup",    "");
254  BIND_CMD("PPAGE",  "recv:pageup",    "");
255
256  BIND_CMD("SPACE",     "recv:scroll  10", "scroll message down a page");
257  BIND_CMD("CR",        "recv:scroll   1", "scroll message down a line");
258  BIND_CMD("LF",        "recv:scroll   1", "scroll message down a line");
259  BIND_CMD("C-h"  ,     "recv:scroll  -1", "scroll message up a line");
260  BIND_CMD("DELETE",    "recv:scroll  -1", "scroll message up a line");
261  BIND_CMD("BACKSPACE", "recv:scroll  -1", "scroll message up a line");
262  BIND_CMD("DC",        "recv:scroll  -1", "scroll message up a line");
263  BIND_CMD("b",         "recv:scroll -10", "scroll message up a page");
264
265  BIND_CMD("C-l",       "redisplay",       "");
266
267  BIND_CMD("i",   "info",             "");
268  BIND_CMD("l",   "blist",            "");
269  BIND_CMD("B",   "alist",            "");
270  BIND_CMD("M",   "pop-message",      "");
271  BIND_CMD("T",   "delete trash",     "mark all 'trash' messages for deletion");
272
273  BIND_CMD("o",   "toggle-oneline", "");
274
275  BIND_CMD("A",   "away toggle",     "toggles away message on and off");
276
277  BIND_CMD("z",   "start-command zwrite ", "start a zwrite command");
278  BIND_CMD("a",   "start-command aimwrite ", "start an aimwrite command");
279  BIND_CMD("r",   "reply",            "reply to the current message");
280  BIND_CMD("R",   "reply sender",     "reply to sender of the current message");
281  BIND_CMD("C-r", "reply -e",         "reply to the current message, but allow editing of recipient");
282  BIND_CMD("M-r", "reply -e",         "reply to the current message, but allow editing of recipient");
283  BIND_CMD("M-R", "reply -e sender",  "reply to sender of the current message, but allow editing of recipient");
284                 
285  BIND_CMD("w",   "openurl",          "open a URL using a webbrowser");
286
287  BIND_CMD("W",   "start-command webzephyr ", "start a webzephyr command");
288
289  BIND_CMD("C-c",  "",                "no effect in this mode");
290  BIND_CMD("C-g",  "",                "no effect in this mode");
291
292
293  /**********************/
294
295  owl_function_activate_keymap("recv");
296
297}
298
299
300/****************************************************************/
301/********************* Support Functions ************************/
302/****************************************************************/
303
304void owl_keys_recwin_prealways(owl_input j) {
305  /* Clear the message line on subsequent key presses */
306  owl_function_makemsg("");
307}
308
309void owl_keys_editwin_default(owl_input j) {
310  owl_editwin *e;
311  if (NULL != (e=owl_global_get_typwin(&g))) {
312       owl_editwin_process_char(e, j);
313  }
314}
315
316void owl_keys_editwin_postalways(owl_input j) {
317  owl_editwin *e;
318  if (NULL != (e=owl_global_get_typwin(&g))) {
319    owl_editwin_post_process_char(e, j);
320  }
321  owl_global_set_needrefresh(&g);
322}
323
324void owl_keys_popless_postalways(owl_input j) {
325  owl_viewwin *v = owl_global_get_viewwin(&g);
326  owl_popwin *pw = owl_global_get_popwin(&g);
327
328  if (pw && owl_popwin_is_active(pw) && v) {
329    owl_viewwin_redisplay(v, 1);
330  } 
331}
332
333void owl_keys_default_invalid(owl_input j) {
334  if (j.ch==ERR) return;
335  if (j.ch==410) return;
336  owl_keyhandler_invalidkey(owl_global_get_keyhandler(&g));
337}
338
Note: See TracBrowser for help on using the repository browser.