source: commands.c @ b950088

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since b950088 was b950088, checked in by Erik Nygren <nygren@mit.edu>, 18 years ago
* Added --no-move option to delete command. In particular, delete-and-always-move-down may now be implemented with '( delete --no-move ; next --skip-deleted )'. * Folded the nextmsg and prevmsg commands and functions together into one command which takes arguments. Added '--filter <name>' option (eg, for next_personal), '--skip-deleted' option, and '--last-if-none'/'--first-if-none' options. Help updated accordingly. In particular, the 'personal' view is now used for 'next personal'. * Updated examples/owlconf.erik with the above.
  • Property mode set to 100644
File size: 43.3 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <unistd.h>
5#include "owl.h"
6
7static const char fileIdent[] = "$Id$";
8
9/* fn is "char *foo(int argc, char **argv, char *buff)" */
10#define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \
11        { name, summary, usage, description, ctx, \
12          NULL, fn, NULL, NULL, NULL, NULL, NULL }
13
14/* fn is "void foo(void)" */
15#define OWLCMD_VOID(name, fn, ctx, summary, usage, description) \
16        { name, summary, usage, description, ctx, \
17          NULL, NULL, fn, NULL, NULL, NULL, NULL }
18
19/* fn is "void foo(int)" */
20#define OWLCMD_INT(name, fn, ctx, summary, usage, description) \
21        { name, summary, usage, description, ctx, \
22          NULL, NULL, NULL, fn, NULL, NULL, NULL }
23
24#define OWLCMD_ALIAS(name, actualname) \
25        { name, OWL_CMD_ALIAS_SUMMARY_PREFIX actualname, "", "", OWL_CTX_ANY, \
26          actualname, NULL, NULL, NULL, NULL, NULL, NULL }
27
28/* fn is "char *foo(void *ctx, int argc, char **argv, char *buff)" */
29#define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \
30        { name, summary, usage, description, ctx, \
31          NULL, NULL, NULL, NULL, ((char*(*)(void*,int,char**,char*))fn), NULL, NULL }
32
33/* fn is "void foo(void)" */
34#define OWLCMD_VOID_CTX(name, fn, ctx, summary, usage, description) \
35        { name, summary, usage, description, ctx, \
36          NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL }
37
38/* fn is "void foo(int)" */
39#define OWLCMD_INT_CTX(name, fn, ctx, summary, usage, description) \
40        { name, summary, usage, description, ctx, \
41          NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn) }
42
43
44owl_cmd commands_to_init[]
45  = {
46  OWLCMD_ARGS("zlog", owl_command_zlog, OWL_CTX_ANY,
47              "send a login or logout notification",
48              "zlog in\nzlog out",
49              "zlog in will send a login notification, zlog out will send a\n"
50              "logout notification.  By default a login notification is sent\n"
51              "when owl is started and a logout notification is sent when owl\n"
52              "is exited.  This behavior can be changed with the 'startuplogin'\n"
53              "and 'shudownlogout' variables.\n"),
54
55  OWLCMD_VOID("quit", owl_command_quit, OWL_CTX_ANY,
56              "exit owl",
57              "",
58              "Exit owl and run any shutdown activities."),
59  OWLCMD_ALIAS("exit", "quit"),
60  OWLCMD_ALIAS("q",    "quit"),
61 
62  OWLCMD_ARGS("start-command", owl_command_start_command, OWL_CTX_INTERACTIVE,
63              "prompts the user to enter a command",
64              "start-command [initial-value]",
65              "Initializes the command field to initial-value."),
66
67  OWLCMD_ARGS("alias", owl_command_alias, OWL_CTX_ANY,
68              "creates a command alias",
69              "alias <new_command> <old_command>",
70              "Creates a command alias from new_command to old_command.\n"
71              "Any arguments passed to <new_command> will be appended to\n"
72              "<old_command> before it is executed.\n"),
73
74  OWLCMD_ARGS("bindkey", owl_command_bindkey, OWL_CTX_ANY,
75              "creates a binding in a keymap",
76              "bindkey <keymap> <keyseq> command <command>",
77              "Binds a key sequence to a command within a keymap.\n"
78              "Use 'show keymaps' to see the existing keymaps.\n"
79              "Key sequences may be things like M-C-t or NPAGE.\n"),
80
81  OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE,
82              "send a zephyr",
83              "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] ",
84              "Zwrite send a zephyr to the one or more users specified.\n\n"
85              "The following options are available:\n\n"
86              "-n    Do not send a ping message.\n\n"
87              "-C    If the message is sent to more than one user include a\n"
88              "      \"cc:\" line in the text\n\n"
89              "-c class\n"
90              "      Send to the specified zephyr class\n\n"
91              "-i instance\n"
92              "      Send to the specified zephyr instance\n\n"
93              "-r realm\n"
94              "      Send to a foreign realm\n"
95              "-O opcode\n"
96              "      Send to the specified opcode\n"),
97 
98  OWLCMD_ARGS("reply", owl_command_reply,  OWL_CTX_INTERACTIVE,
99              "reply to the current message",
100              "reply [-e] [ sender | all ]",
101              "If -e is specified, the zwrite command line is presented to\n"
102              "allow editing.\n\n"
103              "If 'sender' is specified, reply to the sender.\n\n"
104              "If 'all' or no args are specified, reply publically to the\n"
105              "same class/instance for non-personal messages and to the\n"
106              "sender for personal messages.\n"),
107
108  OWLCMD_ARGS("set", owl_command_set, OWL_CTX_ANY,
109              "set a variable value",
110              "set [-q] <variable> <value>\n"
111              "set",
112              "Set the named variable to the specified value.  If no\n"
113              "arguments are used print the value of all variables.\n"
114              "If -q is specified, is silent and doesn't print a message.\n"),
115
116  OWLCMD_ARGS("print", owl_command_print, OWL_CTX_ANY,
117              "print a variable value",
118              "print <variable>\n"
119              "print",
120              "Print the value of the named variable.  If no arugments\n"
121              "are used print the value of all variables.\n"),
122
123  OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY,
124              "print the version of the running owl", "", ""),
125
126  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
127              "subscribe to a zephyr class, instance, recipient",
128              "subscribe <class> <instance> [recipient]",
129              "Subscribe the specified class and instance.  If the recipient\n"
130              "is not listed on the command line it defaults\n"
131              "to * (the wildcard recipient).\n"),
132  OWLCMD_ALIAS("sub", "subscribe"),
133
134  OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
135              "unsubscribe from a zephyr class, instance, recipient",
136              "unsubscribe <class> <instance> [recipient]",
137              "Unsubscribe from the specified class and instance.  If the\n"
138              "recipient is not listed on the command line it defaults\n"
139              "to * (the wildcard recipient).\n"),
140  OWLCMD_ALIAS("unsub", "unsubscribe"),
141
142  OWLCMD_VOID("unsuball", owl_command_unsuball, OWL_CTX_ANY,
143              "unsubscribe from all zephyrs", "", ""),
144 
145  OWLCMD_VOID("getsubs", owl_command_getsubs, OWL_CTX_ANY,
146              "print all current subscriptions",
147              "getsubs",
148              "getsubs retrieves the current subscriptions from the server\n"
149              "and displays them.\n"),
150
151  OWLCMD_ARGS("zpunt", owl_command_zpunt, OWL_CTX_ANY,
152              "suppress a given zephyr triplet",
153              "zpunt <class> <instance> [recipient]\n"
154              "zpunt <instance>",
155              "The zpunt command will supress message to the specified\n"
156              "zephyr triplet.  In the second usage messages as supressed\n"
157              "for class MESSAGE and the named instance.\n\n"
158              "SEE ALSO:  zunpunt, show zpunts\n"),
159
160  OWLCMD_ARGS("zunpunt", owl_command_zunpunt, OWL_CTX_ANY,
161              "undo a previous zpunt",
162              "zunpunt <class> <instance> [recipient]\n"
163              "zunpunt <instance>",
164              "The zunpunt command will allow messages that were previosly\n"
165              "suppressed to be received again.\n\n"
166              "SEE ALSO:  zpunt, show zpunts\n"),
167
168  OWLCMD_VOID("info", owl_command_info, OWL_CTX_INTERACTIVE,
169              "display detailed information about the current message",
170              "", ""),
171 
172  OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
173              "display help on using owl",
174              "help [command]", ""),
175 
176  OWLCMD_VOID("recv:shiftleft", owl_command_shift_left, OWL_CTX_INTERACTIVE,
177              "scrolls receive window to the left", "", ""),
178
179  OWLCMD_VOID("recv:shiftright", owl_command_shift_right, OWL_CTX_INTERACTIVE,
180              "scrolls receive window to the left", "", ""),
181
182  OWLCMD_VOID("recv:pagedown", owl_function_mainwin_pagedown, 
183              OWL_CTX_INTERACTIVE,
184              "scrolls down by a page", "", ""),
185
186  OWLCMD_VOID("recv:pageup", owl_function_mainwin_pageup, OWL_CTX_INTERACTIVE,
187              "scrolls up by a page", "", ""),
188
189  OWLCMD_INT ("recv:scroll", owl_function_page_curmsg, OWL_CTX_INTERACTIVE,
190              "scrolls current message up or down", 
191              "recv:scroll <numlines>", 
192              "Scrolls the current message up or down by <numlines>.\n"
193              "Scrolls up if <numlines> is negative, else scrolls down.\n"),
194
195  OWLCMD_ARGS("next", owl_command_next, OWL_CTX_INTERACTIVE,
196              "move the pointer to the next message",
197              "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]",
198              "Moves the pointer to the next message in the current view.\n"
199              "If --filter is specified, will only consider messages in\n"
200              "the filter <name>.\n"
201              "If --skip-deleted is specified, deleted messages will\n"
202              "be skipped.\n"
203              "If --last-if-none is specified, will stop at last message\n"
204              "in the view if no other suitable messages are found.\n"),
205  OWLCMD_ALIAS("recv:next", "next"),
206
207  OWLCMD_ARGS("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
208              "move the pointer to the previous message",
209              "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]",
210              "Moves the pointer to the next message in the current view.\n"
211              "If --filter is specified, will only consider messages in\n"
212              "the filter <name>.\n"
213              "If --skip-deleted is specified, deleted messages will\n"
214              "be skipped.\n"
215              "If --first-if-none is specified, will stop at first message\n"
216              "in the view if no other suitable messages are found.\n"),
217  OWLCMD_ALIAS("recv:prev", "prev"),
218
219  OWLCMD_ALIAS("recv:next-notdel", "recv:next --skip-deleted --last-if-none"),
220  OWLCMD_ALIAS("next-notdel",      "recv:next --skip-deleted --last-if-none"),
221
222  OWLCMD_ALIAS("recv:prev-notdel", "recv:prev --skip-deleted --first-if-none"),
223  OWLCMD_ALIAS("prev-notdel",      "recv:prev --skip-deleted --first-if-none"),
224
225  OWLCMD_ALIAS("recv:next-personal", "recv:next --filter personal"),
226
227  OWLCMD_ALIAS("recv:prev-personal", "recv:prev --filter personal"),
228
229  OWLCMD_VOID("first", owl_command_first, OWL_CTX_INTERACTIVE,
230              "move the pointer to the first message", "", ""),
231  OWLCMD_ALIAS("recv:first", "first"),
232
233  OWLCMD_VOID("last", owl_command_last, OWL_CTX_INTERACTIVE,
234              "move the pointer to the last message", "", ""),
235  OWLCMD_ALIAS("recv:last", "last"),
236
237  OWLCMD_VOID("expunge", owl_command_expunge, OWL_CTX_INTERACTIVE,
238              "remove all messages marked for deletion", "", ""),
239
240  OWLCMD_VOID("resize", owl_command_resize, OWL_CTX_ANY,
241              "resize the window to the current screen size", "", ""),
242
243  OWLCMD_VOID("redisplay", owl_command_redisplay, OWL_CTX_ANY,
244              "redraw the entire window", "", ""),
245
246  OWLCMD_VOID("suspend", owl_command_suspend, OWL_CTX_ANY,
247              "suspend owl", "", ""),
248
249  OWLCMD_ARGS("echo", owl_command_echo, OWL_CTX_ANY,
250              "pops up a message in popup window",
251              "echo [args .. ]\n\n", ""),
252
253  OWLCMD_ARGS("exec", owl_command_exec, OWL_CTX_ANY,
254              "run a command from the shell",
255              "exec [args .. ]", ""),
256
257  OWLCMD_ARGS("aexec", owl_command_aexec, OWL_CTX_INTERACTIVE,
258              "run a command from the shell and display in an admin message",
259              "aexec [args .. ]", ""),
260
261  OWLCMD_ARGS("pexec", owl_command_pexec, OWL_CTX_INTERACTIVE,
262              "run a command from the shell and display in a popup window",
263              "pexec [args .. ]", ""),
264
265  OWLCMD_ARGS("perl", owl_command_perl, OWL_CTX_ANY,
266              "run a perl expression",
267              "perl [args .. ]", ""),
268
269  OWLCMD_ARGS("aperl", owl_command_aperl, OWL_CTX_INTERACTIVE,
270              "run a perl expression and display in an admin message",
271              "aperl [args .. ]", ""),
272
273  OWLCMD_ARGS("pperl", owl_command_pperl, OWL_CTX_INTERACTIVE,
274              "run a perl expression and display in a popup window",
275              "pperl [args .. ]", ""),
276
277  OWLCMD_ARGS("multi", owl_command_multi, OWL_CTX_ANY,
278              "runs multiple ;-separated commands",
279              "multi <command1> ( ; <command2> )*\n",
280              "Runs multiple semicolon-separated commands in order.\n"
281              "Note quoting isn't supported here yet.\n"
282              "If you want to do something fancy, use perl.\n"),
283
284  OWLCMD_ARGS("(", owl_command_multi, OWL_CTX_ANY,
285              "runs multiple ;-separated commands",
286              "'(' <command1> ( ; <command2> )* ')'\n",
287              "Runs multiple semicolon-separated commands in order.\n"
288              "You must have a space before the final ')'\n"
289              "Note quoting isn't supported here yet.\n"
290              "If you want to do something fancy, use perl.\n"),
291
292  OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN,
293              "pops up a message in a window", "", ""),
294
295  OWLCMD_VOID("openurl", owl_command_openurl, OWL_CTX_INTERACTIVE,
296              "opens up a URL from the current message",
297              "", 
298              "Uses the 'webbrowser' variable to determine\n"
299              "which browser to use.  Currently, 'netscape'\n"
300              "and 'galeon' are supported.\n"),
301
302  OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE,
303              "running a command from the shell",
304              "zaway [ on | off | toggle ]\n"
305              "zaway <message>",
306              "Turn on or off the default zaway message.  If a message is\n"
307              "specified turn on zaway with that message\n"),
308
309  OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY,
310              "load subscriptions from a file",
311              "load-subs <file>\n", ""),
312
313  OWLCMD_VOID("about", owl_command_about, OWL_CTX_INTERACTIVE,
314              "print information about owl", "", ""),
315
316  OWLCMD_VOID("status", owl_command_status, OWL_CTX_ANY,
317              "print status information about the running owl", "", ""),
318 
319  OWLCMD_ARGS("zlocate", owl_command_zlocate, OWL_CTX_INTERACTIVE,
320              "locate a user",
321              "zlocate [-d] <user>", 
322              "Performs a zlocate on a user and puts the result into\n"
323              "a popwin.  If -d is specified, does not authenticate\n"
324              "the lookup request.\n"),
325 
326  OWLCMD_ARGS("filter", owl_command_filter, OWL_CTX_ANY,
327              "create a message filter",
328              "filter <name> [ -c color ] [ <expression> ... ]",
329              "The filter command creates a filter with the specified name,\n"
330              "or if one already exists it is replaced.  Example filter\n"
331              "syntax would be:\n\n"
332              "     filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ )\n\n"
333              "Valid matching fields are class, instance, recipient, sender,\n"
334              "opcode and realm. Valid operations are 'and', 'or' and 'not'.\n"
335              "Spaces must be present before and after parenthesis.  If the\n"
336              "optional color argument is used it specifies the color that\n"
337              "messages matching this filter should be displayed in.\n\n"
338
339              "SEE ALSO: view, viewclass, viewuser\n"),
340
341  OWLCMD_ARGS("colorview", owl_command_colorview, OWL_CTX_INTERACTIVE,
342              "change the color on the current filter",
343              "colorview <color>",
344              "The color of messages in the current filter will be changed\n"
345              "to <color>.  Use the 'show colors' command for a list\n"
346              "of valid colors.\n\n"
347              "SEE ALSO: 'show colors'\n"),
348
349  OWLCMD_ARGS("view", owl_command_view, OWL_CTX_INTERACTIVE,
350              "view messages matching a filter",
351              "view <filter>\n"
352              "view -d <expression>\n"
353              "view --home",
354              "In the first usage, The view command sets the current view to\n"
355              "the specified filter.   This causes only messages matching\n"
356              "that filter to be displayed.\n"
357              "\n"
358              "In the second usage a filter expression\n"
359              "and be specified directly\n"
360              "after -d.  Owl will build an internal filter based on this\n"
361              "filter and change the current view to use it.\n\n"
362              "If --home is specified, switches to the view specified by\n"
363              "the 'view_home' variable.\n\n"
364              "SEE ALSO: filter, viewclass, viewuser\n"),
365
366  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
367              "view only messages similar to the current message",
368              "smartnarrow [-i]",
369              "If the curmsg is a personal message narrow\n"
370              "   to the converstaion with that user.\n"
371              "If the curmsg is a class message, instance foo, recip *\n"
372              "   message, narrow to the class, inst.\n"
373              "If the curmsg is a class message then narrow\n"
374              "    to the class.\n"
375              "If the curmsg is a class message and '-i' is specied\n"
376              "    then narrow to the class, instance\n"),
377
378  OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE,
379              "view messages matching a particular class",
380              "viewclass <class>",
381              "The viewclass command will automatically create a filter\n"
382              "matching the specified class and switch the current view\n"
383              "to it.\n\n"
384              "SEE ALSO: filter, view, viewuser\n"),
385  OWLCMD_ALIAS("vc", "viewclass"),
386
387  OWLCMD_ARGS("viewuser", owl_command_viewuser, OWL_CTX_INTERACTIVE,
388              "view messages matching a particular user",
389              "viewuser <user>",
390              "The viewuser command will automatically create a filter\n"
391              "matching the specified user and switch the current\n"
392              "view to it.\n\n"
393              "SEE ALSO: filter, view, viewclass\n"),
394  OWLCMD_ALIAS("vu", "viewuser"),
395
396  OWLCMD_ARGS("show", owl_command_show, OWL_CTX_INTERACTIVE,
397              "show information",
398              "show variables\n"
399              "show variable <variable>\n"
400              "show filters\n"
401              "show filter <filter>\n"
402              "show keymaps\n"
403              "show keymap <keymap>\n"
404              "show commands\n"
405              "show command <command>\n"
406              "show subs\n"
407              "show subscriptions\n"
408              "show zpunts\n"
409              "show colors\n"
410              "show terminal\n"
411              "show version\n"
412              "show status\n",
413
414              "Show colors will display a list of valid colors for the\n"
415              "     terminal."
416              "Show filters will list the names of all filters.\n"
417              "Show filter <filter> will show the definition of a particular\n"
418              "     filter.\n\n"
419              "Show zpunts will show the active zpunt filters.\n\n"
420              "Show keymaps will list the names of all keymaps.\n"
421              "Show keymap <keymap> will show the key bindings in a keymap.\n\n"
422              "Show commands will list the names of all keymaps.\n"
423              "Show command <command> will provide information about a command.\n\n"
424              "Show variables will list the names of all variables.\n\n"
425              "SEE ALSO: filter, view, alias, bindkey, help\n"),
426 
427  OWLCMD_ARGS("delete", owl_command_delete, OWL_CTX_INTERACTIVE,
428              "mark a message for deletion",
429              "delete [ -id msgid ] [ --no-move ]\n"
430              "delete view\n"
431              "delete trash",
432              "If no message id is specified the current message is marked\n"
433              "for deletion.  Otherwise the message with the given message\n"
434              "id is marked for deltion.\n"
435              "If '--no-move' is specified, don't move after deletion.\n"
436              "If 'trash' is specified, deletes all trash/auto messages\n"
437              "in the current view.\n"
438              "If 'view' is specified, deletes all messages in the\n"
439              "current view.\n"),
440  OWLCMD_ALIAS("del", "delete"),
441
442  OWLCMD_ARGS("undelete", owl_command_undelete, OWL_CTX_INTERACTIVE,
443              "unmark a message for deletion",
444              "undelete [ -id msgid ] [ --no-move ]\n"
445              "undelete view",
446              "If no message id is specified the current message is\n"
447              "unmarked for deletion.  Otherwise the message with the\n"
448              "given message id is marked for undeltion.\n"
449              "If '--no-move' is specified, don't move after deletion.\n"
450              "If 'view' is specified, undeletes all messages\n"
451              "in the current view.\n"),
452  OWLCMD_ALIAS("undel", "undelete"),
453
454  OWLCMD_VOID("beep", owl_command_beep, OWL_CTX_ANY,
455              "ring the terminal bell",
456              "beep",
457              "Beep will ring the terminal bell.\n"
458              "If the variable 'bell' has been\n"
459              "set to 'off' this command does nothing.\n"),
460
461  OWLCMD_ARGS("debug", owl_command_debug, OWL_CTX_ANY,
462              "prints a message into the debug log",
463              "debug <message>", ""),
464
465  /****************************************************************/
466  /************************* EDIT-SPECIFIC ************************/
467  /****************************************************************/
468
469  OWLCMD_VOID_CTX("edit:move-next-word", owl_editwin_move_to_nextword, 
470                  OWL_CTX_EDIT,
471                  "moves cursor forward a word",
472                  "", ""),
473
474  OWLCMD_VOID_CTX("edit:move-prev-word", owl_editwin_move_to_previousword, 
475                  OWL_CTX_EDIT,
476                  "moves cursor backwards a word",
477                  "", ""),
478
479  OWLCMD_VOID_CTX("edit:move-to-buffer-start", owl_editwin_move_to_top,
480                  OWL_CTX_EDIT,
481                  "moves cursor to the top left (start) of the buffer",
482                  "", ""),
483
484  OWLCMD_VOID_CTX("edit:move-to-buffer-end", owl_editwin_move_to_end, 
485                  OWL_CTX_EDIT,
486                  "moves cursor to the bottom right (end) of the buffer",
487                  "", ""),
488
489  OWLCMD_VOID_CTX("edit:move-to-line-end", owl_editwin_move_to_line_end, 
490                  OWL_CTX_EDIT,
491                  "moves cursor to the end of the line",
492                  "", ""),
493
494  OWLCMD_VOID_CTX("edit:move-to-line-start", owl_editwin_move_to_line_start, 
495                  OWL_CTX_EDIT,
496                  "moves cursor to the beginning of the line",
497                  "", ""),
498
499  OWLCMD_VOID_CTX("edit:move-left", owl_editwin_key_left, 
500                  OWL_CTX_EDIT,
501                  "moves the cursor left by a character",
502                  "", ""),
503
504  OWLCMD_VOID_CTX("edit:move-right", owl_editwin_key_right,
505                  OWL_CTX_EDIT,
506                  "moves the cursor right by a character",
507                  "", ""),
508
509  OWLCMD_VOID_CTX("edit:delete-next-word", owl_editwin_delete_nextword,
510                  OWL_CTX_EDIT,
511                  "deletes the word to the right of the cursor",
512                  "", ""),
513
514  OWLCMD_VOID_CTX("edit:delete-prev-char", owl_editwin_backspace,
515                  OWL_CTX_EDIT,
516                  "deletes the character to the left of the cursor",
517                  "", ""),
518
519  OWLCMD_VOID_CTX("edit:delete-next-char", owl_editwin_delete_char, 
520                  OWL_CTX_EDIT,
521                  "deletes the character to the right of the cursor",
522                  "", ""),
523
524  OWLCMD_VOID_CTX("edit:delete-to-line-end", owl_editwin_delete_to_endofline,
525                  OWL_CTX_EDIT,
526                  "deletes from the cursor to the end of the line",
527                  "", ""),
528
529  OWLCMD_VOID_CTX("edit:delete-all", owl_editwin_clear, 
530                  OWL_CTX_EDIT,
531                  "deletes all of the contents of the buffer",
532                  "", ""),
533
534  OWLCMD_VOID_CTX("edit:fill-paragraph", owl_editwin_fill_paragraph, 
535                  OWL_CTX_EDIT,
536                  "fills the current paragraph to line-wrap well",
537                  "", ""),
538
539  OWLCMD_VOID_CTX("edit:recenter", owl_editwin_recenter, 
540                  OWL_CTX_EDIT,
541                  "recenters the buffer",
542                  "", ""),
543
544  OWLCMD_ARGS_CTX("edit:insert-text", owl_command_edit_insert_text, 
545                  OWL_CTX_EDIT,
546                  "inserts text into the buffer",
547                  "edit:insert-text <text>", ""),
548
549  OWLCMD_VOID_CTX("edit:cancel", owl_command_edit_cancel, 
550                  OWL_CTX_EDIT,
551                  "cancels the current command",
552                  "", ""),
553
554  OWLCMD_VOID_CTX("edit:history-next", owl_command_edit_history_next, 
555                  OWL_CTX_EDITLINE,
556                  "replaces the text with the previous history",
557                  "", ""),
558
559  OWLCMD_VOID_CTX("edit:history-prev", owl_command_edit_history_prev, 
560                  OWL_CTX_EDITLINE,
561                  "replaces the text with the previous history",
562                  "", ""),
563
564  OWLCMD_VOID_CTX("editline:done", owl_command_editline_done, 
565                  OWL_CTX_EDITLINE,
566                  "completes the command (eg, executes command being composed)",
567                  "", ""),
568
569  OWLCMD_VOID_CTX("editmulti:move-up-line", owl_editwin_key_up, 
570                  OWL_CTX_EDITMULTI,
571                  "moves the cursor up one line",
572                  "", ""),
573
574  OWLCMD_VOID_CTX("editmulti:move-down-line", owl_editwin_key_down, 
575                  OWL_CTX_EDITMULTI,
576                  "moves the cursor down one line",
577                  "", ""),
578
579  OWLCMD_VOID_CTX("editmulti:done", owl_command_editmulti_done, 
580                  OWL_CTX_EDITMULTI,
581                  "completes the command (eg, sends message being composed)",
582                  "", ""),
583
584  /****************************************************************/
585  /********************** POPLESS-SPECIFIC ************************/
586  /****************************************************************/
587
588  OWLCMD_VOID_CTX("popless:scroll-down-page", owl_viewwin_pagedown, 
589                  OWL_CTX_POPLESS,
590                  "scrolls down one page",
591                  "", ""),
592
593  OWLCMD_VOID_CTX("popless:scroll-down-line", owl_viewwin_linedown, 
594                  OWL_CTX_POPLESS,
595                  "scrolls down one line",
596                  "", ""),
597
598  OWLCMD_VOID_CTX("popless:scroll-up-page", owl_viewwin_pageup, 
599                  OWL_CTX_POPLESS,
600                  "scrolls up one page",
601                  "", ""),
602
603  OWLCMD_VOID_CTX("popless:scroll-up-line", owl_viewwin_lineup, 
604                  OWL_CTX_POPLESS,
605                  "scrolls up one line",
606                  "", ""),
607
608  OWLCMD_VOID_CTX("popless:scroll-to-top", owl_viewwin_top, 
609                  OWL_CTX_POPLESS,
610                  "scrolls to the top of the buffer",
611                  "", ""),
612
613  OWLCMD_VOID_CTX("popless:scroll-to-bottom", owl_viewwin_bottom, 
614                  OWL_CTX_POPLESS,
615                  "scrolls to the bottom of the buffer",
616                  "", ""),
617
618  OWLCMD_INT_CTX ("popless:scroll-right", owl_viewwin_right, 
619                  OWL_CTX_POPLESS,
620                  "scrolls right in the buffer",
621                  "popless:scroll-right <num-chars>", ""),
622
623  OWLCMD_INT_CTX ("popless:scroll-left", owl_viewwin_left, 
624                  OWL_CTX_POPLESS,
625                  "scrolls left in the buffer",
626                  "popless:scroll-left <num-chars>", ""),
627
628  OWLCMD_VOID_CTX("popless:quit", owl_command_popless_quit, 
629                  OWL_CTX_POPLESS,
630                  "exits the popless window",
631                  "", ""),
632
633  /* This line MUST be last! */
634  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
635
636};
637
638void owl_command_info() {
639  owl_function_info();
640}
641
642char *owl_command_help(int argc, char **argv, char *buff) {
643  if (argc!=2) {
644    owl_help();
645    return NULL;
646  }
647 
648  owl_function_help_for_command(argv[1]);
649  return NULL;
650}
651
652void owl_command_about() {
653  owl_function_about();
654}
655
656void owl_command_version() {
657  char buff[1024];
658
659  sprintf(buff, "Owl version %s", OWL_VERSION_STRING);
660  owl_function_makemsg(buff);
661}
662
663char *owl_command_next(int argc, char **argv, char *buff) {
664  char *filter=NULL;
665  int skip_deleted=0, last_if_none=0;
666  while (argc>1) {
667    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
668      skip_deleted=1;
669      argc-=1; argv+=1; 
670    } else if (argc>=1 && !strcmp(argv[1], "--last-if-none")) {
671      last_if_none=1;
672      argc-=1; argv+=1; 
673    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
674      filter = argv[2];
675      argc-=2; argv+=2; 
676    } else {
677      owl_function_makemsg("Invalid arguments to command 'next'.");
678      return(NULL);
679    }
680  }
681  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
682  return(NULL);
683}
684
685char *owl_command_prev(int argc, char **argv, char *buff) {
686  char *filter=NULL;
687  int skip_deleted=0, first_if_none=0;
688  while (argc>1) {
689    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
690      skip_deleted=1;
691      argc-=1; argv+=1; 
692    } else if (argc>=1 && !strcmp(argv[1], "--first-if-none")) {
693      first_if_none=1;
694      argc-=1; argv+=1; 
695    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
696      filter = argv[2];
697      argc-=2; argv+=2; 
698    } else {
699      owl_function_makemsg("Invalid arguments to command 'prev'.");
700      return(NULL);
701    }
702  }
703  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
704  return(NULL);
705}
706
707char *owl_command_smartnarrow(int argc, char **argv, char *buff) {
708  if (argc == 1) {
709    owl_function_smartnarrow(0);
710  } else if (argc == 2 && !strcmp(argv[1], "-i")) {
711    owl_function_smartnarrow(1);
712  } else {
713    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
714  }
715  return NULL;
716}
717
718void owl_command_expunge() {
719  owl_function_expunge();
720}
721
722void owl_command_first() {
723  owl_global_set_rightshift(&g, 0);
724  owl_function_firstmsg();
725}
726
727void owl_command_last() {
728  owl_function_lastmsg();
729}
730
731void owl_command_resize() {
732  owl_function_resize();
733}
734
735void owl_command_redisplay() {
736  owl_function_full_redisplay();
737  owl_global_set_needrefresh(&g);
738}
739
740void owl_command_shift_right() {
741  owl_function_shift_right();
742}
743
744void owl_command_shift_left() {
745  owl_function_shift_left();
746}
747
748void owl_command_unsuball() {
749  owl_function_unsuball();
750}
751
752char *owl_command_loadsubs(int argc, char **argv, char *buff) {
753  if (argc == 2) {
754    owl_function_loadsubs(argv[1]);
755  } else if (argc == 1) {
756    owl_function_loadsubs(NULL);
757  } else {
758    owl_function_makemsg("Wrong number of arguments for load-subs.");
759    return NULL;
760  }
761  return NULL;
762}
763
764void owl_command_suspend() {
765  owl_function_suspend();
766}
767
768char *owl_command_start_command(int argc, char **argv, char *buff) {
769  buff = skiptokens(buff, 1);
770  owl_function_start_command(buff);
771  return NULL;
772}
773
774char *owl_command_zaway(int argc, char **argv, char *buff) {
775 
776  if ((argc==1) ||
777      ((argc==2) && !strcmp(argv[1], "on"))) {
778    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
779    owl_function_zaway_on();
780    return NULL;
781  }
782
783  if (argc==2 && !strcmp(argv[1], "off")) {
784    owl_function_zaway_off();
785    return NULL;
786  }
787
788  if (argc==2 && !strcmp(argv[1], "toggle")) {
789    owl_function_zaway_toggle();
790    return NULL;
791  }
792
793  buff = skiptokens(buff, 1);
794  owl_global_set_zaway_msg(&g, buff);
795  owl_function_zaway_on();
796  return NULL;
797}
798
799
800char *owl_command_set(int argc, char **argv, char *buff) {
801  char *var, *val;
802  int  silent=0;
803
804  if (argc == 1) {
805    owl_function_printallvars();
806    return NULL;
807  } else if (argc == 4 && !strcmp("-q",argv[1])) {
808    silent = 1;
809    var=argv[2];
810    val=argv[3];
811  } else if (argc == 3) {
812    var=argv[1];
813    val=argv[2];
814  } else {
815    owl_function_makemsg("Wrong number of arguments for set command");
816    return NULL;
817  }
818
819  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent);
820  return NULL;
821}
822
823char *owl_command_print(int argc, char **argv, char *buff) {
824  char *var;
825  char valbuff[1024];
826
827  if (argc==1) {
828    owl_function_printallvars();
829    return NULL;
830  } else if (argc!=2) {
831    owl_function_makemsg("Wrong number of arguments for print command");
832    return NULL;
833  }
834
835  var=argv[1];
836   
837  if (0 == owl_variable_get_tostring(owl_global_get_vardict(&g), 
838                                     var, valbuff, 1024)) {
839    owl_function_makemsg("%s = '%s'", var, valbuff);
840  } else {
841    owl_function_makemsg("Unknown variable '%s'.", var);
842  }
843  return NULL;
844}
845
846
847char *owl_command_exec(int argc, char **argv, char *buff) {
848  return owl_function_exec(argc, argv, buff, 0);
849}
850
851char *owl_command_pexec(int argc, char **argv, char *buff) {
852  return owl_function_exec(argc, argv, buff, 1);
853}
854
855char *owl_command_aexec(int argc, char **argv, char *buff) {
856  return owl_function_exec(argc, argv, buff, 2);
857}
858
859char *owl_command_perl(int argc, char **argv, char *buff) {
860  return owl_function_perl(argc, argv, buff, 0);
861}
862
863char *owl_command_pperl(int argc, char **argv, char *buff) {
864  return owl_function_perl(argc, argv, buff, 1);
865}
866
867char *owl_command_aperl(int argc, char **argv, char *buff) {
868  return owl_function_perl(argc, argv, buff, 2);
869}
870
871char *owl_command_multi(int argc, char **argv, char *buff) {
872  char *lastrv = NULL, *newbuff;
873  char **commands;
874  int  ncommands, i;
875  if (argc < 2) {
876    owl_function_makemsg("Invalid arguments to 'multi' command.");   
877    return NULL;
878  }
879  newbuff = owl_strdup(buff);
880  newbuff = skiptokens(newbuff, 1);
881  if (!strcmp(argv[0], "(")) {
882    for (i=strlen(newbuff)-1; i>=0; i--) {
883      if (newbuff[i] == ')') {
884        newbuff[i] = '\0';
885        break;
886      } else if (newbuff[i] != ' ') {
887        owl_function_makemsg("Invalid arguments to 'multi' command.");   
888        owl_free(newbuff);
889        return NULL;
890      }
891    }
892  }
893  commands = atokenize(newbuff, ";", &ncommands);
894  for (i=0; i<ncommands; i++) {
895    if (lastrv) {
896      owl_free(lastrv);
897    }
898    lastrv = owl_function_command(commands[i]);
899  }
900  atokenize_free(commands, ncommands);
901  return lastrv;
902}
903
904
905char *owl_command_alias(int argc, char **argv, char *buff) {
906  if (argc < 3) {
907    owl_function_makemsg("Invalid arguments to 'alias' command.");
908    return NULL;
909  }
910  buff = skiptokens(buff, 2);
911  owl_function_command_alias(argv[1], buff);
912  return (NULL);
913}
914
915
916char *owl_command_bindkey(int argc, char **argv, char *buff) {
917  owl_keymap *km;
918  int ret;
919
920  if (argc < 5 || strcmp(argv[3], "command")) {
921    owl_function_makemsg("Usage: bindkey <keymap> <binding> command <cmd>", argv[3], argc);
922    return NULL;
923  }
924  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]);
925  if (!km) {
926    owl_function_makemsg("No such keymap '%s'", argv[1]);
927    return NULL;
928  }
929  buff = skiptokens(buff, 4);
930  ret = owl_keymap_create_binding(km, argv[2], buff, NULL, "*user*");
931  if (ret!=0) {
932    owl_function_makemsg("Unable to bind '%s' in keymap '%s' to '%s'.",
933                         argv[2], argv[1], buff);
934    return NULL;
935  }
936  return NULL;
937}
938
939void owl_command_quit() {
940  owl_function_quit();
941}
942
943char *owl_command_debug(int argc, char **argv, char *buff) {
944  if (argc<2) {
945    owl_function_makemsg("Need at least one argument to debug command");
946    return NULL;
947  }
948
949  if (!owl_global_is_debug_fast(&g)) {
950    owl_function_makemsg("Debugging is not turned on");
951    return NULL;
952  }
953
954  owl_function_debugmsg(argv[1]);
955  return NULL;
956}
957
958char *owl_command_ktest(int argc, char **argv, char *buff) {
959  owl_function_popless_text("foobar");
960  return NULL;
961}
962
963char *owl_command_zlog(int argc, char **argv, char *buff) {
964  if (argc != 2) {
965    owl_function_makemsg("Wrong number of arguments for zlog command");
966    return NULL;
967  }
968
969  if (!strcmp(argv[1], "in")) {
970    owl_function_zlog_in();
971  } else if (!strcmp(argv[1], "out")) {
972    owl_function_zlog_out();
973  } else {
974    owl_function_makemsg("Invalid subcommand for zlog");
975  }
976  return NULL;
977}
978
979
980void owl_command_zlog_out() {
981  owl_function_zlog_out();
982}
983
984
985char *owl_command_subscribe(int argc, char **argv, char *buff) {
986  char *recip="";
987
988  if (argc<3) {
989    owl_function_makemsg("Not enough arguments to the subscribe command");
990    return NULL;
991  } else if (argc>4) {
992    owl_function_makemsg("Too many arguments to the subscribe command");
993    return NULL;
994  }
995
996  if (argc==3) {
997    recip="";
998  } else if (argc==4) {
999    recip=argv[3];
1000  }
1001
1002  owl_function_subscribe(argv[1], argv[2], recip);
1003  return NULL;
1004}
1005
1006
1007char *owl_command_unsubscribe(int argc, char **argv, char *buff) {
1008  char *recip="";
1009
1010  if (argc<3) {
1011    owl_function_makemsg("Not enough arguments to the unsubscribe command");
1012    return NULL;
1013  } else if (argc>4) {
1014    owl_function_makemsg("Too many arguments to the unsubscribe command");
1015    return NULL;
1016  }
1017
1018  if (argc==3) {
1019    recip="";
1020  } else if (argc==4) {
1021    recip=argv[3];
1022  }
1023
1024  owl_function_unsubscribe(argv[1], argv[2], recip);
1025  return NULL;
1026}
1027
1028char *owl_command_echo(int argc, char **argv, char *buff) {
1029  buff = skiptokens(buff, 1);
1030  owl_function_popless_text(buff);
1031  return NULL;
1032}
1033
1034void owl_command_getsubs() {
1035  owl_function_getsubs();
1036}
1037
1038void owl_command_status() {
1039  owl_function_status();
1040}
1041
1042char *owl_command_zwrite(int argc, char **argv, char *buff) {
1043  char *tmpbuff;
1044  if (argc < 2) {
1045    owl_function_makemsg("Not enough arguments to the zwrite command.");
1046  } else {
1047    tmpbuff = owl_strdup(buff);
1048    owl_function_zwrite_setup(tmpbuff);
1049    owl_global_set_buffercommand(&g, tmpbuff);
1050    owl_free(tmpbuff);
1051  }
1052  return NULL;
1053}
1054
1055char *owl_command_reply(int argc, char **argv, char *buff) {
1056  int edit=0;
1057 
1058  if (argc==2 && !strcmp("-e", argv[1])) {
1059    edit=1;
1060    argv++;
1061  }
1062
1063  if ((argc==1) || (argc==2 && !strcmp(argv[1], "all"))) {   
1064    owl_function_reply(0, !edit);
1065  } else if ((argc==1) || (argc==2 && !strcmp(argv[1], "sender"))) {
1066    owl_function_reply(1, !edit);
1067  } else {
1068    owl_function_makemsg("Invalid arguments to the reply command.");
1069  }
1070  return NULL;
1071}
1072
1073char *owl_command_filter(int argc, char **argv, char *buff) {
1074  owl_function_create_filter(argc, argv);
1075  return NULL;
1076}
1077
1078char *owl_command_zlocate(int argc, char **argv, char *buff) {
1079  if (argc==2) {
1080    owl_function_zlocate(argv[1], 1);
1081  } else if (argc==3) {
1082    if (!strcmp(argv[1], "-d")) {
1083      owl_function_zlocate(argv[2], 0);
1084    } else {
1085      owl_function_makemsg("Invalid option to the zlocate command");
1086      return NULL;
1087    }
1088  } else {
1089    owl_function_makemsg("Wrong number of arguments for zlocate command");
1090    return NULL;
1091  }
1092  return NULL;
1093}
1094
1095char *owl_command_view(int argc, char **argv, char *buff) {
1096  if (argc<2) {
1097    owl_function_makemsg("Wrong number of arguments to view command");
1098    return NULL;
1099  }
1100
1101  if (argc == 2 && !strcmp(argv[1], "--home")) {
1102    owl_function_change_view(owl_global_get_view_home(&g));
1103    return NULL;
1104  }
1105
1106  /* is it a dynamic filter? */
1107  if (!strcmp(argv[1], "-d")) {
1108    char **myargv;
1109    int i;
1110
1111    myargv=owl_malloc((argc*sizeof(char *))+50);
1112    myargv[0]="";
1113    myargv[1]="owl-dynamic";
1114    for (i=2; i<argc; i++) {
1115      myargv[i]=argv[i];
1116    }
1117    owl_function_create_filter(argc, myargv);
1118    owl_function_change_view("owl-dynamic");
1119    owl_free(myargv);
1120    return NULL;
1121  }
1122
1123  /* otherwise it's a normal view command */
1124  if (argc>2) {
1125    owl_function_makemsg("Wrong number of arguments to view command");
1126    return NULL;
1127  }
1128  owl_function_change_view(argv[1]);
1129  return NULL;
1130}
1131
1132
1133char *owl_command_show(int argc, char **argv, char *buff) {
1134
1135  if (argc<2) {
1136    owl_function_help_for_command("show");
1137    return NULL;
1138  }
1139
1140  if (!strcmp(argv[1], "filter") || !strcmp(argv[1], "filters")) {
1141    if (argc==2) {
1142      owl_function_show_filters();
1143    } else {
1144      owl_function_show_filter(argv[2]);
1145    }
1146  } else if (argc==2 
1147             && (!strcmp(argv[1], "zpunts") || !strcmp(argv[1], "zpunted"))) {
1148    owl_function_show_zpunts();
1149  } else if (!strcmp(argv[1], "command") || !strcmp(argv[1], "commands")) {
1150    if (argc==2) {
1151      owl_function_show_commands();
1152    } else {
1153      owl_function_show_command(argv[2]);
1154    }
1155  } else if (!strcmp(argv[1], "variable") || !strcmp(argv[1], "variables")) {
1156    if (argc==2) {
1157      owl_function_show_variables();
1158    } else {
1159      owl_function_show_variable(argv[2]);
1160    }
1161  } else if (!strcmp(argv[1], "keymap") || !strcmp(argv[1], "keymaps")) {
1162    if (argc==2) {
1163      owl_function_show_keymaps();
1164    } else {
1165      owl_function_show_keymap(argv[2]);
1166    }
1167  } else if (!strcmp(argv[1], "colors")) {
1168    owl_function_show_colors();
1169  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
1170    owl_function_getsubs();
1171  } else if (!strcmp(argv[1], "terminal") || !strcmp(argv[1], "term")) {
1172    owl_function_show_term();
1173  } else if (!strcmp(argv[1], "version")) {
1174    owl_function_about();
1175  } else if (!strcmp(argv[1], "status")) {
1176    owl_function_status();
1177  } else {
1178    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
1179    return NULL;
1180  }
1181  return NULL;
1182}
1183
1184char *owl_command_viewclass(int argc, char **argv, char *buff) {
1185  if (argc!=2) {
1186    owl_function_makemsg("Wrong number of arguments to viewclass command");
1187    return NULL;
1188  }
1189  owl_function_fastclassinstfilt(argv[1], NULL);
1190  return NULL;
1191}
1192
1193char *owl_command_viewuser(int argc, char **argv, char *buff) {
1194  if (argc!=2) {
1195    owl_function_makemsg("Wrong number of arguments to viewuser command");
1196    return NULL;
1197  }
1198  owl_function_fastuserfilt(argv[1]);
1199  return NULL;
1200}
1201
1202
1203void owl_command_pop_message(void) {
1204  owl_function_curmsg_to_popwin();
1205}
1206
1207void owl_command_openurl(void) {
1208  owl_function_openurl();
1209}
1210
1211char *owl_command_delete(int argc, char **argv, char *buff) {
1212  int move_after = 1;
1213
1214  if (!strcmp(argv[1], "--no-move")) {
1215    move_after = 0;
1216    argc--; 
1217    argv++;
1218  }
1219
1220  if (argc==1) {
1221    owl_function_deletecur(move_after);
1222    return NULL;
1223  }
1224
1225  if (argc==2 && !strcmp(argv[1], "view")) {
1226    owl_function_delete_curview_msgs(1);
1227    return NULL;
1228  }
1229
1230  if (argc==2 && !strcmp(argv[1], "trash")) {
1231    owl_function_delete_automsgs();
1232    return NULL;
1233  }
1234
1235  if (argc==3 && !strcmp(argv[1], "-id")) {
1236    owl_function_delete_by_id(atoi(argv[2]), 1);
1237    return NULL;
1238  }
1239
1240  owl_function_makemsg("Unknown arguments to delete command");
1241  return NULL;
1242}
1243
1244char *owl_command_undelete(int argc, char **argv, char *buff) {
1245  int move_after = 1;
1246
1247  if (!strcmp(argv[1], "--no-move")) {
1248    move_after = 0;
1249    argc--; 
1250    argv++;
1251  }
1252
1253  if (argc==1) {
1254    owl_function_undeletecur(move_after);
1255    return NULL;
1256  }
1257
1258  if (argc==2 && !strcmp(argv[1], "view")) {
1259    owl_function_delete_curview_msgs(0);
1260    return NULL;
1261  }
1262
1263  if (argc==3 && !strcmp(argv[1], "-id")) {
1264    owl_function_delete_by_id(atoi(argv[2]), 0);
1265    return NULL;
1266  }
1267
1268  owl_function_makemsg("Unknown arguments to delete command");
1269  return NULL;
1270}
1271
1272void owl_command_beep() {
1273  owl_function_beep();
1274}
1275
1276char *owl_command_colorview(int argc, char **argv, char *buff) {
1277  if (argc!=2) {
1278    owl_function_makemsg("Wrong number of arguments to colorview command");
1279    return NULL;
1280  }
1281  owl_function_color_current_filter(argv[1]);
1282  return NULL;
1283}
1284
1285char *owl_command_zpunt(int argc, char **argv, char *buff) {
1286  owl_command_zpunt_and_zunpunt(argc, argv, 0);
1287  return NULL;
1288}
1289
1290char *owl_command_zunpunt(int argc, char **argv, char *buff) {
1291  owl_command_zpunt_and_zunpunt(argc, argv, 1);
1292  return NULL;
1293}
1294
1295
1296void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type) {
1297  /* if type==0 then zpunt
1298   * if type==1 then zunpunt
1299   */
1300  char *class, *inst, *recip;
1301
1302  class="message";
1303  inst="";
1304  recip="*";
1305
1306  if (argc==1) {
1307    /* show current punt filters */
1308    owl_function_show_zpunts();
1309    return;
1310  } else if (argc==2) {
1311    inst=argv[1];
1312  } else if (argc==3) {
1313    class=argv[1];
1314    inst=argv[2];
1315  } else if (argc==4) {
1316    class=argv[1];
1317    inst=argv[2];
1318    recip=argv[3];
1319  } else {
1320    owl_function_makemsg("Wrong number of arguments to the zpunt command");
1321    return;
1322  }
1323
1324  owl_function_zpunt(class, inst, recip, type);
1325  if (type==0) {
1326    owl_function_makemsg("<%s, %s, %s> added to punt list.", class, inst, recip);
1327  } else if (type==1) {
1328    owl_function_makemsg("<%s, %s, %s> removed from punt list.", class, inst, recip);
1329  }
1330}
1331
1332
1333/*********************************************************************/
1334/************************** EDIT SPECIFIC ****************************/
1335/*********************************************************************/
1336
1337void owl_command_edit_cancel(owl_editwin *e) {
1338  owl_function_makemsg("Command cancelled.");
1339  owl_editwin_fullclear(e);
1340  owl_global_set_needrefresh(&g);
1341  wnoutrefresh(owl_editwin_get_curswin(e));
1342  owl_global_set_typwin_inactive(&g);
1343  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE);
1344}
1345
1346void owl_command_edit_history_prev(owl_editwin *e) {
1347  owl_history *hist;
1348  char *ptr;
1349
1350  hist=owl_global_get_history(&g);
1351  if (!owl_history_is_touched(hist)) {
1352    owl_history_store(hist, owl_editwin_get_text(e));
1353    owl_history_set_partial(hist);
1354  }
1355  ptr=owl_history_get_prev(hist);
1356  if (ptr) {
1357    owl_editwin_clear(e);
1358    owl_editwin_insert_string(e, ptr);
1359    owl_editwin_redisplay(e, 0);
1360    owl_global_set_needrefresh(&g);
1361  } else {
1362    owl_function_beep();
1363  }
1364}
1365
1366void owl_command_edit_history_next(owl_editwin *e) {
1367  owl_history *hist;
1368  char *ptr;
1369
1370  hist=owl_global_get_history(&g);
1371  ptr=owl_history_get_next(hist);
1372  if (ptr) {
1373    owl_editwin_clear(e);
1374    owl_editwin_insert_string(e, ptr);
1375    owl_editwin_redisplay(e, 0);
1376    owl_global_set_needrefresh(&g);
1377  } else {
1378    owl_function_beep();
1379  }
1380}
1381
1382char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff) {
1383  buff = skiptokens(buff, 1);
1384  owl_editwin_insert_string(e, buff);
1385  owl_editwin_redisplay(e, 0);
1386  owl_global_set_needrefresh(&g); 
1387  return NULL;
1388}
1389
1390void owl_command_editline_done(owl_editwin *e) {
1391  owl_history *hist=owl_global_get_history(&g);
1392  char *rv;
1393
1394  owl_global_set_typwin_inactive(&g);
1395  owl_history_store(hist, owl_editwin_get_text(e));
1396  owl_history_reset(hist);
1397  rv = owl_function_command(owl_editwin_get_text(e));
1398 
1399  /* if we're still in ONELINE mode we can clear the buffer */
1400  if (owl_editwin_get_style(e)==OWL_EDITWIN_STYLE_ONELINE) {
1401    owl_editwin_fullclear(e);
1402  }
1403 
1404  wnoutrefresh(owl_editwin_get_curswin(e));
1405  owl_global_set_needrefresh(&g);
1406
1407  if (rv) {
1408    owl_function_makemsg("%s", rv);
1409    owl_free(rv);
1410  }
1411}
1412
1413void owl_command_editmulti_done(owl_editwin *e) {
1414  owl_function_run_buffercommand();
1415  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE);
1416  owl_editwin_fullclear(e);
1417  owl_global_set_typwin_inactive(&g);
1418  owl_global_set_needrefresh(&g);
1419  wnoutrefresh(owl_editwin_get_curswin(e));
1420}
1421
1422
1423/*********************************************************************/
1424/*********************** POPLESS SPECIFIC ****************************/
1425/*********************************************************************/
1426
1427void owl_command_popless_quit(owl_viewwin *vw) {
1428  owl_popwin_close(owl_global_get_popwin(&g));
1429  owl_viewwin_free(vw);
1430  owl_global_set_needrefresh(&g);
1431}
1432
Note: See TracBrowser for help on using the repository browser.