source: commands.c @ 38cf544c

barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 38cf544c was 38cf544c, checked in by James M. Kretchmar <kretch@mit.edu>, 21 years ago
Added the 'startup' and 'unstartup' commands The $HOME/.owl directory is created on startup if it does not exist
  • Property mode set to 100644
File size: 61.5 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 (!owl_global_is_aimloggedin(&g)) {
885    owl_function_makemsg("addbuddy: You must be logged into aim to use this command.");
886    return(NULL);
887  }
888
889  if (argc!=3) {
890    owl_function_makemsg("usage: addbuddy <protocol> <buddyname>");
891    return(NULL);
892  }
893
894  if (strcasecmp(argv[1], "aim")) {
895    owl_function_makemsg("addbuddy: currently the only supported protocol is 'aim'");
896    return(NULL);
897  }
898
899  owl_aim_addbuddy(argv[2]);
900  owl_function_makemsg("%s added as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
901
902  return(NULL);
903}
904
905char *owl_command_delbuddy(int argc, char **argv, char *buff)
906{
907  if (!owl_global_is_aimloggedin(&g)) {
908    owl_function_makemsg("delbuddy: You must be logged into aim to use this command.");
909    return(NULL);
910  }
911
912  if (argc!=3) {
913    owl_function_makemsg("usage: delbuddy <protocol> <buddyname>");
914    return(NULL);
915  }
916
917  if (strcasecmp(argv[1], "aim")) {
918    owl_function_makemsg("delbuddy: currently the only supported protocol is 'aim'");
919    return(NULL);
920  }
921
922  owl_aim_delbuddy(argv[2]);
923  owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
924
925  return(NULL);
926}
927
928char *owl_command_startup(int argc, char **argv, char *buff)
929{
930  char *ptr;
931
932  if (argc<2) {
933    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
934    return(NULL);
935  }
936
937  /* we'll be pedantic here, just in case this command gets another name
938   *  (or is aliased) start after the first space on the line
939   */
940  ptr=strchr(buff, ' ');
941  if (!ptr) {
942    owl_function_makemsg("Parse error finding command for startup");
943    return(NULL);
944  }
945
946  owl_function_command(ptr+1);
947  owl_function_addstartup(ptr+1);
948
949  return(NULL);
950}
951
952char *owl_command_unstartup(int argc, char **argv, char *buff)
953{
954  char *ptr;
955
956  if (argc<2) {
957    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
958    return(NULL);
959  }
960
961  /* we'll be pedantic here, just in case this command gets another name
962   *  (or is aliased) start after the first space on the line
963   */
964  ptr=strchr(buff, ' ');
965  if (!ptr) {
966    owl_function_makemsg("Parse error finding command for unstartup");
967    return(NULL);
968  }
969
970  owl_function_delstartup(ptr+1);
971
972  return(NULL);
973}
974
975char *owl_command_dump(int argc, char **argv, char *buff) {
976  if (argc!=2) {
977    owl_function_makemsg("usage: dump <filename>");
978    return(NULL);
979  }
980
981  owl_function_dump(argv[1]);
982  return(NULL);
983}
984
985char *owl_command_next(int argc, char **argv, char *buff) {
986  char *filter=NULL;
987  int skip_deleted=0, last_if_none=0;
988  while (argc>1) {
989    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
990      skip_deleted=1;
991      argc-=1; argv+=1; 
992    } else if (argc>=1 && !strcmp(argv[1], "--last-if-none")) {
993      last_if_none=1;
994      argc-=1; argv+=1; 
995    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
996      filter = owl_strdup(argv[2]);
997      argc-=2; argv+=2; 
998    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
999      filter = owl_function_smartfilter(0);
1000      argc-=2; argv+=2; 
1001    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1002      filter = owl_function_smartfilter(1);
1003      argc-=2; argv+=2; 
1004    } else {
1005      owl_function_makemsg("Invalid arguments to command 'next'.");
1006      return(NULL);
1007    }
1008  }
1009  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
1010  if (filter) owl_free(filter);
1011  return(NULL);
1012}
1013
1014char *owl_command_prev(int argc, char **argv, char *buff) {
1015  char *filter=NULL;
1016  int skip_deleted=0, first_if_none=0;
1017  while (argc>1) {
1018    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1019      skip_deleted=1;
1020      argc-=1; argv+=1; 
1021    } else if (argc>=1 && !strcmp(argv[1], "--first-if-none")) {
1022      first_if_none=1;
1023      argc-=1; argv+=1; 
1024    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
1025      filter = owl_strdup(argv[2]);
1026      argc-=2; argv+=2; 
1027    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1028      filter = owl_function_smartfilter(0);
1029      argc-=2; argv+=2; 
1030    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1031      filter = owl_function_smartfilter(1);
1032      argc-=2; argv+=2; 
1033   } else {
1034      owl_function_makemsg("Invalid arguments to command 'prev'.");
1035      return(NULL);
1036    }
1037  }
1038  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
1039  if (filter) owl_free(filter);
1040  return(NULL);
1041}
1042
1043char *owl_command_smartnarrow(int argc, char **argv, char *buff) {
1044  char *filtname = NULL;
1045
1046  if (argc == 1) {
1047    filtname = owl_function_smartfilter(0);
1048  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1049    filtname = owl_function_smartfilter(1);
1050  } else {
1051    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1052  }
1053  if (filtname) {
1054    owl_function_change_view(filtname);
1055    owl_free(filtname);
1056  }
1057  return NULL;
1058}
1059
1060char *owl_command_smartfilter(int argc, char **argv, char *buff) {
1061  char *filtname = NULL;
1062
1063  if (argc == 1) {
1064    filtname = owl_function_smartfilter(0);
1065  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1066    filtname = owl_function_smartfilter(1);
1067  } else {
1068    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1069  }
1070  return filtname;
1071}
1072
1073void owl_command_expunge() {
1074  owl_function_expunge();
1075}
1076
1077void owl_command_first() {
1078  owl_global_set_rightshift(&g, 0);
1079  owl_function_firstmsg();
1080}
1081
1082void owl_command_last() {
1083  owl_function_lastmsg();
1084}
1085
1086void owl_command_resize() {
1087  owl_function_resize();
1088}
1089
1090void owl_command_redisplay() {
1091  owl_function_full_redisplay();
1092  owl_global_set_needrefresh(&g);
1093}
1094
1095void owl_command_shift_right() {
1096  owl_function_shift_right();
1097}
1098
1099void owl_command_shift_left() {
1100  owl_function_shift_left();
1101}
1102
1103void owl_command_unsuball() {
1104  owl_function_unsuball();
1105}
1106
1107char *owl_command_loadsubs(int argc, char **argv, char *buff) {
1108  if (argc == 2) {
1109    owl_function_loadsubs(argv[1]);
1110  } else if (argc == 1) {
1111    owl_function_loadsubs(NULL);
1112  } else {
1113    owl_function_makemsg("Wrong number of arguments for load-subs.");
1114    return(NULL);
1115  }
1116  return(NULL);
1117}
1118
1119
1120char *owl_command_loadloginsubs(int argc, char **argv, char *buff) {
1121  if (argc == 2) {
1122    owl_function_loadloginsubs(argv[1]);
1123  } else if (argc == 1) {
1124    owl_function_loadloginsubs(NULL);
1125  } else {
1126    owl_function_makemsg("Wrong number of arguments for load-subs.");
1127    return(NULL);
1128  }
1129  return(NULL);
1130}
1131
1132void owl_command_suspend() {
1133  owl_function_suspend();
1134}
1135
1136char *owl_command_start_command(int argc, char **argv, char *buff) {
1137  buff = skiptokens(buff, 1);
1138  owl_function_start_command(buff);
1139  return NULL;
1140}
1141
1142char *owl_command_zaway(int argc, char **argv, char *buff) {
1143 
1144  if ((argc==1) ||
1145      ((argc==2) && !strcmp(argv[1], "on"))) {
1146    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
1147    owl_function_zaway_on();
1148    return NULL;
1149  }
1150
1151  if (argc==2 && !strcmp(argv[1], "off")) {
1152    owl_function_zaway_off();
1153    return NULL;
1154  }
1155
1156  if (argc==2 && !strcmp(argv[1], "toggle")) {
1157    owl_function_zaway_toggle();
1158    return NULL;
1159  }
1160
1161  buff = skiptokens(buff, 1);
1162  owl_global_set_zaway_msg(&g, buff);
1163  owl_function_zaway_on();
1164  return NULL;
1165}
1166
1167
1168char *owl_command_set(int argc, char **argv, char *buff) {
1169  char *var, *val;
1170  int  silent=0;
1171  int requirebool=0;
1172
1173  if (argc == 1) {
1174    owl_function_printallvars();
1175    return NULL;
1176  } 
1177
1178  if (argc > 1 && !strcmp("-q",argv[1])) {
1179    silent = 1;
1180    argc--; argv++;
1181  }
1182
1183  if (argc == 2) {
1184    var=argv[1];
1185    val="on";
1186    requirebool=1;
1187  } else if (argc == 3) {
1188    var=argv[1];
1189    val=argv[2];
1190  } else {
1191    owl_function_makemsg("Wrong number of arguments for set command");
1192    return NULL;
1193  }
1194  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool);
1195  return NULL;
1196}
1197
1198char *owl_command_unset(int argc, char **argv, char *buff) {
1199  char *var, *val;
1200  int  silent=0;
1201
1202  if (argc > 1 && !strcmp("-q",argv[1])) {
1203    silent = 1;
1204    argc--; argv++;
1205  }
1206  if (argc == 2) {
1207    var=argv[1];
1208    val="off";
1209  } else {
1210    owl_function_makemsg("Wrong number of arguments for unset command");
1211    return NULL;
1212  }
1213  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1);
1214  return NULL;
1215}
1216
1217char *owl_command_print(int argc, char **argv, char *buff) {
1218  char *var;
1219  char valbuff[1024];
1220
1221  if (argc==1) {
1222    owl_function_printallvars();
1223    return NULL;
1224  } else if (argc!=2) {
1225    owl_function_makemsg("Wrong number of arguments for print command");
1226    return NULL;
1227  }
1228
1229  var=argv[1];
1230   
1231  if (0 == owl_variable_get_tostring(owl_global_get_vardict(&g), 
1232                                     var, valbuff, 1024)) {
1233    owl_function_makemsg("%s = '%s'", var, valbuff);
1234  } else {
1235    owl_function_makemsg("Unknown variable '%s'.", var);
1236  }
1237  return NULL;
1238}
1239
1240
1241char *owl_command_exec(int argc, char **argv, char *buff) {
1242  return owl_function_exec(argc, argv, buff, 0);
1243}
1244
1245char *owl_command_pexec(int argc, char **argv, char *buff) {
1246  return owl_function_exec(argc, argv, buff, 1);
1247}
1248
1249char *owl_command_aexec(int argc, char **argv, char *buff) {
1250  return owl_function_exec(argc, argv, buff, 2);
1251}
1252
1253char *owl_command_perl(int argc, char **argv, char *buff) {
1254  return owl_function_perl(argc, argv, buff, 0);
1255}
1256
1257char *owl_command_pperl(int argc, char **argv, char *buff) {
1258  return owl_function_perl(argc, argv, buff, 1);
1259}
1260
1261char *owl_command_aperl(int argc, char **argv, char *buff) {
1262  return owl_function_perl(argc, argv, buff, 2);
1263}
1264
1265char *owl_command_multi(int argc, char **argv, char *buff) {
1266  char *lastrv = NULL, *newbuff;
1267  char **commands;
1268  int  ncommands, i;
1269  if (argc < 2) {
1270    owl_function_makemsg("Invalid arguments to 'multi' command.");   
1271    return NULL;
1272  }
1273  newbuff = owl_strdup(buff);
1274  newbuff = skiptokens(newbuff, 1);
1275  if (!strcmp(argv[0], "(")) {
1276    for (i=strlen(newbuff)-1; i>=0; i--) {
1277      if (newbuff[i] == ')') {
1278        newbuff[i] = '\0';
1279        break;
1280      } else if (newbuff[i] != ' ') {
1281        owl_function_makemsg("Invalid arguments to 'multi' command.");   
1282        owl_free(newbuff);
1283        return NULL;
1284      }
1285    }
1286  }
1287  commands = atokenize(newbuff, ";", &ncommands);
1288  for (i=0; i<ncommands; i++) {
1289    if (lastrv) {
1290      owl_free(lastrv);
1291    }
1292    lastrv = owl_function_command(commands[i]);
1293  }
1294  atokenize_free(commands, ncommands);
1295  return lastrv;
1296}
1297
1298
1299char *owl_command_alias(int argc, char **argv, char *buff) {
1300  if (argc < 3) {
1301    owl_function_makemsg("Invalid arguments to 'alias' command.");
1302    return NULL;
1303  }
1304  buff = skiptokens(buff, 2);
1305  owl_function_command_alias(argv[1], buff);
1306  return (NULL);
1307}
1308
1309
1310char *owl_command_bindkey(int argc, char **argv, char *buff) {
1311  owl_keymap *km;
1312  int ret;
1313
1314  if (argc < 5 || strcmp(argv[3], "command")) {
1315    owl_function_makemsg("Usage: bindkey <keymap> <binding> command <cmd>", argv[3], argc);
1316    return NULL;
1317  }
1318  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]);
1319  if (!km) {
1320    owl_function_makemsg("No such keymap '%s'", argv[1]);
1321    return NULL;
1322  }
1323  buff = skiptokens(buff, 4);
1324  ret = owl_keymap_create_binding(km, argv[2], buff, NULL, "*user*");
1325  if (ret!=0) {
1326    owl_function_makemsg("Unable to bind '%s' in keymap '%s' to '%s'.",
1327                         argv[2], argv[1], buff);
1328    return NULL;
1329  }
1330  return NULL;
1331}
1332
1333void owl_command_quit() {
1334  owl_function_quit();
1335}
1336
1337char *owl_command_debug(int argc, char **argv, char *buff) {
1338  if (argc<2) {
1339    owl_function_makemsg("Need at least one argument to debug command");
1340    return(NULL);
1341  }
1342
1343  if (!owl_global_is_debug_fast(&g)) {
1344    owl_function_makemsg("Debugging is not turned on");
1345    return(NULL);
1346  }
1347
1348  owl_function_debugmsg(argv[1]);
1349  return(NULL);
1350}
1351
1352char *owl_command_term(int argc, char **argv, char *buff) {
1353  if (argc<2) {
1354    owl_function_makemsg("Need at least one argument to the term command");
1355    return(NULL);
1356  }
1357
1358  if (!strcmp(argv[1], "raise")) {
1359    owl_function_xterm_raise();
1360  } else if (!strcmp(argv[1], "deiconify")) {
1361    owl_function_xterm_deiconify();
1362  } else {
1363    owl_function_makemsg("Unknown terminal subcommand");
1364  }
1365  return(NULL);
1366}
1367
1368char *owl_command_zlog(int argc, char **argv, char *buff) {
1369  if ((argc<2) || (argc>3)) {
1370    owl_function_makemsg("Wrong number of arguments for zlog command");
1371    return(NULL);
1372  }
1373
1374  if (!strcmp(argv[1], "in")) {
1375    if (argc>2) {
1376      owl_global_set_tty(&g, argv[2]);
1377    }
1378    owl_zephyr_zlog_in();
1379  } else if (!strcmp(argv[1], "out")) {
1380    if (argc!=2) {
1381      owl_function_makemsg("Wrong number of arguments for zlog command");
1382      return(NULL);
1383    }
1384    owl_zephyr_zlog_out();
1385  } else {
1386    owl_function_makemsg("Invalid subcommand for zlog");
1387  }
1388  return(NULL);
1389}
1390
1391
1392void owl_command_zlog_out(void) {
1393  owl_zephyr_zlog_out();
1394}
1395
1396
1397char *owl_command_subscribe(int argc, char **argv, char *buff) {
1398  char *recip="";
1399  int temp=0;
1400 
1401  if (argc<3) {
1402    owl_function_makemsg("Not enough arguments to the subscribe command");
1403    return(NULL);
1404  }
1405  argc--;
1406  argv++;
1407
1408  if (!strcmp(argv[0], "-t")) {
1409    temp=1;
1410    argc--;
1411    argv++;
1412  }
1413  if (argc<2) {
1414    owl_function_makemsg("Not enough arguments to the subscribe command");
1415    return(NULL);
1416  }
1417
1418  if (argc>3) {
1419    owl_function_makemsg("Too many arguments to the subscribe command");
1420    return(NULL);
1421  }
1422
1423  if (argc==2) {
1424    recip="";
1425  } else if (argc==3) {
1426    recip=argv[2];
1427  }
1428
1429  owl_function_subscribe(argv[0], argv[1], recip);
1430  if (!temp) {
1431    owl_zephyr_addsub(NULL, argv[0], argv[1], recip);
1432  }
1433  return(NULL);
1434}
1435
1436
1437char *owl_command_unsubscribe(int argc, char **argv, char *buff) {
1438  char *recip="";
1439  int temp=0;
1440
1441  if (argc<3) {
1442    owl_function_makemsg("Not enough arguments to the unsubscribe command");
1443    return(NULL);
1444  }
1445  argc--;
1446  argv++;
1447
1448  if (!strcmp(argv[0], "-t")) {
1449    temp=1;
1450    argc--;
1451    argv++;
1452  }
1453  if (argc<2) {
1454    owl_function_makemsg("Not enough arguments to the subscribe command");
1455    return(NULL);
1456  }
1457
1458  if (argc>3) {
1459    owl_function_makemsg("Too many arguments to the unsubscribe command");
1460    return(NULL);
1461  }
1462
1463  if (argc==2) {
1464    recip="";
1465  } else if (argc==3) {
1466    recip=argv[2];
1467  }
1468
1469  owl_function_unsubscribe(argv[0], argv[1], recip);
1470  if (!temp) {
1471    owl_zephyr_delsub(NULL, argv[0], argv[1], recip);
1472  }
1473  return(NULL);
1474}
1475
1476char *owl_command_echo(int argc, char **argv, char *buff) {
1477  buff = skiptokens(buff, 1);
1478  owl_function_popless_text(buff);
1479  return NULL;
1480}
1481
1482void owl_command_getsubs() {
1483  owl_function_getsubs();
1484}
1485
1486void owl_command_status() {
1487  owl_function_status();
1488}
1489
1490char *owl_command_zwrite(int argc, char **argv, char *buff) {
1491  char *tmpbuff, *pos, *cmd, *msg;
1492
1493  /* check for a zwrite -m */
1494  for (pos = buff; *pos; pos = skiptokens(pos, 1)) {
1495    if (!strncmp(pos, "-m ", 3)) {
1496      cmd = owl_strdup(buff);
1497      msg = cmd+(pos-buff);
1498      *msg = '\0';
1499      msg += 3;
1500      owl_zwrite_create_and_send_from_line(cmd, msg);
1501      owl_free(cmd);
1502      return NULL;
1503    }
1504  }
1505
1506  if (argc < 2) {
1507    owl_function_makemsg("Not enough arguments to the zwrite command.");
1508  } else {
1509    tmpbuff = owl_strdup(buff);
1510    owl_function_zwrite_setup(tmpbuff);
1511    owl_global_set_buffercommand(&g, tmpbuff);
1512    owl_free(tmpbuff);
1513  }
1514  return NULL;
1515}
1516
1517char *owl_command_aimwrite(int argc, char **argv, char *buff) {
1518  char *tmpbuff;
1519
1520  if (!owl_global_is_aimloggedin(&g)) {
1521    owl_function_makemsg("You are not logged in to AIM.");
1522    return(NULL);
1523  }
1524
1525  if (argc < 2) {
1526    owl_function_makemsg("Not enough arguments to the aimwrite command.");
1527    return(NULL);
1528  }
1529
1530  tmpbuff=owl_strdup(buff);
1531  owl_function_aimwrite_setup(tmpbuff);
1532  owl_global_set_buffercommand(&g, tmpbuff);
1533  owl_free(tmpbuff);
1534  return(NULL);
1535}
1536
1537char *owl_command_zcrypt(int argc, char **argv, char *buff) {
1538  char *tmpbuff, *pos, *cmd, *msg;
1539 
1540  /* check for a zwrite -m */
1541  for (pos = buff; *pos; pos = skiptokens(pos, 1)) {
1542    if (!strncmp(pos, "-m ", 3)) {
1543      cmd = owl_strdup(buff);
1544      msg = cmd+(pos-buff);
1545      *msg = '\0';
1546      msg += 3;
1547      owl_zwrite_create_and_send_from_line(cmd, msg);
1548      owl_free(cmd);
1549      return NULL;
1550    }
1551  }
1552
1553  if (argc < 2) {
1554    owl_function_makemsg("Not enough arguments to the zcrypt command.");
1555  } else {
1556    tmpbuff = owl_strdup(buff);
1557    owl_function_zwrite_setup(tmpbuff);
1558    owl_global_set_buffercommand(&g, tmpbuff);
1559    owl_free(tmpbuff);
1560  }
1561  return(NULL);
1562}
1563
1564char *owl_command_reply(int argc, char **argv, char *buff) {
1565  int edit=0;
1566 
1567  if (argc>=2 && !strcmp("-e", argv[1])) {
1568    edit=1;
1569    argv++;
1570    argc--;
1571  }
1572
1573  if ((argc==1) || (argc==2 && !strcmp(argv[1], "all"))) {   
1574    owl_function_reply(0, !edit);
1575  } else if (argc==2 && !strcmp(argv[1], "sender")) {
1576    owl_function_reply(1, !edit);
1577  } else if (argc==2 && !strcmp(argv[1], "zaway")) {
1578    owl_message *m;
1579    owl_view    *v;
1580    v = owl_global_get_current_view(&g);   
1581    m = owl_view_get_element(v, owl_global_get_curmsg(&g));
1582    if (m) owl_zephyr_zaway(m);
1583  } else {
1584    owl_function_makemsg("Invalid arguments to the reply command.");
1585  }
1586  return NULL;
1587}
1588
1589char *owl_command_filter(int argc, char **argv, char *buff) {
1590  owl_function_create_filter(argc, argv);
1591  return NULL;
1592}
1593
1594char *owl_command_zlocate(int argc, char **argv, char *buff) {
1595  int auth;
1596 
1597  if (argc<2) {
1598    owl_function_makemsg("Too few arguments for zlocate command");
1599    return NULL;
1600  }
1601
1602  auth=1;
1603  if (!strcmp(argv[1], "-d")) {
1604    if (argc>2) {
1605      auth=0;
1606      argc--;
1607      argv++;
1608    } else {
1609      owl_function_makemsg("Missing arguments for zlocate command");
1610      return NULL;
1611    }
1612  }
1613
1614  argc--;
1615  argv++;
1616  owl_function_zlocate(argc, argv, auth);
1617  return NULL;
1618}
1619
1620char *owl_command_view(int argc, char **argv, char *buff) {
1621  if (argc<2) {
1622    owl_function_makemsg("Wrong number of arguments to view command");
1623    return NULL;
1624  }
1625
1626  if (argc == 2 && !strcmp(argv[1], "--home")) {
1627    owl_function_change_view(owl_global_get_view_home(&g));
1628    return NULL;
1629  }
1630
1631  /* is it a dynamic filter? */
1632  if (!strcmp(argv[1], "-d")) {
1633    char **myargv;
1634    int i;
1635
1636    myargv=owl_malloc((argc*sizeof(char *))+50);
1637    myargv[0]="";
1638    myargv[1]="owl-dynamic";
1639    for (i=2; i<argc; i++) {
1640      myargv[i]=argv[i];
1641    }
1642    owl_function_create_filter(argc, myargv);
1643    owl_function_change_view("owl-dynamic");
1644    owl_free(myargv);
1645    return NULL;
1646  }
1647
1648  /* otherwise it's a normal view command */
1649  if (argc>2) {
1650    owl_function_makemsg("Wrong number of arguments to view command");
1651    return NULL;
1652  }
1653  owl_function_change_view(argv[1]);
1654  return NULL;
1655}
1656
1657
1658char *owl_command_show(int argc, char **argv, char *buff) {
1659
1660  if (argc<2) {
1661    owl_function_help_for_command("show");
1662    return NULL;
1663  }
1664
1665  if (!strcmp(argv[1], "filter") || !strcmp(argv[1], "filters")) {
1666    if (argc==2) {
1667      owl_function_show_filters();
1668    } else {
1669      owl_function_show_filter(argv[2]);
1670    }
1671  } else if (argc==2 
1672             && (!strcmp(argv[1], "zpunts") || !strcmp(argv[1], "zpunted"))) {
1673    owl_function_show_zpunts();
1674  } else if (!strcmp(argv[1], "command") || !strcmp(argv[1], "commands")) {
1675    if (argc==2) {
1676      owl_function_show_commands();
1677    } else {
1678      owl_function_show_command(argv[2]);
1679    }
1680  } else if (!strcmp(argv[1], "variable") || !strcmp(argv[1], "variables")) {
1681    if (argc==2) {
1682      owl_function_show_variables();
1683    } else {
1684      owl_function_show_variable(argv[2]);
1685    }
1686  } else if (!strcmp(argv[1], "keymap") || !strcmp(argv[1], "keymaps")) {
1687    if (argc==2) {
1688      owl_function_show_keymaps();
1689    } else {
1690      owl_function_show_keymap(argv[2]);
1691    }
1692  } else if (!strcmp(argv[1], "colors")) {
1693    owl_function_show_colors();
1694  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
1695    owl_function_getsubs();
1696  } else if (!strcmp(argv[1], "terminal") || !strcmp(argv[1], "term")) {
1697    owl_function_show_term();
1698  } else if (!strcmp(argv[1], "version")) {
1699    owl_function_about();
1700  } else if (!strcmp(argv[1], "status")) {
1701    owl_function_status();
1702  } else {
1703    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
1704    return NULL;
1705  }
1706  return NULL;
1707}
1708
1709char *owl_command_viewclass(int argc, char **argv, char *buff) {
1710  char *filtname;
1711  if (argc!=2) {
1712    owl_function_makemsg("Wrong number of arguments to viewclass command");
1713    return NULL;
1714  }
1715  filtname = owl_function_classinstfilt(argv[1], NULL);
1716  owl_function_change_view(filtname);
1717  owl_free(filtname);
1718  return NULL;
1719}
1720
1721char *owl_command_viewuser(int argc, char **argv, char *buff) {
1722  char *filtname;
1723  if (argc!=2) {
1724    owl_function_makemsg("Wrong number of arguments to viewuser command");
1725    return NULL;
1726  }
1727  filtname=owl_function_zuserfilt(argv[1]);
1728  owl_function_change_view(filtname);
1729  owl_free(filtname);
1730  return NULL;
1731}
1732
1733
1734void owl_command_pop_message(void) {
1735  owl_function_curmsg_to_popwin();
1736}
1737
1738void owl_command_openurl(void) {
1739  owl_function_openurl();
1740}
1741
1742char *owl_command_delete(int argc, char **argv, char *buff) {
1743  int move_after = 1;
1744
1745  if (argc>1 && !strcmp(argv[1], "--no-move")) {
1746    move_after = 0;
1747    argc--; 
1748    argv++;
1749  }
1750
1751  if (argc==1) {
1752    owl_function_deletecur(move_after);
1753    return NULL;
1754  }
1755
1756  if (argc==2 && !strcmp(argv[1], "view")) {
1757    owl_function_delete_curview_msgs(1);
1758    return NULL;
1759  }
1760
1761  if (argc==2 && !strcmp(argv[1], "trash")) {
1762    owl_function_delete_automsgs();
1763    return NULL;
1764  }
1765
1766  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
1767    owl_function_delete_by_id(atoi(argv[2]), 1);
1768    return NULL;
1769  }
1770
1771  owl_function_makemsg("Unknown arguments to delete command");
1772  return NULL;
1773}
1774
1775char *owl_command_undelete(int argc, char **argv, char *buff) {
1776  int move_after = 1;
1777
1778  if (argc>1 && !strcmp(argv[1], "--no-move")) {
1779    move_after = 0;
1780    argc--; 
1781    argv++;
1782  }
1783
1784  if (argc==1) {
1785    owl_function_undeletecur(move_after);
1786    return NULL;
1787  }
1788
1789  if (argc==2 && !strcmp(argv[1], "view")) {
1790    owl_function_delete_curview_msgs(0);
1791    return NULL;
1792  }
1793
1794  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
1795    owl_function_delete_by_id(atoi(argv[2]), 0);
1796    return NULL;
1797  }
1798
1799  owl_function_makemsg("Unknown arguments to delete command");
1800  return NULL;
1801}
1802
1803void owl_command_beep() {
1804  owl_function_beep();
1805}
1806
1807char *owl_command_colorview(int argc, char **argv, char *buff) {
1808  if (argc!=2) {
1809    owl_function_makemsg("Wrong number of arguments to colorview command");
1810    return NULL;
1811  }
1812  owl_function_color_current_filter(argv[1]);
1813  return NULL;
1814}
1815
1816char *owl_command_zpunt(int argc, char **argv, char *buff) {
1817  owl_command_zpunt_and_zunpunt(argc, argv, 0);
1818  return NULL;
1819}
1820
1821char *owl_command_zunpunt(int argc, char **argv, char *buff) {
1822  owl_command_zpunt_and_zunpunt(argc, argv, 1);
1823  return NULL;
1824}
1825
1826
1827void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type) {
1828  /* if type==0 then zpunt
1829   * if type==1 then zunpunt
1830   */
1831  char *class, *inst, *recip;
1832
1833  class="message";
1834  inst="";
1835  recip="*";
1836
1837  if (argc==1) {
1838    /* show current punt filters */
1839    owl_function_show_zpunts();
1840    return;
1841  } else if (argc==2) {
1842    inst=argv[1];
1843  } else if (argc==3) {
1844    class=argv[1];
1845    inst=argv[2];
1846  } else if (argc==4) {
1847    class=argv[1];
1848    inst=argv[2];
1849    recip=argv[3];
1850  } else {
1851    owl_function_makemsg("Wrong number of arguments to the zpunt command");
1852    return;
1853  }
1854
1855  owl_function_zpunt(class, inst, recip, type);
1856  if (type==0) {
1857    owl_function_makemsg("<%s, %s, %s> added to punt list.", class, inst, recip);
1858  } else if (type==1) {
1859    owl_function_makemsg("<%s, %s, %s> removed from punt list.", class, inst, recip);
1860  }
1861}
1862
1863char *owl_command_smartzpunt(int argc, char **argv, char *buff) {
1864  if (argc == 1) {
1865    owl_function_smartzpunt(0);
1866  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1867    owl_function_smartzpunt(1);
1868  } else {
1869    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1870  }
1871  return NULL;
1872}
1873
1874char *owl_command_getview(int argc, char **argv, char *buff) {
1875  char *filtname;
1876  if (argc != 1) {
1877    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
1878    return NULL;
1879  }
1880  filtname = owl_view_get_filtname(owl_global_get_current_view(&g));
1881  if (filtname) filtname = owl_strdup(filtname);
1882  return filtname;
1883}
1884
1885char *owl_command_getvar(int argc, char **argv, char *buff) {
1886  char tmpbuff[1024];
1887  if (argc != 2) {
1888    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
1889    return NULL;
1890  }
1891  if (owl_variable_get_tostring(owl_global_get_vardict(&g), 
1892                                argv[1], tmpbuff, 1024)) {
1893    return NULL;
1894  }
1895  return owl_strdup(tmpbuff); 
1896}
1897
1898char *owl_command_search(int argc, char **argv, char *buff) {
1899  int direction;
1900  char *buffstart;
1901
1902  direction=OWL_DIRECTION_DOWNWARDS;
1903  buffstart=skiptokens(buff, 1);
1904  if (argc>1 && !strcmp(argv[1], "-r")) {
1905    direction=OWL_DIRECTION_UPWARDS;
1906    buffstart=skiptokens(buff, 2);
1907  }
1908   
1909  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
1910    owl_function_search_continue(direction);
1911  } else {
1912    owl_function_search_start(buffstart, direction);
1913  }
1914 
1915  return(NULL);
1916}
1917
1918char *owl_command_aimlogin(int argc, char **argv, char *buff) {
1919  int ret;
1920 
1921  if (argc!=3) {
1922    owl_function_makemsg("Wrong number of arguments to aimlogin command");
1923    return(NULL);
1924  }
1925
1926  /* clear the buddylist */
1927  owl_buddylist_clear(owl_global_get_buddylist(&g));
1928
1929  /* try to login */
1930  ret=owl_aim_login(argv[1], argv[2]);
1931  if (!ret) {
1932    owl_function_makemsg("%s logged in.\n", argv[1]);
1933    return(NULL);
1934  }
1935 
1936  owl_function_makemsg("Warning: login for %s failed.\n");
1937  return(NULL);
1938}
1939
1940char *owl_command_aimlogout(int argc, char **argv, char *buff) {
1941  /* clear the buddylist */
1942  owl_buddylist_clear(owl_global_get_buddylist(&g));
1943
1944  owl_aim_logout();
1945  return(NULL);
1946}
1947
1948/*********************************************************************/
1949/************************** EDIT SPECIFIC ****************************/
1950/*********************************************************************/
1951
1952void owl_command_edit_cancel(owl_editwin *e) {
1953  owl_history *hist;
1954
1955  owl_function_makemsg("Command cancelled.");
1956
1957  hist=owl_editwin_get_history(e);
1958  owl_history_store(hist, owl_editwin_get_text(e));
1959  owl_history_reset(hist);
1960
1961  owl_editwin_fullclear(e);
1962  owl_global_set_needrefresh(&g);
1963  wnoutrefresh(owl_editwin_get_curswin(e));
1964  owl_global_set_typwin_inactive(&g);
1965  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
1966}
1967
1968void owl_command_edit_history_prev(owl_editwin *e) {
1969  owl_history *hist;
1970  char *ptr;
1971
1972  hist=owl_editwin_get_history(e);
1973  if (!owl_history_is_touched(hist)) {
1974    owl_history_store(hist, owl_editwin_get_text(e));
1975    owl_history_set_partial(hist);
1976  }
1977  ptr=owl_history_get_prev(hist);
1978  if (ptr) {
1979    owl_editwin_clear(e);
1980    owl_editwin_insert_string(e, ptr);
1981    owl_editwin_redisplay(e, 0);
1982    owl_global_set_needrefresh(&g);
1983  } else {
1984    owl_function_beep();
1985  }
1986}
1987
1988void owl_command_edit_history_next(owl_editwin *e) {
1989  owl_history *hist;
1990  char *ptr;
1991
1992  hist=owl_editwin_get_history(e);
1993  ptr=owl_history_get_next(hist);
1994  if (ptr) {
1995    owl_editwin_clear(e);
1996    owl_editwin_insert_string(e, ptr);
1997    owl_editwin_redisplay(e, 0);
1998    owl_global_set_needrefresh(&g);
1999  } else {
2000    owl_function_beep();
2001  }
2002}
2003
2004char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff) {
2005  buff = skiptokens(buff, 1);
2006  owl_editwin_insert_string(e, buff);
2007  owl_editwin_redisplay(e, 0);
2008  owl_global_set_needrefresh(&g); 
2009  return NULL;
2010}
2011
2012void owl_command_editline_done(owl_editwin *e) {
2013  owl_history *hist=owl_editwin_get_history(e);
2014  char *rv, *cmd;
2015
2016  owl_history_store(hist, owl_editwin_get_text(e));
2017  owl_history_reset(hist);
2018  owl_global_set_typwin_inactive(&g);
2019  cmd = owl_strdup(owl_editwin_get_text(e));
2020  owl_editwin_fullclear(e);
2021  rv = owl_function_command(cmd);
2022  owl_free(cmd);
2023
2024  wnoutrefresh(owl_editwin_get_curswin(e));
2025  owl_global_set_needrefresh(&g);
2026
2027  if (rv) {
2028    owl_function_makemsg("%s", rv);
2029    owl_free(rv);
2030  }
2031}
2032
2033void owl_command_editmulti_done(owl_editwin *e) {
2034  owl_history *hist=owl_editwin_get_history(e);
2035
2036  owl_history_store(hist, owl_editwin_get_text(e));
2037  owl_history_reset(hist);
2038
2039  owl_function_run_buffercommand();
2040  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
2041  owl_editwin_fullclear(e);
2042  owl_global_set_typwin_inactive(&g);
2043  owl_global_set_needrefresh(&g);
2044  wnoutrefresh(owl_editwin_get_curswin(e));
2045}
2046
2047void owl_command_editmulti_done_or_delete(owl_editwin *e) {
2048  if (owl_editwin_is_at_end(e)) {
2049    owl_command_editmulti_done(e);
2050  } else {
2051    owl_editwin_delete_char(e);
2052  }
2053}
2054
2055
2056/*********************************************************************/
2057/*********************** POPLESS SPECIFIC ****************************/
2058/*********************************************************************/
2059
2060void owl_command_popless_quit(owl_viewwin *vw) {
2061  owl_popwin_close(owl_global_get_popwin(&g));
2062  owl_viewwin_free(vw);
2063  owl_global_set_needrefresh(&g);
2064}
Note: See TracBrowser for help on using the repository browser.