source: commands.c @ 6873455

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 6873455 was 6873455, checked in by James M. Kretchmar <kretch@mit.edu>, 17 years ago
Improved intro doc
  • Property mode set to 100644
File size: 65.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 [tty]\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.  If a tty is specified for zlog in\n"
54              "then the owl variable 'tty' will be set to that string, causing\n"
55              "it to be used as the zephyr location tty.\n"),
56
57  OWLCMD_VOID("quit", owl_command_quit, OWL_CTX_ANY,
58              "exit owl",
59              "",
60              "Exit owl and run any shutdown activities."),
61  OWLCMD_ALIAS("exit", "quit"),
62  OWLCMD_ALIAS("q",    "quit"),
63
64  OWLCMD_ARGS("term", owl_command_term, OWL_CTX_ANY,
65              "control the terminal",
66              "term raise\n"
67              "term deiconify\n",
68              ""),
69
70  OWLCMD_VOID("nop", owl_command_nop, OWL_CTX_ANY,
71              "do nothing",
72              "",
73              ""),
74 
75  OWLCMD_ARGS("start-command", owl_command_start_command, OWL_CTX_INTERACTIVE,
76              "prompts the user to enter a command",
77              "start-command [initial-value]",
78              "Initializes the command field to initial-value."),
79
80  OWLCMD_ARGS("start-question", owl_command_start_question, OWL_CTX_INTERACTIVE,
81              "prompts the user to enter a response to some question",
82              "start-command <question>",
83              ""),
84
85  OWLCMD_ARGS("start-password", owl_command_start_password, OWL_CTX_INTERACTIVE,
86              "prompts the user to enter a password",
87              "start-password <question>",
88              ""),
89
90  OWLCMD_ARGS("alias", owl_command_alias, OWL_CTX_ANY,
91              "creates a command alias",
92              "alias <new_command> <old_command>",
93              "Creates a command alias from new_command to old_command.\n"
94              "Any arguments passed to <new_command> will be appended to\n"
95              "<old_command> before it is executed.\n"),
96
97  OWLCMD_ARGS("bindkey", owl_command_bindkey, OWL_CTX_ANY,
98              "creates a binding in a keymap",
99              "bindkey <keymap> <keyseq> command <command>",
100              "Binds a key sequence to a command within a keymap.\n"
101              "Use 'show keymaps' to see the existing keymaps.\n"
102              "Key sequences may be things like M-C-t or NPAGE.\n"),
103
104  OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE,
105              "send a zephyr",
106              "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] [-m <message...>]",
107              "Zwrite send a zephyr to the one or more users specified.\n\n"
108              "The following options are available:\n\n"
109              "-m    Specifies a message to send without prompting.\n"
110              "      Note that this does not yet log an outgoing message.\n"
111              "      This must be the last argument.\n\n"
112              "-n    Do not send a ping message.\n\n"
113              "-C    If the message is sent to more than one user include a\n"
114              "      \"cc:\" line in the text\n\n"
115              "-c class\n"
116              "      Send to the specified zephyr class\n\n"
117              "-i instance\n"
118              "      Send to the specified zephyr instance\n\n"
119              "-r realm\n"
120              "      Send to a foreign realm\n"
121              "-O opcode\n"
122              "      Send to the specified opcode\n"),
123
124  OWLCMD_ARGS("aimwrite", owl_command_aimwrite, OWL_CTX_INTERACTIVE,
125              "send an AIM message",
126              "aimzwrite <user>",
127              "Send an aim message to a user.\n"),
128
129  OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE,
130              "send an encrypted zephyr",
131              "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [-m <message...>]\n",
132              "Behaves like zwrite but uses encryption.  Not for use with\n"
133              "personal messages\n"),
134 
135  OWLCMD_ARGS("reply", owl_command_reply,  OWL_CTX_INTERACTIVE,
136              "reply to the current message",
137              "reply [-e] [ sender | all | zaway ]",
138              "If -e is specified, the zwrite command line is presented to\n"
139              "allow editing.\n\n"
140              "If 'sender' is specified, reply to the sender.\n\n"
141              "If 'all' or no args are specified, reply publically to the\n"
142              "same class/instance for non-personal messages and to the\n"
143              "sender for personal messages.\n\n"
144              "If 'zaway' is specified, replies with a zaway message.\n\n"),
145
146  OWLCMD_ARGS("set", owl_command_set, OWL_CTX_ANY,
147              "set a variable value",
148              "set [-q] <variable> [<value>]\n"
149              "set",
150              "Set the named variable to the specified value.  If no\n"
151              "arguments are used print the value of all variables.\n"
152              "If value is unspecified and the variable is a boolean, will set it to 'on'.\n"
153              "If -q is specified, is silent and doesn't print a message.\n"),
154
155  OWLCMD_ARGS("unset", owl_command_unset, OWL_CTX_ANY,
156              "unset a boolean variable value",
157              "set [-q] <variable>\n"
158              "set",
159              "Set the named boolean variable to off.\n"
160              "If -q is specified, is silent and doesn't print a message.\n"),
161
162  OWLCMD_ARGS("print", owl_command_print, OWL_CTX_ANY,
163              "print a variable value",
164              "print <variable>\n"
165              "print",
166              "Print the value of the named variable.  If no arugments\n"
167              "are used print the value of all variables.\n"),
168
169  OWLCMD_ARGS("startup", owl_command_startup, OWL_CTX_ANY,
170              "run a command and set it to be run at every Owl startup",
171              "startup <commands> ...",
172              "Everything on the command line after the startup command\n"
173              "is executed as a normal owl command and is also placed in\n"
174              "a file so that the command is executed every time owl\n"
175              "is started"),
176
177  OWLCMD_ARGS("unstartup", owl_command_unstartup, OWL_CTX_ANY,
178              "remove a command from the list of those to be run at Owl startup",
179              "unstartup <commands> ...",
180              ""),
181
182  OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY,
183              "print the version of the running owl", "", ""),
184
185  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
186              "subscribe to a zephyr class, instance, recipient",
187              "subscribe [-t] <class> <instance> [recipient]",
188              "Subscribe the specified class and instance.  If the recipient\n"
189              "is not listed on the command line it defaults\n"
190              "to * (the wildcard recipient).  If the -t option is present\n"
191              "the subscription will only be temporary, i.e., it will not\n"
192              "be written to the subscription file and will therefore not\n"
193              "be present the next time owl is started.\n"),
194  OWLCMD_ALIAS("sub", "subscribe"),
195
196  OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
197              "unsubscribe from a zephyr class, instance, recipient",
198              "unsubscribe [-t] <class> <instance> [recipient]",
199              "Unsubscribe from the specified class and instance.  If the\n"
200              "recipient is not listed on the command line it defaults\n"
201              "to * (the wildcard recipient).  If the -t option is present\n"
202              "the unsubscription will only be temporary, i.e., it will not\n"
203              "be updated in the subscription file and will therefore not\n"
204              "be in effect the next time owl is started.\n"),
205  OWLCMD_ALIAS("unsub", "unsubscribe"),
206
207  OWLCMD_VOID("unsuball", owl_command_unsuball, OWL_CTX_ANY,
208              "unsubscribe from all zephyrs", "", ""),
209 
210  OWLCMD_VOID("getsubs", owl_command_getsubs, OWL_CTX_ANY,
211              "print all current subscriptions",
212              "getsubs",
213              "getsubs retrieves the current subscriptions from the server\n"
214              "and displays them.\n"),
215
216  OWLCMD_ARGS("dump", owl_command_dump, OWL_CTX_ANY,
217              "dump messages to a file",
218              "dump <filename>",
219              "Dump messages in current view to the named file."),
220
221  OWLCMD_ARGS("addbuddy", owl_command_addbuddy, OWL_CTX_INTERACTIVE,
222              "add a buddy to a buddylist",
223              "addbuddy aim <screenname>",
224              "Add the named buddy to your buddylist.  Eventually other protocols,\n"
225              "such as zephyr, will also be able to use this command.  For now the\n"
226              "only available protocol is 'aim', specified as the first argument."),
227
228  OWLCMD_ARGS("delbuddy", owl_command_delbuddy, OWL_CTX_INTERACTIVE,
229              "delete a buddy from a buddylist",
230              "delbuddy aim <screenname>",
231              "Delete the named buddy to your buddylist.  Eventually other protocols,\n"
232              "such as zephyr, will also be able to use this command.  For now the\n"
233              "only available protocol is 'aim', specified as the first argument.\n"),
234
235  OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE,
236              "creates a zpunt based on the current message",
237              "smartzpunt [-i | --instance]",
238              "Starts a zpunt command based on the current message's class\n"
239              "(and instance if -i is specified).\n"),
240
241  OWLCMD_ARGS("zpunt", owl_command_zpunt, OWL_CTX_ANY,
242              "suppress a given zephyr triplet",
243              "zpunt <class> <instance> [recipient]\n"
244              "zpunt <instance>",
245              "The zpunt command will supress message to the specified\n"
246              "zephyr triplet.  In the second usage messages as supressed\n"
247              "for class MESSAGE and the named instance.\n\n"
248              "SEE ALSO:  zunpunt, show zpunts\n"),
249
250  OWLCMD_ARGS("zunpunt", owl_command_zunpunt, OWL_CTX_ANY,
251              "undo a previous zpunt",
252              "zunpunt <class> <instance> [recipient]\n"
253              "zunpunt <instance>",
254              "The zunpunt command will allow messages that were previosly\n"
255              "suppressed to be received again.\n\n"
256              "SEE ALSO:  zpunt, show zpunts\n"),
257
258  OWLCMD_VOID("info", owl_command_info, OWL_CTX_INTERACTIVE,
259              "display detailed information about the current message",
260              "", ""),
261 
262  OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
263              "display help on using owl",
264              "help [command]", ""),
265
266  OWLCMD_ARGS("zlist", owl_command_zlist, OWL_CTX_INTERACTIVE,
267              "List users logged in",
268              "znol [-f file]",
269              "Print a znol-style listing of users logged in"),
270
271  OWLCMD_ARGS("alist", owl_command_alist, OWL_CTX_INTERACTIVE,
272              "List AIM users logged in",
273              "alist",
274              "Print a listing of AIM users logged in"),
275
276  OWLCMD_ARGS("blist", owl_command_blist, OWL_CTX_INTERACTIVE,
277              "List all buddies logged in",
278              "alist",
279              "Print a listing of buddies logged in, regardless of protocol."),
280
281  OWLCMD_ARGS("toggle-oneline", owl_command_toggleoneline, OWL_CTX_INTERACTIVE,
282              "Toggle the style between oneline and the default style",
283              "toggle-oneline",
284              ""),
285
286  OWLCMD_VOID("recv:shiftleft", owl_command_shift_left, OWL_CTX_INTERACTIVE,
287              "scrolls receive window to the left", "", ""),
288
289  OWLCMD_VOID("recv:shiftright", owl_command_shift_right, OWL_CTX_INTERACTIVE,
290              "scrolls receive window to the left", "", ""),
291
292  OWLCMD_VOID("recv:pagedown", owl_function_mainwin_pagedown, 
293              OWL_CTX_INTERACTIVE,
294              "scrolls down by a page", "", ""),
295
296  OWLCMD_VOID("recv:pageup", owl_function_mainwin_pageup, OWL_CTX_INTERACTIVE,
297              "scrolls up by a page", "", ""),
298
299  OWLCMD_INT ("recv:scroll", owl_function_page_curmsg, OWL_CTX_INTERACTIVE,
300              "scrolls current message up or down", 
301              "recv:scroll <numlines>", 
302              "Scrolls the current message up or down by <numlines>.\n"
303              "Scrolls up if <numlines> is negative, else scrolls down.\n"),
304
305  OWLCMD_ARGS("next", owl_command_next, OWL_CTX_INTERACTIVE,
306              "move the pointer to the next message",
307              "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]\n"
308              "          [ --smart-filter | --smart-filter-instance ]",
309              "Moves the pointer to the next message in the current view.\n"
310              "If --filter is specified, will only consider messages in\n"
311              "the filter <name>.\n"
312              "If --smart-filter or --smart-filter-instance is specified,\n"
313              "goes to the next message that is similar to the current message.\n"
314              "If --skip-deleted is specified, deleted messages will\n"
315              "be skipped.\n"
316              "If --last-if-none is specified, will stop at last message\n"
317              "in the view if no other suitable messages are found.\n"),
318  OWLCMD_ALIAS("recv:next", "next"),
319
320  OWLCMD_ARGS("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
321              "move the pointer to the previous message",
322              "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]\n"
323              "          [ --smart-filter | --smart-filter-instance ]",
324              "Moves the pointer to the next message in the current view.\n"
325              "If --filter is specified, will only consider messages in\n"
326              "the filter <name>.\n"
327              "If --smart-filter or --smart-filter-instance is specified,\n"
328              "goes to the previous message that is similar to the current message.\n"
329              "If --skip-deleted is specified, deleted messages will\n"
330              "be skipped.\n"
331              "If --first-if-none is specified, will stop at first message\n"
332              "in the view if no other suitable messages are found.\n"),
333  OWLCMD_ALIAS("recv:prev", "prev"),
334
335  OWLCMD_ALIAS("recv:next-notdel", "recv:next --skip-deleted --last-if-none"),
336  OWLCMD_ALIAS("next-notdel",      "recv:next --skip-deleted --last-if-none"),
337
338  OWLCMD_ALIAS("recv:prev-notdel", "recv:prev --skip-deleted --first-if-none"),
339  OWLCMD_ALIAS("prev-notdel",      "recv:prev --skip-deleted --first-if-none"),
340
341  OWLCMD_ALIAS("recv:next-personal", "recv:next --filter personal"),
342
343  OWLCMD_ALIAS("recv:prev-personal", "recv:prev --filter personal"),
344
345  OWLCMD_VOID("first", owl_command_first, OWL_CTX_INTERACTIVE,
346              "move the pointer to the first message", "", ""),
347  OWLCMD_ALIAS("recv:first", "first"),
348
349  OWLCMD_VOID("last", owl_command_last, OWL_CTX_INTERACTIVE,
350              "move the pointer to the last message", "", 
351              "Moves the pointer to the last message in the view.\n"
352              "If we are already at the last message in the view,\n"
353              "blanks the screen and moves just past the end of the view\n"
354              "so that new messages will appear starting at the top\n"
355              "of the screen.\n"),
356  OWLCMD_ALIAS("recv:last", "last"),
357
358  OWLCMD_VOID("expunge", owl_command_expunge, OWL_CTX_INTERACTIVE,
359              "remove all messages marked for deletion", "", ""),
360
361  OWLCMD_VOID("resize", owl_command_resize, OWL_CTX_ANY,
362              "resize the window to the current screen size", "", ""),
363
364  OWLCMD_VOID("redisplay", owl_command_redisplay, OWL_CTX_ANY,
365              "redraw the entire window", "", ""),
366
367  OWLCMD_VOID("suspend", owl_command_suspend, OWL_CTX_ANY,
368              "suspend owl", "", ""),
369
370  OWLCMD_ARGS("echo", owl_command_echo, OWL_CTX_ANY,
371              "pops up a message in popup window",
372              "echo [args .. ]\n\n", ""),
373
374  OWLCMD_ARGS("exec", owl_command_exec, OWL_CTX_ANY,
375              "run a command from the shell",
376              "exec [args .. ]", ""),
377
378  OWLCMD_ARGS("aexec", owl_command_aexec, OWL_CTX_INTERACTIVE,
379              "run a command from the shell and display in an admin message",
380              "aexec [args .. ]", ""),
381
382  OWLCMD_ARGS("pexec", owl_command_pexec, OWL_CTX_INTERACTIVE,
383              "run a command from the shell and display in a popup window",
384              "pexec [args .. ]", ""),
385
386  OWLCMD_ARGS("perl", owl_command_perl, OWL_CTX_ANY,
387              "run a perl expression",
388              "perl [args .. ]", ""),
389
390  OWLCMD_ARGS("aperl", owl_command_aperl, OWL_CTX_INTERACTIVE,
391              "run a perl expression and display in an admin message",
392              "aperl [args .. ]", ""),
393
394  OWLCMD_ARGS("pperl", owl_command_pperl, OWL_CTX_INTERACTIVE,
395              "run a perl expression and display in a popup window",
396              "pperl [args .. ]", ""),
397
398  OWLCMD_ARGS("multi", owl_command_multi, OWL_CTX_ANY,
399              "runs multiple ;-separated commands",
400              "multi <command1> ( ; <command2> )*\n",
401              "Runs multiple semicolon-separated commands in order.\n"
402              "Note quoting isn't supported here yet.\n"
403              "If you want to do something fancy, use perl.\n"),
404
405  OWLCMD_ARGS("(", owl_command_multi, OWL_CTX_ANY,
406              "runs multiple ;-separated commands",
407              "'(' <command1> ( ; <command2> )* ')'\n",
408              "Runs multiple semicolon-separated commands in order.\n"
409              "You must have a space before the final ')'\n"
410              "Note quoting isn't supported here yet.\n"
411              "If you want to do something fancy, use perl.\n"),
412
413  OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN,
414              "pops up a message in a window", "", ""),
415
416  OWLCMD_VOID("openurl", owl_command_openurl, OWL_CTX_INTERACTIVE,
417              "opens up a URL from the current message",
418              "", 
419              "Uses the 'webbrowser' variable to determine\n"
420              "which browser to use.  Currently, 'netscape'\n"
421              "and 'galeon' are supported.\n"),
422
423  OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE,
424              "running a command from the shell",
425              "zaway [ on | off | toggle ]\n"
426              "zaway <message>",
427              "Turn on or off the default zaway message.  If a message is\n"
428              "specified turn on zaway with that message\n"),
429
430  OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY,
431              "load subscriptions from a file",
432              "load-subs <file>\n", ""),
433
434  OWLCMD_ARGS("loadsubs", owl_command_loadsubs, OWL_CTX_ANY,
435              "load subscriptions from a file",
436              "loadsubs <file>\n", ""),
437
438  OWLCMD_ARGS("loadloginsubs", owl_command_loadloginsubs, OWL_CTX_ANY,
439              "load login subscriptions from a file",
440              "loadloginsubs <file>\n",
441              "The file should contain a list of usernames, one per line."),
442
443  OWLCMD_VOID("about", owl_command_about, OWL_CTX_INTERACTIVE,
444              "print information about owl", "", ""),
445
446  OWLCMD_VOID("status", owl_command_status, OWL_CTX_ANY,
447              "print status information about the running owl", "", ""),
448 
449  OWLCMD_ARGS("zlocate", owl_command_zlocate, OWL_CTX_INTERACTIVE,
450              "locate a user",
451              "zlocate [-d] <user> ...", 
452              "Performs a zlocate on one ore more users and puts the result\n"
453              "int a popwin.  If -d is specified, does not authenticate\n"
454              "the lookup request.\n"),
455 
456  OWLCMD_ARGS("filter", owl_command_filter, OWL_CTX_ANY,
457              "create a message filter",
458              "filter <name> [ -c color ] [ <expression> ... ]",
459              "The filter command creates a filter with the specified name,\n"
460              "or if one already exists it is replaced.  Example filter\n"
461              "syntax would be:\n\n"
462              "     filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ )\n\n"
463              "Valid matching fields are:\n"
464              "    sender     -  sender\n"
465              "    recipient  -  recipient\n"
466              "    class      -  zephyr class name\n"
467              "    instance   -  zephyr instance name\n"
468              "    opcode     -  zephyr opcode\n"
469              "    realm      -  zephyr realm\n"
470              "    body       -  message body\n"
471              "    type       -  message type (zephyr, aim, admin)\n"
472              "    direction  -  either 'in' 'out' or 'none'\n"
473              "    login      -  either 'login' 'logout' or 'none'\n" 
474              "Valid operators are:\n"
475              "    and\n"
476              "    or\n"
477              "    not\n"
478              "And additionally you may use the static values:\n"
479              "    true\n"
480              "    false\n"
481              "Spaces must be present before and after parenthesis.  If the\n"
482              "optional color argument is used it specifies the color that\n"
483              "messages matching this filter should be displayed in.\n\n"
484              "SEE ALSO: view, viewclass, viewuser\n"),
485
486  OWLCMD_ARGS("colorview", owl_command_colorview, OWL_CTX_INTERACTIVE,
487              "change the color on the current filter",
488              "colorview <color>",
489              "The color of messages in the current filter will be changed\n"
490              "to <color>.  Use the 'show colors' command for a list\n"
491              "of valid colors.\n\n"
492              "SEE ALSO: 'show colors'\n"),
493
494  OWLCMD_ARGS("view", owl_command_view, OWL_CTX_INTERACTIVE,
495              "view messages matching a filter",
496              "view [<viewname>] [-f <filter> | --home ] [-s <style>]\n"
497              "view <filter>\n"
498              "view -d <expression>\n"
499              "view --home",
500              "The view command sets information associated with a particular view,\n"
501              "such as view's filter or style.  In the first general usage listed\n"
502              "above <viewname> is the name of the view to be changed.  If not\n"
503              "specified the default view 'main' will be used.  A filter can be set\n"
504              "for the view by listing a named filter after the -f argument.  If\n"
505              "the --home argument is used the filter will be set to the filter named\n"
506              "by the\n 'view_home' variable.  The style can be set by listing the\n"
507              "name style after the -s argument.\n"
508              "\n"
509              "The other usages listed above are abbreivated forms that simply set\n"
510              "the filter of the current view. The -d option allows you to write a\n"
511              "filter expression that will be dynamically created by owl and then\n"
512              "applied as the view's filter\n"
513              "SEE ALSO: filter, viewclass, viewuser\n"),
514
515  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
516              "view only messages similar to the current message",
517              "smartnarrow [-i | --instance]",
518              "If the curmsg is a personal message narrow\n"
519              "   to the converstaion with that user.\n"
520              "If the curmsg is a class message, instance foo, recip *\n"
521              "   message, narrow to the class, inst.\n"
522              "If the curmsg is a class message then narrow\n"
523              "    to the class.\n"
524              "If the curmsg is a class message and '-i' is specied\n"
525              "    then narrow to the class, instance\n"),
526
527  OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE,
528              "returns the name of a filter based on the current message",
529              "smartfilter [-i | --instance]",
530              "If the curmsg is a personal message, the filter is\n"
531              "   the converstaion with that user.\n"
532              "If the curmsg is a class message, instance foo, recip *\n"
533              "   message, the filter is the class, inst.\n"
534              "If the curmsg is a class message, the filter is that class.\n"
535              "If the curmsg is a class message and '-i' is specied\n"
536              "    the filter is that <class,instance> pair\n"),
537
538  OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE,
539              "view messages matching a particular class",
540              "viewclass <class>",
541              "The viewclass command will automatically create a filter\n"
542              "matching the specified class and switch the current view\n"
543              "to it.\n\n"
544              "SEE ALSO: filter, view, viewuser\n"),
545  OWLCMD_ALIAS("vc", "viewclass"),
546
547  OWLCMD_ARGS("viewuser", owl_command_viewuser, OWL_CTX_INTERACTIVE,
548              "view messages matching a particular user",
549              "viewuser <user>",
550              "The viewuser command will automatically create a filter\n"
551              "matching the specified user and switch the current\n"
552              "view to it.\n\n"
553              "SEE ALSO: filter, view, viewclass\n"),
554  OWLCMD_ALIAS("vu", "viewuser"),
555
556  OWLCMD_ARGS("show", owl_command_show, OWL_CTX_INTERACTIVE,
557              "show information",
558              "show variables\n"
559              "show variable <variable>\n"
560              "show filters\n"
561              "show filter <filter>\n"
562              "show keymaps\n"
563              "show keymap <keymap>\n"
564              "show commands\n"
565              "show command <command>\n"
566              "show subs\n"
567              "show subscriptions\n"
568              "show zpunts\n"
569              "show colors\n"
570              "show terminal\n"
571              "show version\n"
572              "show view [<view>]\n"
573              "show status\n",
574
575              "Show colors will display a list of valid colors for the\n"
576              "     terminal."
577              "Show filters will list the names of all filters.\n"
578              "Show filter <filter> will show the definition of a particular\n"
579              "     filter.\n\n"
580              "Show zpunts will show the active zpunt filters.\n\n"
581              "Show keymaps will list the names of all keymaps.\n"
582              "Show keymap <keymap> will show the key bindings in a keymap.\n\n"
583              "Show commands will list the names of all keymaps.\n"
584              "Show command <command> will provide information about a command.\n\n"
585              "Show variables will list the names of all variables.\n\n"
586              "SEE ALSO: filter, view, alias, bindkey, help\n"),
587 
588  OWLCMD_ARGS("delete", owl_command_delete, OWL_CTX_INTERACTIVE,
589              "mark a message for deletion",
590              "delete [ -id msgid ] [ --no-move ]\n"
591              "delete view\n"
592              "delete trash",
593              "If no message id is specified the current message is marked\n"
594              "for deletion.  Otherwise the message with the given message\n"
595              "id is marked for deltion.\n"
596              "If '--no-move' is specified, don't move after deletion.\n"
597              "If 'trash' is specified, deletes all trash/auto messages\n"
598              "in the current view.\n"
599              "If 'view' is specified, deletes all messages in the\n"
600              "current view.\n"),
601  OWLCMD_ALIAS("del", "delete"),
602
603  OWLCMD_ARGS("undelete", owl_command_undelete, OWL_CTX_INTERACTIVE,
604              "unmark a message for deletion",
605              "undelete [ -id msgid ] [ --no-move ]\n"
606              "undelete view",
607              "If no message id is specified the current message is\n"
608              "unmarked for deletion.  Otherwise the message with the\n"
609              "given message id is marked for undeltion.\n"
610              "If '--no-move' is specified, don't move after deletion.\n"
611              "If 'view' is specified, undeletes all messages\n"
612              "in the current view.\n"),
613  OWLCMD_ALIAS("undel", "undelete"),
614
615  OWLCMD_VOID("beep", owl_command_beep, OWL_CTX_ANY,
616              "ring the terminal bell",
617              "beep",
618              "Beep will ring the terminal bell.\n"
619              "If the variable 'bell' has been\n"
620              "set to 'off' this command does nothing.\n"),
621
622  OWLCMD_ARGS("debug", owl_command_debug, OWL_CTX_ANY,
623              "prints a message into the debug log",
624              "debug <message>", ""),
625
626  OWLCMD_ARGS("getview", owl_command_getview, OWL_CTX_INTERACTIVE,
627              "returns the name of the filter for the current view",
628              "", ""),
629
630  OWLCMD_ARGS("getvar", owl_command_getvar, OWL_CTX_INTERACTIVE,
631              "returns the value of a variable",
632              "getvar <varname>", ""),
633
634  OWLCMD_ARGS("search", owl_command_search, OWL_CTX_INTERACTIVE,
635              "search messages for a particular string",
636              "search [-r] [<string>]",
637              "The search command will find messages that contain the\n"
638              "specified string and move the cursor there.  If no string\n"
639              "argument is supplied then the previous one is used.  By\n"
640              "default searches are done fowards, if -r is used the search\n"
641              "is performed backwards"),
642
643  OWLCMD_ARGS("aimlogin", owl_command_aimlogin, OWL_CTX_ANY,
644              "login to an AIM account",
645              "aimlogin <screenname> [<password>]\n",
646              ""),
647
648  OWLCMD_ARGS("aimlogout", owl_command_aimlogout, OWL_CTX_ANY,
649              "logout from AIM",
650              "aimlogout\n",
651              ""),
652
653
654  /****************************************************************/
655  /************************* EDIT-SPECIFIC ************************/
656  /****************************************************************/
657
658  OWLCMD_VOID_CTX("edit:move-next-word", owl_editwin_move_to_nextword, 
659                  OWL_CTX_EDIT,
660                  "moves cursor forward a word",
661                  "", ""),
662
663  OWLCMD_VOID_CTX("edit:move-prev-word", owl_editwin_move_to_previousword, 
664                  OWL_CTX_EDIT,
665                  "moves cursor backwards a word",
666                  "", ""),
667
668  OWLCMD_VOID_CTX("edit:move-to-buffer-start", owl_editwin_move_to_top,
669                  OWL_CTX_EDIT,
670                  "moves cursor to the top left (start) of the buffer",
671                  "", ""),
672
673  OWLCMD_VOID_CTX("edit:move-to-buffer-end", owl_editwin_move_to_end, 
674                  OWL_CTX_EDIT,
675                  "moves cursor to the bottom right (end) of the buffer",
676                  "", ""),
677
678  OWLCMD_VOID_CTX("edit:move-to-line-end", owl_editwin_move_to_line_end, 
679                  OWL_CTX_EDIT,
680                  "moves cursor to the end of the line",
681                  "", ""),
682
683  OWLCMD_VOID_CTX("edit:move-to-line-start", owl_editwin_move_to_line_start, 
684                  OWL_CTX_EDIT,
685                  "moves cursor to the beginning of the line",
686                  "", ""),
687
688  OWLCMD_VOID_CTX("edit:move-left", owl_editwin_key_left, 
689                  OWL_CTX_EDIT,
690                  "moves the cursor left by a character",
691                  "", ""),
692
693  OWLCMD_VOID_CTX("edit:move-right", owl_editwin_key_right,
694                  OWL_CTX_EDIT,
695                  "moves the cursor right by a character",
696                  "", ""),
697
698  OWLCMD_VOID_CTX("edit:delete-next-word", owl_editwin_delete_nextword,
699                  OWL_CTX_EDIT,
700                  "deletes the word to the right of the cursor",
701                  "", ""),
702
703  OWLCMD_VOID_CTX("edit:delete-prev-word", owl_editwin_delete_previousword,
704                  OWL_CTX_EDIT,
705                  "deletes the word to the left of the cursor",
706                  "", ""),
707
708  OWLCMD_VOID_CTX("edit:delete-prev-char", owl_editwin_backspace,
709                  OWL_CTX_EDIT,
710                  "deletes the character to the left of the cursor",
711                  "", ""),
712
713  OWLCMD_VOID_CTX("edit:delete-next-char", owl_editwin_delete_char, 
714                  OWL_CTX_EDIT,
715                  "deletes the character to the right of the cursor",
716                  "", ""),
717
718  OWLCMD_VOID_CTX("edit:delete-to-line-end", owl_editwin_delete_to_endofline,
719                  OWL_CTX_EDIT,
720                  "deletes from the cursor to the end of the line",
721                  "", ""),
722
723  OWLCMD_VOID_CTX("edit:delete-all", owl_editwin_clear, 
724                  OWL_CTX_EDIT,
725                  "deletes all of the contents of the buffer",
726                  "", ""),
727
728  OWLCMD_VOID_CTX("edit:transpose-chars", owl_editwin_transpose_chars,
729                  OWL_CTX_EDIT,
730                  "Interchange characters around point, moving forward one character.",
731                  "", ""),
732
733  OWLCMD_VOID_CTX("edit:fill-paragraph", owl_editwin_fill_paragraph, 
734                  OWL_CTX_EDIT,
735                  "fills the current paragraph to line-wrap well",
736                  "", ""),
737
738  OWLCMD_VOID_CTX("edit:recenter", owl_editwin_recenter, 
739                  OWL_CTX_EDIT,
740                  "recenters the buffer",
741                  "", ""),
742
743  OWLCMD_ARGS_CTX("edit:insert-text", owl_command_edit_insert_text, 
744                  OWL_CTX_EDIT,
745                  "inserts text into the buffer",
746                  "edit:insert-text <text>", ""),
747
748  OWLCMD_VOID_CTX("edit:cancel", owl_command_edit_cancel, 
749                  OWL_CTX_EDIT,
750                  "cancels the current command",
751                  "", ""),
752
753  OWLCMD_VOID_CTX("edit:history-next", owl_command_edit_history_next, 
754                  OWL_CTX_EDIT,
755                  "replaces the text with the previous history",
756                  "", ""),
757
758  OWLCMD_VOID_CTX("edit:history-prev", owl_command_edit_history_prev, 
759                  OWL_CTX_EDIT,
760                  "replaces the text with the previous history",
761                  "", ""),
762
763  OWLCMD_VOID_CTX("editline:done", owl_command_editline_done, 
764                  OWL_CTX_EDITLINE,
765                  "completes the command (eg, executes command being composed)",
766                  "", ""),
767
768  OWLCMD_VOID_CTX("editresponse:done", owl_command_editresponse_done, 
769                  OWL_CTX_EDITRESPONSE,
770                  "completes the response to a question",
771                  "", ""),
772
773  OWLCMD_VOID_CTX("editmulti:move-up-line", owl_editwin_key_up, 
774                  OWL_CTX_EDITMULTI,
775                  "moves the cursor up one line",
776                  "", ""),
777
778  OWLCMD_VOID_CTX("editmulti:move-down-line", owl_editwin_key_down, 
779                  OWL_CTX_EDITMULTI,
780                  "moves the cursor down one line",
781                  "", ""),
782
783  OWLCMD_VOID_CTX("editmulti:done", owl_command_editmulti_done, 
784                  OWL_CTX_EDITMULTI,
785                  "completes the command (eg, sends message being composed)",
786                  "", ""),
787
788  OWLCMD_VOID_CTX("editmulti:done-or-delete", owl_command_editmulti_done_or_delete, 
789                  OWL_CTX_EDITMULTI,
790                  "completes the command, but only if at end of message",
791                  "", 
792                  "If only whitespace is to the right of the cursor,\n"
793                  "runs 'editmulti:done'.\n"\
794                  "Otherwise runs 'edit:delete-next-char'\n"),
795
796  /****************************************************************/
797  /********************** POPLESS-SPECIFIC ************************/
798  /****************************************************************/
799
800  OWLCMD_VOID_CTX("popless:scroll-down-page", owl_viewwin_pagedown, 
801                  OWL_CTX_POPLESS,
802                  "scrolls down one page",
803                  "", ""),
804
805  OWLCMD_VOID_CTX("popless:scroll-down-line", owl_viewwin_linedown, 
806                  OWL_CTX_POPLESS,
807                  "scrolls down one line",
808                  "", ""),
809
810  OWLCMD_VOID_CTX("popless:scroll-up-page", owl_viewwin_pageup, 
811                  OWL_CTX_POPLESS,
812                  "scrolls up one page",
813                  "", ""),
814
815  OWLCMD_VOID_CTX("popless:scroll-up-line", owl_viewwin_lineup, 
816                  OWL_CTX_POPLESS,
817                  "scrolls up one line",
818                  "", ""),
819
820  OWLCMD_VOID_CTX("popless:scroll-to-top", owl_viewwin_top, 
821                  OWL_CTX_POPLESS,
822                  "scrolls to the top of the buffer",
823                  "", ""),
824
825  OWLCMD_VOID_CTX("popless:scroll-to-bottom", owl_viewwin_bottom, 
826                  OWL_CTX_POPLESS,
827                  "scrolls to the bottom of the buffer",
828                  "", ""),
829
830  OWLCMD_INT_CTX ("popless:scroll-right", owl_viewwin_right, 
831                  OWL_CTX_POPLESS,
832                  "scrolls right in the buffer",
833                  "popless:scroll-right <num-chars>", ""),
834
835  OWLCMD_INT_CTX ("popless:scroll-left", owl_viewwin_left, 
836                  OWL_CTX_POPLESS,
837                  "scrolls left in the buffer",
838                  "popless:scroll-left <num-chars>", ""),
839
840  OWLCMD_VOID_CTX("popless:quit", owl_command_popless_quit, 
841                  OWL_CTX_POPLESS,
842                  "exits the popless window",
843                  "", ""),
844
845  /* This line MUST be last! */
846  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
847
848};
849
850void owl_command_info()
851{
852  owl_function_info();
853}
854
855void owl_command_nop()
856{
857}
858
859char *owl_command_help(int argc, char **argv, char *buff)
860{
861  if (argc!=2) {
862    owl_help();
863    return NULL;
864  }
865 
866  owl_function_help_for_command(argv[1]);
867  return NULL;
868}
869
870char *owl_command_zlist(int argc, char **argv, char *buff)
871{
872  int elapsed=0, timesort=0;
873  char *file=NULL;
874
875  argc--;
876  argv++;
877  while (argc) {
878    if (!strcmp(argv[0], "-e")) {
879      elapsed=1;
880      argc--;
881      argv++;
882    } else if (!strcmp(argv[0], "-t")) {
883      timesort=1;
884      argc--;
885      argv++;
886    } else if (!strcmp(argv[0], "-f")) {
887      if (argc==1) {
888        owl_function_makemsg("zlist: -f needs an argument");
889        return(NULL);
890      }
891      file=argv[1];
892      argc-=2;
893      argv+=2;
894    } else {
895      owl_function_makemsg("zlist: unknown argument");
896      return(NULL);
897    }
898  }
899  owl_function_buddylist(0, 1, file);
900  return(NULL);
901}
902
903char *owl_command_alist()
904{
905  owl_function_buddylist(1, 0, NULL);
906  return(NULL);
907}
908
909char *owl_command_blist()
910{
911  owl_function_buddylist(1, 1, NULL);
912  return(NULL);
913}
914
915char *owl_command_toggleoneline()
916{
917  owl_function_toggleoneline();
918  return(NULL);
919}
920
921void owl_command_about()
922{
923  owl_function_about();
924}
925
926void owl_command_version()
927{
928  char buff[1024];
929
930  sprintf(buff, "Owl version %s", OWL_VERSION_STRING);
931  owl_function_makemsg(buff);
932}
933
934char *owl_command_addbuddy(int argc, char **argv, char *buff)
935{
936  if (argc!=3) {
937    owl_function_makemsg("usage: addbuddy <protocol> <buddyname>");
938    return(NULL);
939  }
940
941  if (!strcasecmp(argv[1], "aim")) {
942    if (!owl_global_is_aimloggedin(&g)) {
943      owl_function_makemsg("addbuddy: You must be logged into aim to use this command.");
944      return(NULL);
945    }
946    /*
947    owl_function_makemsg("This function is not yet operational.  Stay tuned.");
948    return(NULL);
949    */
950    owl_aim_addbuddy(argv[2]);
951    owl_function_makemsg("%s added as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
952  } else if (!strcasecmp(argv[1], "zephyr")) {
953    owl_zephyr_addbuddy(argv[2]);
954    owl_function_makemsg("%s added as zephyr buddy", argv[2]);
955  } else {
956    owl_function_makemsg("addbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
957  }
958
959  return(NULL);
960}
961
962char *owl_command_delbuddy(int argc, char **argv, char *buff)
963{
964  if (argc!=3) {
965    owl_function_makemsg("usage: delbuddy <protocol> <buddyname>");
966    return(NULL);
967  }
968
969  if (!strcasecmp(argv[1], "aim")) {
970    if (!owl_global_is_aimloggedin(&g)) {
971      owl_function_makemsg("delbuddy: You must be logged into aim to use this command.");
972      return(NULL);
973    }
974    /*
975    owl_function_makemsg("This function is not yet operational.  Stay tuned.");
976    return(NULL);
977    */
978    owl_aim_delbuddy(argv[2]);
979    owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
980  } else if (!strcasecmp(argv[1], "zephyr")) {
981    owl_zephyr_delbuddy(argv[2]);
982    owl_function_makemsg("%s deleted as zephyr buddy", argv[2]);
983  } else {
984    owl_function_makemsg("delbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
985  }
986
987
988  return(NULL);
989}
990
991char *owl_command_startup(int argc, char **argv, char *buff)
992{
993  char *ptr;
994
995  if (argc<2) {
996    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
997    return(NULL);
998  }
999
1000  ptr=strchr(buff, ' ');
1001  if (!ptr) {
1002    owl_function_makemsg("Parse error finding command for startup");
1003    return(NULL);
1004  }
1005
1006  owl_function_command(ptr+1);
1007  owl_function_addstartup(ptr+1);
1008
1009  return(NULL);
1010}
1011
1012char *owl_command_unstartup(int argc, char **argv, char *buff)
1013{
1014  char *ptr;
1015
1016  if (argc<2) {
1017    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
1018    return(NULL);
1019  }
1020
1021  ptr=strchr(buff, ' ');
1022  if (!ptr) {
1023    owl_function_makemsg("Parse error finding command for unstartup");
1024    return(NULL);
1025  }
1026
1027  owl_function_delstartup(ptr+1);
1028
1029  return(NULL);
1030}
1031
1032char *owl_command_dump(int argc, char **argv, char *buff)
1033{
1034  if (argc!=2) {
1035    owl_function_makemsg("usage: dump <filename>");
1036    return(NULL);
1037  }
1038
1039  owl_function_dump(argv[1]);
1040  return(NULL);
1041}
1042
1043char *owl_command_next(int argc, char **argv, char *buff)
1044{
1045  char *filter=NULL;
1046  int skip_deleted=0, last_if_none=0;
1047  while (argc>1) {
1048    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1049      skip_deleted=1;
1050      argc-=1; argv+=1; 
1051    } else if (argc>=1 && !strcmp(argv[1], "--last-if-none")) {
1052      last_if_none=1;
1053      argc-=1; argv+=1; 
1054    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
1055      filter = owl_strdup(argv[2]);
1056      argc-=2; argv+=2; 
1057    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1058      filter = owl_function_smartfilter(0);
1059      argc-=2; argv+=2; 
1060    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1061      filter = owl_function_smartfilter(1);
1062      argc-=2; argv+=2; 
1063    } else {
1064      owl_function_makemsg("Invalid arguments to command 'next'.");
1065      return(NULL);
1066    }
1067  }
1068  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
1069  if (filter) owl_free(filter);
1070  return(NULL);
1071}
1072
1073char *owl_command_prev(int argc, char **argv, char *buff)
1074{
1075  char *filter=NULL;
1076  int skip_deleted=0, first_if_none=0;
1077  while (argc>1) {
1078    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1079      skip_deleted=1;
1080      argc-=1; argv+=1; 
1081    } else if (argc>=1 && !strcmp(argv[1], "--first-if-none")) {
1082      first_if_none=1;
1083      argc-=1; argv+=1; 
1084    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
1085      filter = owl_strdup(argv[2]);
1086      argc-=2; argv+=2; 
1087    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1088      filter = owl_function_smartfilter(0);
1089      argc-=2; argv+=2; 
1090    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1091      filter = owl_function_smartfilter(1);
1092      argc-=2; argv+=2; 
1093   } else {
1094      owl_function_makemsg("Invalid arguments to command 'prev'.");
1095      return(NULL);
1096    }
1097  }
1098  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
1099  if (filter) owl_free(filter);
1100  return(NULL);
1101}
1102
1103char *owl_command_smartnarrow(int argc, char **argv, char *buff)
1104{
1105  char *filtname = NULL;
1106
1107  if (argc == 1) {
1108    filtname = owl_function_smartfilter(0);
1109  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1110    filtname = owl_function_smartfilter(1);
1111  } else {
1112    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1113  }
1114  if (filtname) {
1115    owl_function_change_view(filtname);
1116    owl_free(filtname);
1117  }
1118  return NULL;
1119}
1120
1121char *owl_command_smartfilter(int argc, char **argv, char *buff)
1122{
1123  char *filtname = NULL;
1124
1125  if (argc == 1) {
1126    filtname = owl_function_smartfilter(0);
1127  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1128    filtname = owl_function_smartfilter(1);
1129  } else {
1130    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1131  }
1132  return filtname;
1133}
1134
1135void owl_command_expunge()
1136{
1137  owl_function_expunge();
1138}
1139
1140void owl_command_first()
1141{
1142  owl_global_set_rightshift(&g, 0);
1143  owl_function_firstmsg();
1144}
1145
1146void owl_command_last()
1147{
1148  owl_function_lastmsg();
1149}
1150
1151void owl_command_resize()
1152{
1153  owl_function_resize();
1154}
1155
1156void owl_command_redisplay()
1157{
1158  owl_function_full_redisplay();
1159  owl_global_set_needrefresh(&g);
1160}
1161
1162void owl_command_shift_right()
1163{
1164  owl_function_shift_right();
1165}
1166
1167void owl_command_shift_left()
1168{
1169  owl_function_shift_left();
1170}
1171
1172void owl_command_unsuball()
1173{
1174  owl_function_unsuball();
1175}
1176
1177char *owl_command_loadsubs(int argc, char **argv, char *buff)
1178{
1179  if (argc == 2) {
1180    owl_function_loadsubs(argv[1]);
1181  } else if (argc == 1) {
1182    owl_function_loadsubs(NULL);
1183  } else {
1184    owl_function_makemsg("Wrong number of arguments for load-subs.");
1185    return(NULL);
1186  }
1187  return(NULL);
1188}
1189
1190
1191char *owl_command_loadloginsubs(int argc, char **argv, char *buff)
1192{
1193  if (argc == 2) {
1194    owl_function_loadloginsubs(argv[1]);
1195  } else if (argc == 1) {
1196    owl_function_loadloginsubs(NULL);
1197  } else {
1198    owl_function_makemsg("Wrong number of arguments for load-subs.");
1199    return(NULL);
1200  }
1201  return(NULL);
1202}
1203
1204void owl_command_suspend()
1205{
1206  owl_function_suspend();
1207}
1208
1209char *owl_command_start_command(int argc, char **argv, char *buff)
1210{
1211  buff = skiptokens(buff, 1);
1212  owl_function_start_command(buff);
1213  return(NULL);
1214}
1215
1216char *owl_command_start_question(int argc, char **argv, char *buff)
1217{
1218  buff = skiptokens(buff, 1);
1219  owl_function_start_question(buff);
1220  return(NULL);
1221}
1222
1223char *owl_command_start_password(int argc, char **argv, char *buff)
1224{
1225  buff = skiptokens(buff, 1);
1226  owl_function_start_password(buff);
1227  return(NULL);
1228}
1229
1230char *owl_command_zaway(int argc, char **argv, char *buff)
1231{
1232  if ((argc==1) ||
1233      ((argc==2) && !strcmp(argv[1], "on"))) {
1234    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
1235    owl_function_zaway_on();
1236    return NULL;
1237  }
1238
1239  if (argc==2 && !strcmp(argv[1], "off")) {
1240    owl_function_zaway_off();
1241    return NULL;
1242  }
1243
1244  if (argc==2 && !strcmp(argv[1], "toggle")) {
1245    owl_function_zaway_toggle();
1246    return NULL;
1247  }
1248
1249  buff = skiptokens(buff, 1);
1250  owl_global_set_zaway_msg(&g, buff);
1251  owl_function_zaway_on();
1252  return NULL;
1253}
1254
1255
1256char *owl_command_set(int argc, char **argv, char *buff)
1257{
1258  char *var, *val;
1259  int  silent=0;
1260  int requirebool=0;
1261
1262  if (argc == 1) {
1263    owl_function_printallvars();
1264    return NULL;
1265  } 
1266
1267  if (argc > 1 && !strcmp("-q",argv[1])) {
1268    silent = 1;
1269    argc--; argv++;
1270  }
1271
1272  if (argc == 2) {
1273    var=argv[1];
1274    val="on";
1275    requirebool=1;
1276  } else if (argc == 3) {
1277    var=argv[1];
1278    val=argv[2];
1279  } else {
1280    owl_function_makemsg("Wrong number of arguments for set command");
1281    return NULL;
1282  }
1283  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool);
1284  return NULL;
1285}
1286
1287char *owl_command_unset(int argc, char **argv, char *buff)
1288{
1289  char *var, *val;
1290  int  silent=0;
1291
1292  if (argc > 1 && !strcmp("-q",argv[1])) {
1293    silent = 1;
1294    argc--; argv++;
1295  }
1296  if (argc == 2) {
1297    var=argv[1];
1298    val="off";
1299  } else {
1300    owl_function_makemsg("Wrong number of arguments for unset command");
1301    return NULL;
1302  }
1303  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1);
1304  return NULL;
1305}
1306
1307char *owl_command_print(int argc, char **argv, char *buff)
1308{
1309  char *var;
1310  char valbuff[1024];
1311
1312  if (argc==1) {
1313    owl_function_printallvars();
1314    return NULL;
1315  } else if (argc!=2) {
1316    owl_function_makemsg("Wrong number of arguments for print command");
1317    return NULL;
1318  }
1319
1320  var=argv[1];
1321   
1322  if (0 == owl_variable_get_tostring(owl_global_get_vardict(&g), 
1323                                     var, valbuff, 1024)) {
1324    owl_function_makemsg("%s = '%s'", var, valbuff);
1325  } else {
1326    owl_function_makemsg("Unknown variable '%s'.", var);
1327  }
1328  return NULL;
1329}
1330
1331
1332char *owl_command_exec(int argc, char **argv, char *buff)
1333{
1334  return owl_function_exec(argc, argv, buff, 0);
1335}
1336
1337char *owl_command_pexec(int argc, char **argv, char *buff)
1338{
1339  return owl_function_exec(argc, argv, buff, 1);
1340}
1341
1342char *owl_command_aexec(int argc, char **argv, char *buff)
1343{
1344  return owl_function_exec(argc, argv, buff, 2);
1345}
1346
1347char *owl_command_perl(int argc, char **argv, char *buff)
1348{
1349  return owl_function_perl(argc, argv, buff, 0);
1350}
1351
1352char *owl_command_pperl(int argc, char **argv, char *buff)
1353{
1354  return owl_function_perl(argc, argv, buff, 1);
1355}
1356
1357char *owl_command_aperl(int argc, char **argv, char *buff)
1358{
1359  return owl_function_perl(argc, argv, buff, 2);
1360}
1361
1362char *owl_command_multi(int argc, char **argv, char *buff)
1363{
1364  char *lastrv = NULL, *newbuff;
1365  char **commands;
1366  int  ncommands, i;
1367  if (argc < 2) {
1368    owl_function_makemsg("Invalid arguments to 'multi' command.");   
1369    return NULL;
1370  }
1371  newbuff = owl_strdup(buff);
1372  newbuff = skiptokens(newbuff, 1);
1373  if (!strcmp(argv[0], "(")) {
1374    for (i=strlen(newbuff)-1; i>=0; i--) {
1375      if (newbuff[i] == ')') {
1376        newbuff[i] = '\0';
1377        break;
1378      } else if (newbuff[i] != ' ') {
1379        owl_function_makemsg("Invalid arguments to 'multi' command.");   
1380        owl_free(newbuff);
1381        return NULL;
1382      }
1383    }
1384  }
1385  commands = atokenize(newbuff, ";", &ncommands);
1386  for (i=0; i<ncommands; i++) {
1387    if (lastrv) {
1388      owl_free(lastrv);
1389    }
1390    lastrv = owl_function_command(commands[i]);
1391  }
1392  atokenize_free(commands, ncommands);
1393  return lastrv;
1394}
1395
1396
1397char *owl_command_alias(int argc, char **argv, char *buff)
1398{
1399  if (argc < 3) {
1400    owl_function_makemsg("Invalid arguments to 'alias' command.");
1401    return NULL;
1402  }
1403  buff = skiptokens(buff, 2);
1404  owl_function_command_alias(argv[1], buff);
1405  return (NULL);
1406}
1407
1408
1409char *owl_command_bindkey(int argc, char **argv, char *buff)
1410{
1411  owl_keymap *km;
1412  int ret;
1413
1414  if (argc < 5 || strcmp(argv[3], "command")) {
1415    owl_function_makemsg("Usage: bindkey <keymap> <binding> command <cmd>", argv[3], argc);
1416    return NULL;
1417  }
1418  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]);
1419  if (!km) {
1420    owl_function_makemsg("No such keymap '%s'", argv[1]);
1421    return NULL;
1422  }
1423  buff = skiptokens(buff, 4);
1424  ret = owl_keymap_create_binding(km, argv[2], buff, NULL, "*user*");
1425  if (ret!=0) {
1426    owl_function_makemsg("Unable to bind '%s' in keymap '%s' to '%s'.",
1427                         argv[2], argv[1], buff);
1428    return NULL;
1429  }
1430  return NULL;
1431}
1432
1433void owl_command_quit()
1434{
1435  owl_function_quit();
1436}
1437
1438char *owl_command_debug(int argc, char **argv, char *buff)
1439{
1440  if (argc<2) {
1441    owl_function_makemsg("Need at least one argument to debug command");
1442    return(NULL);
1443  }
1444
1445  if (!owl_global_is_debug_fast(&g)) {
1446    owl_function_makemsg("Debugging is not turned on");
1447    return(NULL);
1448  }
1449
1450  owl_function_debugmsg(argv[1]);
1451  return(NULL);
1452}
1453
1454char *owl_command_term(int argc, char **argv, char *buff)
1455{
1456  if (argc<2) {
1457    owl_function_makemsg("Need at least one argument to the term command");
1458    return(NULL);
1459  }
1460
1461  if (!strcmp(argv[1], "raise")) {
1462    owl_function_xterm_raise();
1463  } else if (!strcmp(argv[1], "deiconify")) {
1464    owl_function_xterm_deiconify();
1465  } else {
1466    owl_function_makemsg("Unknown terminal subcommand");
1467  }
1468  return(NULL);
1469}
1470
1471char *owl_command_zlog(int argc, char **argv, char *buff)
1472{
1473  if ((argc<2) || (argc>3)) {
1474    owl_function_makemsg("Wrong number of arguments for zlog command");
1475    return(NULL);
1476  }
1477
1478  if (!strcmp(argv[1], "in")) {
1479    if (argc>2) {
1480      owl_global_set_tty(&g, argv[2]);
1481    }
1482    owl_zephyr_zlog_in();
1483  } else if (!strcmp(argv[1], "out")) {
1484    if (argc!=2) {
1485      owl_function_makemsg("Wrong number of arguments for zlog command");
1486      return(NULL);
1487    }
1488    owl_zephyr_zlog_out();
1489  } else {
1490    owl_function_makemsg("Invalid subcommand for zlog");
1491  }
1492  return(NULL);
1493}
1494
1495
1496void owl_command_zlog_out(void)
1497{
1498  owl_zephyr_zlog_out();
1499}
1500
1501
1502char *owl_command_subscribe(int argc, char **argv, char *buff)
1503{
1504  char *recip="";
1505  int temp=0;
1506 
1507  if (argc<3) {
1508    owl_function_makemsg("Not enough arguments to the subscribe command");
1509    return(NULL);
1510  }
1511  argc--;
1512  argv++;
1513
1514  if (!strcmp(argv[0], "-t")) {
1515    temp=1;
1516    argc--;
1517    argv++;
1518  }
1519  if (argc<2) {
1520    owl_function_makemsg("Not enough arguments to the subscribe command");
1521    return(NULL);
1522  }
1523
1524  if (argc>3) {
1525    owl_function_makemsg("Too many arguments to the subscribe command");
1526    return(NULL);
1527  }
1528
1529  if (argc==2) {
1530    recip="";
1531  } else if (argc==3) {
1532    recip=argv[2];
1533  }
1534
1535  owl_function_subscribe(argv[0], argv[1], recip);
1536  if (!temp) {
1537    owl_zephyr_addsub(NULL, argv[0], argv[1], recip);
1538  }
1539  return(NULL);
1540}
1541
1542
1543char *owl_command_unsubscribe(int argc, char **argv, char *buff)
1544{
1545  char *recip="";
1546  int temp=0;
1547
1548  if (argc<3) {
1549    owl_function_makemsg("Not enough arguments to the unsubscribe command");
1550    return(NULL);
1551  }
1552  argc--;
1553  argv++;
1554
1555  if (!strcmp(argv[0], "-t")) {
1556    temp=1;
1557    argc--;
1558    argv++;
1559  }
1560  if (argc<2) {
1561    owl_function_makemsg("Not enough arguments to the subscribe command");
1562    return(NULL);
1563  }
1564
1565  if (argc>3) {
1566    owl_function_makemsg("Too many arguments to the unsubscribe command");
1567    return(NULL);
1568  }
1569
1570  if (argc==2) {
1571    recip="";
1572  } else if (argc==3) {
1573    recip=argv[2];
1574  }
1575
1576  owl_function_unsubscribe(argv[0], argv[1], recip);
1577  if (!temp) {
1578    owl_zephyr_delsub(NULL, argv[0], argv[1], recip);
1579  }
1580  return(NULL);
1581}
1582
1583char *owl_command_echo(int argc, char **argv, char *buff)
1584{
1585  buff = skiptokens(buff, 1);
1586  owl_function_popless_text(buff);
1587  return NULL;
1588}
1589
1590void owl_command_getsubs(void)
1591{
1592  owl_function_getsubs();
1593}
1594
1595void owl_command_status(void)
1596{
1597  owl_function_status();
1598}
1599
1600char *owl_command_zwrite(int argc, char **argv, char *buff)
1601{
1602  owl_zwrite z;
1603
1604  if (!owl_global_is_havezephyr(&g)) {
1605    owl_function_makemsg("Zephyr is not available");
1606    return(NULL);
1607  }
1608  /* check for a zwrite -m */
1609  owl_zwrite_create_from_line(&z, buff);
1610  if (owl_zwrite_is_message_set(&z)) {
1611    owl_function_zwrite(buff, NULL);
1612    owl_zwrite_free(&z);
1613    return (NULL);
1614  }
1615
1616  if (argc < 2) {
1617    owl_function_makemsg("Not enough arguments to the zwrite command.");
1618  } else {
1619    owl_function_zwrite_setup(buff);
1620  }
1621  return(NULL);
1622}
1623
1624char *owl_command_aimwrite(int argc, char **argv, char *buff)
1625{
1626  char *newbuff;
1627  int i, j;
1628 
1629  if (!owl_global_is_aimloggedin(&g)) {
1630    owl_function_makemsg("You are not logged in to AIM.");
1631    return(NULL);
1632  }
1633
1634  if (argc < 2) {
1635    owl_function_makemsg("Not enough arguments to the aimwrite command.");
1636    return(NULL);
1637  }
1638
1639  /* squish arguments together to make one screenname w/o spaces for now */
1640  newbuff=owl_malloc(strlen(buff)+5);
1641  sprintf(newbuff, "%s ", argv[0]);
1642  j=argc-1;
1643  for (i=0; i<j; i++) {
1644    strcat(newbuff, argv[i+1]);
1645  }
1646   
1647  owl_function_aimwrite_setup(newbuff);
1648  owl_free(newbuff);
1649  return(NULL);
1650}
1651
1652char *owl_command_zcrypt(int argc, char **argv, char *buff)
1653{
1654#ifdef OWL_ENABLE_ZCRYPT
1655  owl_zwrite z;
1656
1657  if (!owl_global_is_havezephyr(&g)) {
1658    owl_function_makemsg("Zephyr is not available");
1659    return(NULL);
1660  }
1661  /* check for a zcrypt -m */
1662  owl_zwrite_create_from_line(&z, buff);
1663  if (owl_zwrite_is_message_set(&z)) {
1664    owl_function_zcrypt(buff, NULL);
1665    owl_zwrite_free(&z);
1666    return (NULL);
1667  }
1668
1669  if (argc < 2) {
1670    owl_function_makemsg("Not enough arguments to the zcrypt command.");
1671  } else {
1672    owl_function_zwrite_setup(buff);
1673  }
1674  return(NULL);
1675#else
1676  owl_function_makemsg("This Owl does not support zcrypt");
1677#endif
1678}
1679
1680char *owl_command_reply(int argc, char **argv, char *buff)
1681{
1682  int edit=0;
1683 
1684  if (argc>=2 && !strcmp("-e", argv[1])) {
1685    edit=1;
1686    argv++;
1687    argc--;
1688  }
1689
1690  if ((argc==1) || (argc==2 && !strcmp(argv[1], "all"))) {   
1691    owl_function_reply(0, !edit);
1692  } else if (argc==2 && !strcmp(argv[1], "sender")) {
1693    owl_function_reply(1, !edit);
1694  } else if (argc==2 && !strcmp(argv[1], "zaway")) {
1695    owl_message *m;
1696    owl_view    *v;
1697    v = owl_global_get_current_view(&g);   
1698    m = owl_view_get_element(v, owl_global_get_curmsg(&g));
1699    if (m) owl_zephyr_zaway(m);
1700  } else {
1701    owl_function_makemsg("Invalid arguments to the reply command.");
1702  }
1703  return NULL;
1704}
1705
1706char *owl_command_filter(int argc, char **argv, char *buff)
1707{
1708  owl_function_create_filter(argc, argv);
1709  return NULL;
1710}
1711
1712char *owl_command_zlocate(int argc, char **argv, char *buff)
1713{
1714  int auth;
1715 
1716  if (argc<2) {
1717    owl_function_makemsg("Too few arguments for zlocate command");
1718    return NULL;
1719  }
1720
1721  auth=1;
1722  if (!strcmp(argv[1], "-d")) {
1723    if (argc>2) {
1724      auth=0;
1725      argc--;
1726      argv++;
1727    } else {
1728      owl_function_makemsg("Missing arguments for zlocate command");
1729      return NULL;
1730    }
1731  }
1732
1733  argc--;
1734  argv++;
1735  owl_function_zlocate(argc, argv, auth);
1736  return NULL;
1737}
1738
1739char *owl_command_view(int argc, char **argv, char *buff)
1740{
1741
1742  /* Backwards compatability has made this kind of complicated:
1743   * view [<viewname>] [-f <filter> | -d <expression> | --home ] [-s <style>]
1744   * view <filter>
1745   * view -d <expression>
1746   * view --home
1747   */
1748
1749  /* First take the 'view --home' case */
1750  if (argc == 2 && !strcmp(argv[1], "--home")) {
1751    owl_function_change_view(owl_global_get_view_home(&g));
1752    return(NULL);
1753  }
1754
1755  /* Now look for 'view <filter>' */
1756  if (argc==2) {
1757    owl_function_change_view(argv[1]);
1758    return(NULL);
1759  }
1760
1761  /* Now get 'view -d <expression>' */
1762  if (argc>=3 && !strcmp(argv[1], "-d")) {
1763    char **myargv;
1764    int i;
1765
1766    myargv=owl_malloc((argc*sizeof(char *))+50);
1767    myargv[0]="";
1768    myargv[1]="owl-dynamic";
1769    for (i=2; i<argc; i++) {
1770      myargv[i]=argv[i];
1771    }
1772    owl_function_create_filter(argc, myargv);
1773    owl_function_change_view("owl-dynamic");
1774    owl_free(myargv);
1775    return NULL;
1776  }
1777
1778  /* Finally handle the general case */
1779  if (argc<3) {
1780    owl_function_makemsg("Too few arguments to the view command.");
1781    return(NULL);
1782  }
1783  argc--;
1784  argv++;
1785  if (strcmp(argv[0], "-f") && strcmp(argv[0], "-d") && strcmp(argv[0], "--home") && strcmp(argv[0], "-s")) {
1786    if (strcmp(argv[0], "main")) {
1787      owl_function_makemsg("No view named '%s'", argv[0]);
1788      return(NULL);
1789    }
1790    argc--;
1791    argv++;
1792  }
1793  while (argc) {
1794    if (!strcmp(argv[0], "-f")) {
1795      if (argc<2) {
1796        owl_function_makemsg("Too few argments to the view command");
1797        return(NULL);
1798      }
1799      owl_function_change_view(argv[1]);
1800      argc-=2;
1801      argv+=2;
1802    } else if (!strcmp(argv[0], "--home")) {
1803      owl_function_change_view(owl_global_get_view_home(&g));
1804      argc--;
1805      argv++;
1806    } else if (!strcmp(argv[0], "-s")) {
1807      if (argc<2) {
1808        owl_function_makemsg("Too few argments to the view command");
1809        return(NULL);
1810      }
1811      owl_function_change_style(owl_global_get_current_view(&g), argv[1]);
1812      argc-=2;
1813      argv+=2;
1814    } else {
1815      owl_function_makemsg("Too few argments to the view command");
1816      return(NULL);
1817    }
1818   
1819  }
1820  return(NULL);
1821}
1822
1823
1824char *owl_command_show(int argc, char **argv, char *buff)
1825{
1826  if (argc<2) {
1827    owl_function_help_for_command("show");
1828    return NULL;
1829  }
1830
1831  if (!strcmp(argv[1], "filter") || !strcmp(argv[1], "filters")) {
1832    if (argc==2) {
1833      owl_function_show_filters();
1834    } else {
1835      owl_function_show_filter(argv[2]);
1836    }
1837  } else if (argc==2 
1838             && (!strcmp(argv[1], "zpunts") || !strcmp(argv[1], "zpunted"))) {
1839    owl_function_show_zpunts();
1840  } else if (!strcmp(argv[1], "command") || !strcmp(argv[1], "commands")) {
1841    if (argc==2) {
1842      owl_function_show_commands();
1843    } else {
1844      owl_function_show_command(argv[2]);
1845    }
1846  } else if (!strcmp(argv[1], "variable") || !strcmp(argv[1], "variables")) {
1847    if (argc==2) {
1848      owl_function_show_variables();
1849    } else {
1850      owl_function_show_variable(argv[2]);
1851    }
1852  } else if (!strcmp(argv[1], "keymap") || !strcmp(argv[1], "keymaps")) {
1853    if (argc==2) {
1854      owl_function_show_keymaps();
1855    } else {
1856      owl_function_show_keymap(argv[2]);
1857    }
1858  } else if (!strcmp(argv[1], "view")) {
1859    if (argc==3) {
1860      owl_function_show_view(argv[2]);
1861    } else {
1862      owl_function_show_view(NULL);
1863    }
1864  } else if (!strcmp(argv[1], "colors")) {
1865    owl_function_show_colors();
1866  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
1867    owl_function_getsubs();
1868  } else if (!strcmp(argv[1], "terminal") || !strcmp(argv[1], "term")) {
1869    owl_function_show_term();
1870  } else if (!strcmp(argv[1], "version")) {
1871    owl_function_about();
1872  } else if (!strcmp(argv[1], "status")) {
1873    owl_function_status();
1874  } else {
1875    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
1876    return NULL;
1877  }
1878  return NULL;
1879}
1880
1881char *owl_command_viewclass(int argc, char **argv, char *buff)
1882{
1883  char *filtname;
1884  if (argc!=2) {
1885    owl_function_makemsg("Wrong number of arguments to viewclass command");
1886    return NULL;
1887  }
1888  filtname = owl_function_classinstfilt(argv[1], NULL);
1889  owl_function_change_view(filtname);
1890  owl_free(filtname);
1891  return NULL;
1892}
1893
1894char *owl_command_viewuser(int argc, char **argv, char *buff)
1895{
1896  char *filtname;
1897  if (argc!=2) {
1898    owl_function_makemsg("Wrong number of arguments to viewuser command");
1899    return NULL;
1900  }
1901  filtname=owl_function_zuserfilt(argv[1]);
1902  owl_function_change_view(filtname);
1903  owl_free(filtname);
1904  return NULL;
1905}
1906
1907
1908void owl_command_pop_message(void)
1909{
1910  owl_function_curmsg_to_popwin();
1911}
1912
1913void owl_command_openurl(void)
1914{
1915  owl_function_openurl();
1916}
1917
1918char *owl_command_delete(int argc, char **argv, char *buff)
1919{
1920  int move_after = 1;
1921
1922  if (argc>1 && !strcmp(argv[1], "--no-move")) {
1923    move_after = 0;
1924    argc--; 
1925    argv++;
1926  }
1927
1928  if (argc==1) {
1929    owl_function_deletecur(move_after);
1930    return NULL;
1931  }
1932
1933  if (argc==2 && !strcmp(argv[1], "view")) {
1934    owl_function_delete_curview_msgs(1);
1935    return NULL;
1936  }
1937
1938  if (argc==2 && !strcmp(argv[1], "trash")) {
1939    owl_function_delete_automsgs();
1940    return NULL;
1941  }
1942
1943  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
1944    owl_function_delete_by_id(atoi(argv[2]), 1);
1945    return NULL;
1946  }
1947
1948  owl_function_makemsg("Unknown arguments to delete command");
1949  return NULL;
1950}
1951
1952char *owl_command_undelete(int argc, char **argv, char *buff)
1953{
1954  int move_after = 1;
1955
1956  if (argc>1 && !strcmp(argv[1], "--no-move")) {
1957    move_after = 0;
1958    argc--; 
1959    argv++;
1960  }
1961
1962  if (argc==1) {
1963    owl_function_undeletecur(move_after);
1964    return NULL;
1965  }
1966
1967  if (argc==2 && !strcmp(argv[1], "view")) {
1968    owl_function_delete_curview_msgs(0);
1969    return NULL;
1970  }
1971
1972  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
1973    owl_function_delete_by_id(atoi(argv[2]), 0);
1974    return NULL;
1975  }
1976
1977  owl_function_makemsg("Unknown arguments to delete command");
1978  return NULL;
1979}
1980
1981void owl_command_beep()
1982{
1983  owl_function_beep();
1984}
1985
1986char *owl_command_colorview(int argc, char **argv, char *buff)
1987{
1988  if (argc!=2) {
1989    owl_function_makemsg("Wrong number of arguments to colorview command");
1990    return NULL;
1991  }
1992  owl_function_color_current_filter(argv[1]);
1993  return NULL;
1994}
1995
1996char *owl_command_zpunt(int argc, char **argv, char *buff)
1997{
1998  owl_command_zpunt_and_zunpunt(argc, argv, 0);
1999  return NULL;
2000}
2001
2002char *owl_command_zunpunt(int argc, char **argv, char *buff)
2003{
2004  owl_command_zpunt_and_zunpunt(argc, argv, 1);
2005  return NULL;
2006}
2007
2008
2009void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type)
2010{
2011  /* if type==0 then zpunt
2012   * if type==1 then zunpunt
2013   */
2014  char *class, *inst, *recip;
2015
2016  class="message";
2017  inst="";
2018  recip="*";
2019
2020  if (argc==1) {
2021    /* show current punt filters */
2022    owl_function_show_zpunts();
2023    return;
2024  } else if (argc==2) {
2025    inst=argv[1];
2026  } else if (argc==3) {
2027    class=argv[1];
2028    inst=argv[2];
2029  } else if (argc==4) {
2030    class=argv[1];
2031    inst=argv[2];
2032    recip=argv[3];
2033  } else {
2034    owl_function_makemsg("Wrong number of arguments to the zpunt command");
2035    return;
2036  }
2037
2038  owl_function_zpunt(class, inst, recip, type);
2039  if (type==0) {
2040    owl_function_makemsg("<%s, %s, %s> added to punt list.", class, inst, recip);
2041  } else if (type==1) {
2042    owl_function_makemsg("<%s, %s, %s> removed from punt list.", class, inst, recip);
2043  }
2044}
2045
2046char *owl_command_smartzpunt(int argc, char **argv, char *buff)
2047{
2048  if (argc == 1) {
2049    owl_function_smartzpunt(0);
2050  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
2051    owl_function_smartzpunt(1);
2052  } else {
2053    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
2054  }
2055  return NULL;
2056}
2057
2058char *owl_command_getview(int argc, char **argv, char *buff)
2059{
2060  char *filtname;
2061  if (argc != 1) {
2062    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2063    return NULL;
2064  }
2065  filtname = owl_view_get_filtname(owl_global_get_current_view(&g));
2066  if (filtname) filtname = owl_strdup(filtname);
2067  return filtname;
2068}
2069
2070char *owl_command_getvar(int argc, char **argv, char *buff)
2071{
2072  char tmpbuff[1024];
2073  if (argc != 2) {
2074    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2075    return NULL;
2076  }
2077  if (owl_variable_get_tostring(owl_global_get_vardict(&g), 
2078                                argv[1], tmpbuff, 1024)) {
2079    return NULL;
2080  }
2081  return owl_strdup(tmpbuff); 
2082}
2083
2084char *owl_command_search(int argc, char **argv, char *buff)
2085{
2086  int direction;
2087  char *buffstart;
2088
2089  direction=OWL_DIRECTION_DOWNWARDS;
2090  buffstart=skiptokens(buff, 1);
2091  if (argc>1 && !strcmp(argv[1], "-r")) {
2092    direction=OWL_DIRECTION_UPWARDS;
2093    buffstart=skiptokens(buff, 2);
2094  }
2095   
2096  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
2097    owl_function_search_continue(direction);
2098  } else {
2099    owl_function_search_start(buffstart, direction);
2100  }
2101 
2102  return(NULL);
2103}
2104
2105char *owl_command_aimlogin(int argc, char **argv, char *buff)
2106{
2107  int ret;
2108 
2109  if ((argc<2) || (argc>3)) {
2110    owl_function_makemsg("Wrong number of arguments to aimlogin command");
2111    return(NULL);
2112  }
2113
2114  /* if we get two arguments, ask for the password */
2115  if (argc==2) {
2116    owl_global_set_buffercommand(&g, buff);
2117    owl_function_start_password("Password: ");
2118    return(NULL);
2119  }
2120
2121  /* clear the buddylist */
2122  owl_buddylist_clear(owl_global_get_buddylist(&g));
2123
2124  /* try to login */
2125  ret=owl_aim_login(argv[1], argv[2]);
2126  if (ret) owl_function_makemsg("Warning: login for %s failed.\n");
2127
2128  /* this is a test */
2129  return(NULL);
2130}
2131
2132char *owl_command_aimlogout(int argc, char **argv, char *buff)
2133{
2134  /* clear the buddylist */
2135  owl_buddylist_clear(owl_global_get_buddylist(&g));
2136
2137  owl_aim_logout();
2138  return(NULL);
2139}
2140
2141/*********************************************************************/
2142/************************** EDIT SPECIFIC ****************************/
2143/*********************************************************************/
2144
2145void owl_command_edit_cancel(owl_editwin *e)
2146{
2147  owl_history *hist;
2148
2149  owl_function_makemsg("Command cancelled.");
2150
2151  hist=owl_editwin_get_history(e);
2152  owl_history_store(hist, owl_editwin_get_text(e));
2153  owl_history_reset(hist);
2154
2155  owl_editwin_fullclear(e);
2156  owl_global_set_needrefresh(&g);
2157  wnoutrefresh(owl_editwin_get_curswin(e));
2158  owl_global_set_typwin_inactive(&g);
2159  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2160
2161  owl_function_activate_keymap("recv");
2162}
2163
2164void owl_command_edit_history_prev(owl_editwin *e)
2165{
2166  owl_history *hist;
2167  char *ptr;
2168
2169  hist=owl_editwin_get_history(e);
2170  if (!owl_history_is_touched(hist)) {
2171    owl_history_store(hist, owl_editwin_get_text(e));
2172    owl_history_set_partial(hist);
2173  }
2174  ptr=owl_history_get_prev(hist);
2175  if (ptr) {
2176    owl_editwin_clear(e);
2177    owl_editwin_insert_string(e, ptr);
2178    owl_editwin_redisplay(e, 0);
2179    owl_global_set_needrefresh(&g);
2180  } else {
2181    owl_function_beep();
2182  }
2183}
2184
2185void owl_command_edit_history_next(owl_editwin *e)
2186{
2187  owl_history *hist;
2188  char *ptr;
2189
2190  hist=owl_editwin_get_history(e);
2191  ptr=owl_history_get_next(hist);
2192  if (ptr) {
2193    owl_editwin_clear(e);
2194    owl_editwin_insert_string(e, ptr);
2195    owl_editwin_redisplay(e, 0);
2196    owl_global_set_needrefresh(&g);
2197  } else {
2198    owl_function_beep();
2199  }
2200}
2201
2202char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff)
2203{
2204  buff = skiptokens(buff, 1);
2205  owl_editwin_insert_string(e, buff);
2206  owl_editwin_redisplay(e, 0);
2207  owl_global_set_needrefresh(&g); 
2208  return NULL;
2209}
2210
2211void owl_command_editline_done(owl_editwin *e)
2212{
2213  owl_history *hist=owl_editwin_get_history(e);
2214  char *rv, *cmd;
2215
2216  owl_history_store(hist, owl_editwin_get_text(e));
2217  owl_history_reset(hist);
2218  owl_global_set_typwin_inactive(&g);
2219  cmd = owl_strdup(owl_editwin_get_text(e));
2220  owl_editwin_fullclear(e);
2221  rv = owl_function_command(cmd);
2222  owl_free(cmd);
2223
2224  wnoutrefresh(owl_editwin_get_curswin(e));
2225  owl_global_set_needrefresh(&g);
2226
2227  if (rv) {
2228    owl_function_makemsg("%s", rv);
2229    owl_free(rv);
2230  }
2231}
2232
2233
2234void owl_command_editresponse_done(owl_editwin *e)
2235{
2236  owl_global_set_response(&g, owl_editwin_get_text(e));
2237
2238  owl_global_set_typwin_inactive(&g);
2239  owl_editwin_fullclear(e);
2240  wnoutrefresh(owl_editwin_get_curswin(e));
2241  owl_global_set_needrefresh(&g);
2242
2243  owl_function_run_buffercommand();
2244}
2245
2246
2247void owl_command_editmulti_done(owl_editwin *e)
2248{
2249  owl_history *hist=owl_editwin_get_history(e);
2250
2251  owl_history_store(hist, owl_editwin_get_text(e));
2252  owl_history_reset(hist);
2253
2254  owl_function_run_buffercommand();
2255  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2256  owl_editwin_fullclear(e);
2257  owl_global_set_typwin_inactive(&g);
2258  owl_global_set_needrefresh(&g);
2259  wnoutrefresh(owl_editwin_get_curswin(e));
2260}
2261
2262void owl_command_editmulti_done_or_delete(owl_editwin *e)
2263{
2264  if (owl_editwin_is_at_end(e)) {
2265    owl_command_editmulti_done(e);
2266  } else {
2267    owl_editwin_delete_char(e);
2268  }
2269}
2270
2271
2272/*********************************************************************/
2273/*********************** POPLESS SPECIFIC ****************************/
2274/*********************************************************************/
2275
2276void owl_command_popless_quit(owl_viewwin *vw)
2277{
2278  owl_popwin_close(owl_global_get_popwin(&g));
2279  owl_viewwin_free(vw);
2280  owl_global_set_needrefresh(&g);
2281}
Note: See TracBrowser for help on using the repository browser.