source: commands.c @ 7360fab

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