source: commands.c @ c3ab155

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