source: commands.c @ d36f2cb

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