source: commands.c @ 65ad073

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