source: commands.c @ a957e92

release-1.10release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since a957e92 was 49d67b1, checked in by Karl Ramm <kcr@1ts.org>, 14 years ago
"s inside ""s need to be \\d
  • Property mode set to 100644
File size: 81.8 KB
RevLine 
[7d4fbcd]1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <unistd.h>
5#include "owl.h"
6
[e19eb97]7/* fn is "char *foo(int argc, const char *const *argv, const char *buff)" */
[7d4fbcd]8#define OWLCMD_ARGS(name, fn, ctx, summary, usage, description) \
9        { name, summary, usage, description, ctx, \
[bc9020f]10          NULL, fn, NULL, NULL, NULL, NULL, NULL, NULL }
[7d4fbcd]11
12/* fn is "void foo(void)" */
13#define OWLCMD_VOID(name, fn, ctx, summary, usage, description) \
14        { name, summary, usage, description, ctx, \
[bc9020f]15          NULL, NULL, fn, NULL, NULL, NULL, NULL, NULL }
[7d4fbcd]16
17/* fn is "void foo(int)" */
18#define OWLCMD_INT(name, fn, ctx, summary, usage, description) \
19        { name, summary, usage, description, ctx, \
[bc9020f]20          NULL, NULL, NULL, fn, NULL, NULL, NULL, NULL }
[7d4fbcd]21
22#define OWLCMD_ALIAS(name, actualname) \
23        { name, OWL_CMD_ALIAS_SUMMARY_PREFIX actualname, "", "", OWL_CTX_ANY, \
[bc9020f]24          actualname, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
[7d4fbcd]25
[e19eb97]26/* fn is "char *foo(void *ctx, int argc, const char *const *argv, const char *buff)" */
[7d4fbcd]27#define OWLCMD_ARGS_CTX(name, fn, ctx, summary, usage, description) \
28        { name, summary, usage, description, ctx, \
[e19eb97]29          NULL, NULL, NULL, NULL, ((char*(*)(void*,int,const char*const *,const char*))fn), NULL, NULL, NULL }
[7d4fbcd]30
31/* fn is "void foo(void)" */
32#define OWLCMD_VOID_CTX(name, fn, ctx, summary, usage, description) \
33        { name, summary, usage, description, ctx, \
[bc9020f]34          NULL, NULL, NULL, NULL, NULL, ((void(*)(void*))(fn)), NULL, NULL }
[7d4fbcd]35
36/* fn is "void foo(int)" */
37#define OWLCMD_INT_CTX(name, fn, ctx, summary, usage, description) \
38        { name, summary, usage, description, ctx, \
[bc9020f]39          NULL, NULL, NULL, NULL, NULL, NULL, ((void(*)(void*,int))fn), NULL }
[7d4fbcd]40
41
[0a0fb74]42const owl_cmd commands_to_init[]
[7d4fbcd]43  = {
44  OWLCMD_ARGS("zlog", owl_command_zlog, OWL_CTX_ANY,
45              "send a login or logout notification",
[425c013]46              "zlog in [tty]\nzlog out",
[7d4fbcd]47              "zlog in will send a login notification, zlog out will send a\n"
48              "logout notification.  By default a login notification is sent\n"
49              "when owl is started and a logout notification is sent when owl\n"
50              "is exited.  This behavior can be changed with the 'startuplogin'\n"
[451db9e]51              "and 'shutdownlogout' variables.  If a tty is specified for zlog in\n"
[425c013]52              "then the owl variable 'tty' will be set to that string, causing\n"
53              "it to be used as the zephyr location tty.\n"),
[7d4fbcd]54
55  OWLCMD_VOID("quit", owl_command_quit, OWL_CTX_ANY,
56              "exit owl",
57              "",
58              "Exit owl and run any shutdown activities."),
59  OWLCMD_ALIAS("exit", "quit"),
[8921d3f]60  OWLCMD_ALIAS("q",    "quit"),
[ecd5dc5]61
62  OWLCMD_ARGS("term", owl_command_term, OWL_CTX_ANY,
63              "control the terminal",
64              "term raise\n"
65              "term deiconify\n",
66              ""),
67
68  OWLCMD_VOID("nop", owl_command_nop, OWL_CTX_ANY,
69              "do nothing",
70              "",
71              ""),
[7d4fbcd]72 
73  OWLCMD_ARGS("start-command", owl_command_start_command, OWL_CTX_INTERACTIVE,
74              "prompts the user to enter a command",
75              "start-command [initial-value]",
76              "Initializes the command field to initial-value."),
77
78  OWLCMD_ARGS("alias", owl_command_alias, OWL_CTX_ANY,
79              "creates a command alias",
80              "alias <new_command> <old_command>",
81              "Creates a command alias from new_command to old_command.\n"
82              "Any arguments passed to <new_command> will be appended to\n"
83              "<old_command> before it is executed.\n"),
84
85  OWLCMD_ARGS("bindkey", owl_command_bindkey, OWL_CTX_ANY,
86              "creates a binding in a keymap",
87              "bindkey <keymap> <keyseq> command <command>",
[49d67b1]88              "(Note: There is a literal word \"command\" between <keyseq>\n"
[a006a662]89              " and <command>.)\n"
[7d4fbcd]90              "Binds a key sequence to a command within a keymap.\n"
91              "Use 'show keymaps' to see the existing keymaps.\n"
[a006a662]92              "Key sequences may be things like M-C-t or NPAGE.\n\n"
93              "Ex.: bindkey recv C-b command zwrite -c barnowl"),
[7d4fbcd]94
95  OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE,
96              "send a zephyr",
[1c6c4d3]97              "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] [-m <message...>]",
[7d4fbcd]98              "Zwrite send a zephyr to the one or more users specified.\n\n"
99              "The following options are available:\n\n"
[1c6c4d3]100              "-m    Specifies a message to send without prompting.\n"
101              "      Note that this does not yet log an outgoing message.\n"
102              "      This must be the last argument.\n\n"
[7d4fbcd]103              "-n    Do not send a ping message.\n\n"
104              "-C    If the message is sent to more than one user include a\n"
105              "      \"cc:\" line in the text\n\n"
106              "-c class\n"
107              "      Send to the specified zephyr class\n\n"
108              "-i instance\n"
109              "      Send to the specified zephyr instance\n\n"
110              "-r realm\n"
111              "      Send to a foreign realm\n"
112              "-O opcode\n"
113              "      Send to the specified opcode\n"),
[d309eb3]114
[d09e5a1]115  OWLCMD_ARGS("aimwrite", owl_command_aimwrite, OWL_CTX_INTERACTIVE,
[453bd70]116              "send an AIM message",
[fa4f9c3]117              "aimwrite <user> [-m <message...>]",
[944004c]118              "Send an aim message to a user.\n\n" 
119              "The following options are available:\n\n"
[fa4f9c3]120              "-m    Specifies a message to send without prompting.\n"),
[d09e5a1]121
[37eab7f]122  OWLCMD_ARGS("loopwrite", owl_command_loopwrite, OWL_CTX_INTERACTIVE,
123              "send a loopback message",
124              "loopwrite",
125              "Send a local message.\n"),
126
[d309eb3]127  OWLCMD_ARGS("zcrypt", owl_command_zcrypt, OWL_CTX_INTERACTIVE,
128              "send an encrypted zephyr",
129              "zcrypt [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [-m <message...>]\n",
130              "Behaves like zwrite but uses encryption.  Not for use with\n"
131              "personal messages\n"),
[7d4fbcd]132 
133  OWLCMD_ARGS("reply", owl_command_reply,  OWL_CTX_INTERACTIVE,
134              "reply to the current message",
[e75011e]135              "reply [-e] [ sender | all | zaway ]",
[7d4fbcd]136              "If -e is specified, the zwrite command line is presented to\n"
137              "allow editing.\n\n"
138              "If 'sender' is specified, reply to the sender.\n\n"
139              "If 'all' or no args are specified, reply publically to the\n"
140              "same class/instance for non-personal messages and to the\n"
[e75011e]141              "sender for personal messages.\n\n"
142              "If 'zaway' is specified, replies with a zaway message.\n\n"),
[7d4fbcd]143
144  OWLCMD_ARGS("set", owl_command_set, OWL_CTX_ANY,
145              "set a variable value",
[88ca489]146              "set [-q] [<variable>] [<value>]\n"
[7d4fbcd]147              "set",
148              "Set the named variable to the specified value.  If no\n"
[88ca489]149              "arguments are given, print the value of all variables.\n"
150              "If the value is unspecified and the variable is a boolean, it will be\n"
151              "set to 'on'.  If -q is used, set is silent and does not print a\n"
152              "message.\n"),
[486688f]153
154  OWLCMD_ARGS("unset", owl_command_unset, OWL_CTX_ANY,
155              "unset a boolean variable value",
156              "set [-q] <variable>\n"
157              "set",
158              "Set the named boolean variable to off.\n"
[7d4fbcd]159              "If -q is specified, is silent and doesn't print a message.\n"),
160
161  OWLCMD_ARGS("print", owl_command_print, OWL_CTX_ANY,
162              "print a variable value",
163              "print <variable>\n"
164              "print",
[d768834]165              "Print the value of the named variable.  If no arguments\n"
[7d4fbcd]166              "are used print the value of all variables.\n"),
167
[38cf544c]168  OWLCMD_ARGS("startup", owl_command_startup, OWL_CTX_ANY,
169              "run a command and set it to be run at every Owl startup",
170              "startup <commands> ...",
171              "Everything on the command line after the startup command\n"
172              "is executed as a normal owl command and is also placed in\n"
173              "a file so that the command is executed every time owl\n"
174              "is started"),
175
176  OWLCMD_ARGS("unstartup", owl_command_unstartup, OWL_CTX_ANY,
177              "remove a command from the list of those to be run at Owl startup",
178              "unstartup <commands> ...",
179              ""),
180
[7d4fbcd]181  OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY,
182              "print the version of the running owl", "", ""),
183
184  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
185              "subscribe to a zephyr class, instance, recipient",
[fd472a7]186              "subscribe [-t] <class> [instance [recipient]]",
[451db9e]187              "Subscribe to the specified class and instance.  If the\n"
[f830d84]188              "instance or recipient is not listed on the command\n"
189              "line they default to * (the wildcard recipient).\n"
[fd472a7]190              "If the -t option is present the subscription will\n"
[f830d84]191              "only be temporary, i.e., it will not be written to\n"
192              "the subscription file and will therefore not be\n"
193              "present the next time owl is started.\n"),
[7d4fbcd]194  OWLCMD_ALIAS("sub", "subscribe"),
195
196  OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
197              "unsubscribe from a zephyr class, instance, recipient",
[fd472a7]198              "unsubscribe [-t] <class> [instance [recipient]]",
[7d4fbcd]199              "Unsubscribe from the specified class and instance.  If the\n"
[f830d84]200              "instance or recipient is not listed on the command\n"
201              "line they default to * (the wildcard recipient).\n"
[fd472a7]202              "If the -t option is present the unsubscription will\n"
203              "only be temporary, i.e., it will not be updated in\n"
[f830d84]204              "the subscription file and will therefore not be\n"
[fd472a7]205              "in effect the next time owl is started.\n"),
[7d4fbcd]206  OWLCMD_ALIAS("unsub", "unsubscribe"),
207
208  OWLCMD_VOID("unsuball", owl_command_unsuball, OWL_CTX_ANY,
209              "unsubscribe from all zephyrs", "", ""),
210 
211  OWLCMD_VOID("getsubs", owl_command_getsubs, OWL_CTX_ANY,
212              "print all current subscriptions",
213              "getsubs",
214              "getsubs retrieves the current subscriptions from the server\n"
215              "and displays them.\n"),
216
[2adaf1d]217  OWLCMD_ARGS("dump", owl_command_dump, OWL_CTX_ANY,
218              "dump messages to a file",
219              "dump <filename>",
220              "Dump messages in current view to the named file."),
221
[2404c3a]222  OWLCMD_ARGS("source", owl_command_source, OWL_CTX_ANY,
223              "execute owl commands from a file",
224              "source <filename>",
225              "Execute the owl commands in <filename>.\n"),
226
[952bb256]227  OWLCMD_ARGS("aim", owl_command_aim, OWL_CTX_INTERACTIVE,
228              "AIM specific commands",
229              "aim search <email>",
230              ""),
231
[fd93b41]232  OWLCMD_ARGS("addbuddy", owl_command_addbuddy, OWL_CTX_INTERACTIVE,
233              "add a buddy to a buddylist",
[fe0a16a]234              "addbuddy <protocol> <screenname>",
235              "Add the named buddy to your buddylist.  <protocol> can be aim or zephyr\n"),
[fd93b41]236
237  OWLCMD_ARGS("delbuddy", owl_command_delbuddy, OWL_CTX_INTERACTIVE,
238              "delete a buddy from a buddylist",
[fe0a16a]239              "delbuddy <protocol> <screenname>",
[b1fd36e]240              "Delete the named buddy from your buddylist.  <protocol> can be aim or zephyr\n"),
[fd93b41]241
[8c92848]242  OWLCMD_ARGS("join", owl_command_join, OWL_CTX_INTERACTIVE,
243              "join a chat group",
244              "join aim <groupname> [exchange]",
245              "Join the AIM chatroom with 'groupname'.\n"),
246
[d36f2cb]247  OWLCMD_ARGS("smartzpunt", owl_command_smartzpunt, OWL_CTX_INTERACTIVE,
248              "creates a zpunt based on the current message",
[5eeea3b]249              "smartzpunt [-i | --instance]",
[d36f2cb]250              "Starts a zpunt command based on the current message's class\n"
251              "(and instance if -i is specified).\n"),
252
[7d4fbcd]253  OWLCMD_ARGS("zpunt", owl_command_zpunt, OWL_CTX_ANY,
254              "suppress a given zephyr triplet",
255              "zpunt <class> <instance> [recipient]\n"
256              "zpunt <instance>",
257              "The zpunt command will supress message to the specified\n"
[451db9e]258              "zephyr triplet.  In the second usage messages are suppressed\n"
[7d4fbcd]259              "for class MESSAGE and the named instance.\n\n"
260              "SEE ALSO:  zunpunt, show zpunts\n"),
261
262  OWLCMD_ARGS("zunpunt", owl_command_zunpunt, OWL_CTX_ANY,
263              "undo a previous zpunt",
264              "zunpunt <class> <instance> [recipient]\n"
265              "zunpunt <instance>",
[451db9e]266              "The zunpunt command will allow messages that were previously\n"
[7d4fbcd]267              "suppressed to be received again.\n\n"
268              "SEE ALSO:  zpunt, show zpunts\n"),
269
[ce7b824]270  OWLCMD_ARGS("punt", owl_command_punt, OWL_CTX_ANY,
271              "suppress an arbitrary filter",
[790ab12]272              "punt <filter-text>",
[ce7b824]273              "punt <filter-text (multiple words)>\n"
274              "The punt command will supress message to the specified\n"
275              "filter\n\n"
276              "SEE ALSO:  unpunt, zpunt, show zpunts\n"),
277
278  OWLCMD_ARGS("unpunt", owl_command_unpunt, OWL_CTX_ANY,
279              "remove an entry from the punt list",
[790ab12]280              "zpunt <filter-text>\n"
[ce7b824]281              "zpunt <filter-text>\n"
282              "zpunt <number>\n",
283              "The unpunt command will remove an entry from the puntlist.\n"
284              "The first two forms correspond to the first two forms of the :punt\n"
285              "command. The latter allows you to remove a specific entry from the\n"
286              "the list (see :show zpunts)\n\n"
287              "SEE ALSO:  punt, zpunt, zunpunt, show zpunts\n"),
288
[7d4fbcd]289  OWLCMD_VOID("info", owl_command_info, OWL_CTX_INTERACTIVE,
290              "display detailed information about the current message",
291              "", ""),
292 
293  OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
294              "display help on using owl",
295              "help [command]", ""),
[42abb10]296
297  OWLCMD_ARGS("zlist", owl_command_zlist, OWL_CTX_INTERACTIVE,
298              "List users logged in",
299              "znol [-f file]",
300              "Print a znol-style listing of users logged in"),
[aa5f725]301
[e60f98c]302  OWLCMD_VOID("alist", owl_command_alist, OWL_CTX_INTERACTIVE,
[aa5f725]303              "List AIM users logged in",
304              "alist",
305              "Print a listing of AIM users logged in"),
306
[e60f98c]307  OWLCMD_VOID("blist", owl_command_blist, OWL_CTX_INTERACTIVE,
[aa5f725]308              "List all buddies logged in",
[25b5b4b]309              "blist",
[aa5f725]310              "Print a listing of buddies logged in, regardless of protocol."),
311
[e60f98c]312  OWLCMD_VOID("toggle-oneline", owl_command_toggleoneline, OWL_CTX_INTERACTIVE,
[c3ab155]313              "Toggle the style between oneline and the default style",
314              "toggle-oneline",
315              ""),
316
[7d4fbcd]317  OWLCMD_VOID("recv:shiftleft", owl_command_shift_left, OWL_CTX_INTERACTIVE,
318              "scrolls receive window to the left", "", ""),
319
320  OWLCMD_VOID("recv:shiftright", owl_command_shift_right, OWL_CTX_INTERACTIVE,
321              "scrolls receive window to the left", "", ""),
322
323  OWLCMD_VOID("recv:pagedown", owl_function_mainwin_pagedown, 
324              OWL_CTX_INTERACTIVE,
325              "scrolls down by a page", "", ""),
326
327  OWLCMD_VOID("recv:pageup", owl_function_mainwin_pageup, OWL_CTX_INTERACTIVE,
328              "scrolls up by a page", "", ""),
329
[70110286]330  OWLCMD_VOID("recv:mark", owl_function_mark_message,
331              OWL_CTX_INTERACTIVE,
332              "mark the current message", "", ""),
333
334  OWLCMD_VOID("recv:swapmark", owl_function_swap_cur_marked,
335              OWL_CTX_INTERACTIVE,
[73ba824]336              "swap the positions of the pointer and the mark", "", ""),
[70110286]337
[7d4fbcd]338  OWLCMD_INT ("recv:scroll", owl_function_page_curmsg, OWL_CTX_INTERACTIVE,
339              "scrolls current message up or down", 
340              "recv:scroll <numlines>", 
341              "Scrolls the current message up or down by <numlines>.\n"
342              "Scrolls up if <numlines> is negative, else scrolls down.\n"),
343
[b950088]344  OWLCMD_ARGS("next", owl_command_next, OWL_CTX_INTERACTIVE,
345              "move the pointer to the next message",
[7360fab]346              "recv:next [ --filter <name> ] [ --skip-deleted ] [ --last-if-none ]\n"
347              "          [ --smart-filter | --smart-filter-instance ]",
[b950088]348              "Moves the pointer to the next message in the current view.\n"
349              "If --filter is specified, will only consider messages in\n"
350              "the filter <name>.\n"
[7360fab]351              "If --smart-filter or --smart-filter-instance is specified,\n"
352              "goes to the next message that is similar to the current message.\n"
[b950088]353              "If --skip-deleted is specified, deleted messages will\n"
354              "be skipped.\n"
355              "If --last-if-none is specified, will stop at last message\n"
356              "in the view if no other suitable messages are found.\n"),
[7d4fbcd]357  OWLCMD_ALIAS("recv:next", "next"),
358
[b950088]359  OWLCMD_ARGS("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
360              "move the pointer to the previous message",
[7360fab]361              "recv:prev [ --filter <name> ] [ --skip-deleted ] [ --first-if-none ]\n"
362              "          [ --smart-filter | --smart-filter-instance ]",
[b950088]363              "Moves the pointer to the next message in the current view.\n"
364              "If --filter is specified, will only consider messages in\n"
365              "the filter <name>.\n"
[7360fab]366              "If --smart-filter or --smart-filter-instance is specified,\n"
367              "goes to the previous message that is similar to the current message.\n"
[b950088]368              "If --skip-deleted is specified, deleted messages will\n"
369              "be skipped.\n"
370              "If --first-if-none is specified, will stop at first message\n"
371              "in the view if no other suitable messages are found.\n"),
[7d4fbcd]372  OWLCMD_ALIAS("recv:prev", "prev"),
373
[b950088]374  OWLCMD_ALIAS("recv:next-notdel", "recv:next --skip-deleted --last-if-none"),
375  OWLCMD_ALIAS("next-notdel",      "recv:next --skip-deleted --last-if-none"),
[7d4fbcd]376
[b950088]377  OWLCMD_ALIAS("recv:prev-notdel", "recv:prev --skip-deleted --first-if-none"),
378  OWLCMD_ALIAS("prev-notdel",      "recv:prev --skip-deleted --first-if-none"),
[7d4fbcd]379
[b950088]380  OWLCMD_ALIAS("recv:next-personal", "recv:next --filter personal"),
[7d4fbcd]381
[b950088]382  OWLCMD_ALIAS("recv:prev-personal", "recv:prev --filter personal"),
[7d4fbcd]383
384  OWLCMD_VOID("first", owl_command_first, OWL_CTX_INTERACTIVE,
385              "move the pointer to the first message", "", ""),
386  OWLCMD_ALIAS("recv:first", "first"),
387
388  OWLCMD_VOID("last", owl_command_last, OWL_CTX_INTERACTIVE,
[5eeea3b]389              "move the pointer to the last message", "", 
390              "Moves the pointer to the last message in the view.\n"
391              "If we are already at the last message in the view,\n"
392              "blanks the screen and moves just past the end of the view\n"
393              "so that new messages will appear starting at the top\n"
394              "of the screen.\n"),
[7d4fbcd]395  OWLCMD_ALIAS("recv:last", "last"),
396
397  OWLCMD_VOID("expunge", owl_command_expunge, OWL_CTX_INTERACTIVE,
398              "remove all messages marked for deletion", "", ""),
399
400  OWLCMD_VOID("resize", owl_command_resize, OWL_CTX_ANY,
401              "resize the window to the current screen size", "", ""),
402
403  OWLCMD_VOID("redisplay", owl_command_redisplay, OWL_CTX_ANY,
404              "redraw the entire window", "", ""),
405
406  OWLCMD_VOID("suspend", owl_command_suspend, OWL_CTX_ANY,
407              "suspend owl", "", ""),
408
409  OWLCMD_ARGS("echo", owl_command_echo, OWL_CTX_ANY,
410              "pops up a message in popup window",
411              "echo [args .. ]\n\n", ""),
412
413  OWLCMD_ARGS("exec", owl_command_exec, OWL_CTX_ANY,
414              "run a command from the shell",
415              "exec [args .. ]", ""),
416
417  OWLCMD_ARGS("aexec", owl_command_aexec, OWL_CTX_INTERACTIVE,
418              "run a command from the shell and display in an admin message",
419              "aexec [args .. ]", ""),
420
421  OWLCMD_ARGS("pexec", owl_command_pexec, OWL_CTX_INTERACTIVE,
422              "run a command from the shell and display in a popup window",
423              "pexec [args .. ]", ""),
424
425  OWLCMD_ARGS("perl", owl_command_perl, OWL_CTX_ANY,
426              "run a perl expression",
427              "perl [args .. ]", ""),
428
429  OWLCMD_ARGS("aperl", owl_command_aperl, OWL_CTX_INTERACTIVE,
430              "run a perl expression and display in an admin message",
431              "aperl [args .. ]", ""),
432
433  OWLCMD_ARGS("pperl", owl_command_pperl, OWL_CTX_INTERACTIVE,
434              "run a perl expression and display in a popup window",
435              "pperl [args .. ]", ""),
436
437  OWLCMD_ARGS("multi", owl_command_multi, OWL_CTX_ANY,
438              "runs multiple ;-separated commands",
439              "multi <command1> ( ; <command2> )*\n",
440              "Runs multiple semicolon-separated commands in order.\n"
441              "Note quoting isn't supported here yet.\n"
442              "If you want to do something fancy, use perl.\n"),
443
444  OWLCMD_ARGS("(", owl_command_multi, OWL_CTX_ANY,
445              "runs multiple ;-separated commands",
446              "'(' <command1> ( ; <command2> )* ')'\n",
447              "Runs multiple semicolon-separated commands in order.\n"
448              "You must have a space before the final ')'\n"
449              "Note quoting isn't supported here yet.\n"
450              "If you want to do something fancy, use perl.\n"),
451
452  OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN,
453              "pops up a message in a window", "", ""),
454
455  OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE,
[4b660cc]456              "Set, enable or disable zephyr away message",
[7d4fbcd]457              "zaway [ on | off | toggle ]\n"
458              "zaway <message>",
[4b660cc]459              "Turn on or off a zaway message.  If 'message' is\n"
460              "specified turn on zaway with that message, otherwise\n"
461              "use the default.\n"),
462
463  OWLCMD_ARGS("aaway", owl_command_aaway, OWL_CTX_INTERACTIVE,
464              "Set, enable or disable AIM away message",
465              "aaway [ on | off | toggle ]\n"
466              "aaway <message>",
467              "Turn on or off the AIM away message.  If 'message' is\n"
468              "specified turn on aaway with that message, otherwise\n"
469              "use the default.\n"),
470
471  OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE,
472              "Set, enable or disable both AIM and zephyr away messages",
473              "away [ on | off | toggle ]\n"
474              "away <message>",
475              "Turn on or off the AIM and zephyr away message.  If\n"
476              "'message' is specified turn them on with that message,\n"
477              "otherwise use the default.\n"
478              "\n"
479              "This command really just runs the 'aaway' and 'zaway'\n"
480              "commands together\n"
481              "\n"
482              "SEE ALSO: aaway, zaway"),
[7d4fbcd]483
484  OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY,
485              "load subscriptions from a file",
486              "load-subs <file>\n", ""),
487
[7933748]488  OWLCMD_ARGS("loadsubs", owl_command_loadsubs, OWL_CTX_ANY,
489              "load subscriptions from a file",
490              "loadsubs <file>\n", ""),
491
492  OWLCMD_ARGS("loadloginsubs", owl_command_loadloginsubs, OWL_CTX_ANY,
493              "load login subscriptions from a file",
494              "loadloginsubs <file>\n",
495              "The file should contain a list of usernames, one per line."),
496
[7d4fbcd]497  OWLCMD_VOID("about", owl_command_about, OWL_CTX_INTERACTIVE,
498              "print information about owl", "", ""),
499
500  OWLCMD_VOID("status", owl_command_status, OWL_CTX_ANY,
501              "print status information about the running owl", "", ""),
502 
503  OWLCMD_ARGS("zlocate", owl_command_zlocate, OWL_CTX_INTERACTIVE,
504              "locate a user",
[2527615]505              "zlocate [-d] <user> ...", 
506              "Performs a zlocate on one ore more users and puts the result\n"
507              "int a popwin.  If -d is specified, does not authenticate\n"
[7d4fbcd]508              "the lookup request.\n"),
509 
510  OWLCMD_ARGS("filter", owl_command_filter, OWL_CTX_ANY,
511              "create a message filter",
[8fa9562]512              "filter <name> [ -c fgcolor ] [ -b bgcolor ] [ <expression> ... ]",
[7d4fbcd]513              "The filter command creates a filter with the specified name,\n"
514              "or if one already exists it is replaced.  Example filter\n"
515              "syntax would be:\n\n"
516              "     filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ )\n\n"
[0c502e9]517              "Valid matching fields are:\n"
518              "    sender     -  sender\n"
519              "    recipient  -  recipient\n"
520              "    class      -  zephyr class name\n"
521              "    instance   -  zephyr instance name\n"
522              "    opcode     -  zephyr opcode\n"
523              "    realm      -  zephyr realm\n"
524              "    body       -  message body\n"
[49d467c]525              "    hostname   -  hostname of sending host\n"
[0c502e9]526              "    type       -  message type (zephyr, aim, admin)\n"
527              "    direction  -  either 'in' 'out' or 'none'\n"
[40458b9]528              "    login      -  either 'login' 'logout' or 'none'\n"
529              "Also you may match on the validity of another filter:\n"
530              "    filter <filtername>\n"
[32eed98]531              "Also you may pass the message to a perl function returning 0 or 1,\n"
532              "where 1 indicates that the function matches the filter:\n"
533              "    perl <subname>\n"
[0c502e9]534              "Valid operators are:\n"
535              "    and\n"
536              "    or\n"
537              "    not\n"
538              "And additionally you may use the static values:\n"
539              "    true\n"
540              "    false\n"
[451db9e]541              "Spaces must be present before and after parentheses.  If the\n"
[8fa9562]542              "optional color arguments are used they specifies the colors that\n"
[7d4fbcd]543              "messages matching this filter should be displayed in.\n\n"
544              "SEE ALSO: view, viewclass, viewuser\n"),
545
546  OWLCMD_ARGS("colorview", owl_command_colorview, OWL_CTX_INTERACTIVE,
[8fa9562]547              "change the colors on the current filter",
548              "colorview <fgcolor> [<bgcolor>]",
549              "The colors of messages in the current filter will be changed\n"
550              "to <fgcolor>,<bgcolor>.  Use the 'show colors' command for a list\n"
[7d4fbcd]551              "of valid colors.\n\n"
552              "SEE ALSO: 'show colors'\n"),
553
[5e0b690]554  OWLCMD_ARGS("colorclass", owl_command_colorclass, OWL_CTX_INTERACTIVE,
555              "create a filter to color messages of the given class name",
[8fa9562]556              "colorclass <class> <fgcolor> [<bgcolor>]",
[5e0b690]557              "A filter will be created to color messages in <class>"
[8fa9562]558              "in <fgcolor>,<bgcolor>.  Use the 'show colors' command for a list\n"
[5e0b690]559              "of valid colors.\n\n"
560              "SEE ALSO: 'show colors'\n"),
561
[7d4fbcd]562  OWLCMD_ARGS("view", owl_command_view, OWL_CTX_INTERACTIVE,
563              "view messages matching a filter",
[3895e23]564              "view [<viewname>] [-f <filter> | --home | -r ] [-s <style>]\n"
[7d4fbcd]565              "view <filter>\n"
566              "view -d <expression>\n"
567              "view --home",
[ef56a67]568              "The view command sets information associated with a particular view,\n"
569              "such as view's filter or style.  In the first general usage listed\n"
570              "above <viewname> is the name of the view to be changed.  If not\n"
571              "specified the default view 'main' will be used.  A filter can be set\n"
572              "for the view by listing a named filter after the -f argument.  If\n"
573              "the --home argument is used the filter will be set to the filter named\n"
574              "by the\n 'view_home' variable.  The style can be set by listing the\n"
575              "name style after the -s argument.\n"
[7d4fbcd]576              "\n"
[ef56a67]577              "The other usages listed above are abbreivated forms that simply set\n"
578              "the filter of the current view. The -d option allows you to write a\n"
579              "filter expression that will be dynamically created by owl and then\n"
580              "applied as the view's filter\n"
[7d4fbcd]581              "SEE ALSO: filter, viewclass, viewuser\n"),
582
583  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
584              "view only messages similar to the current message",
[7360fab]585              "smartnarrow [-i | --instance]",
[7d4fbcd]586              "If the curmsg is a personal message narrow\n"
[d768834]587              "   to the conversation with that user.\n"
[451db9e]588              "If the curmsg is a <MESSAGE, foo, *>\n"
589              "   message, narrow to the instance.\n"
590              "If the curmsg is a class message, narrow\n"
[7d4fbcd]591              "    to the class.\n"
[451db9e]592              "If the curmsg is a class message and '-i' is specified\n"
593              "    then narrow to the class and instance.\n"),
[7d4fbcd]594
[7360fab]595  OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE,
596              "returns the name of a filter based on the current message",
597              "smartfilter [-i | --instance]",
598              "If the curmsg is a personal message, the filter is\n"
[d768834]599              "   the conversation with that user.\n"
[451db9e]600              "If the curmsg is a <MESSAGE, foo, *>\n"
601              "   message, the filter is to that instance.\n"
[7360fab]602              "If the curmsg is a class message, the filter is that class.\n"
603              "If the curmsg is a class message and '-i' is specied\n"
[451db9e]604              "    the filter is to that class and instance.\n"),
[7360fab]605
[7d4fbcd]606  OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE,
607              "view messages matching a particular class",
608              "viewclass <class>",
609              "The viewclass command will automatically create a filter\n"
610              "matching the specified class and switch the current view\n"
611              "to it.\n\n"
612              "SEE ALSO: filter, view, viewuser\n"),
613  OWLCMD_ALIAS("vc", "viewclass"),
614
615  OWLCMD_ARGS("viewuser", owl_command_viewuser, OWL_CTX_INTERACTIVE,
616              "view messages matching a particular user",
617              "viewuser <user>",
618              "The viewuser command will automatically create a filter\n"
619              "matching the specified user and switch the current\n"
620              "view to it.\n\n"
621              "SEE ALSO: filter, view, viewclass\n"),
622  OWLCMD_ALIAS("vu", "viewuser"),
623
624  OWLCMD_ARGS("show", owl_command_show, OWL_CTX_INTERACTIVE,
[15283bb]625              "show information",
[f17bff98]626              "show colors\n"
627              "show commands\n"
628              "show command <command>\n"
629              "show errors\n"
[7d4fbcd]630              "show filters\n"
631              "show filter <filter>\n"
632              "show keymaps\n"
633              "show keymap <keymap>\n"
[debb15d]634              "show license\n"
[799b60e]635              "show quickstart\n"
[f17bff98]636              "show startup\n"
637              "show status\n"
[f1e629d]638              "show styles\n"
[f17bff98]639              "show subscriptions / show subs\n"
[7d4fbcd]640              "show terminal\n"
[f17bff98]641              "show variables\n"
642              "show variable <variable>\n"
[7d4fbcd]643              "show version\n"
[ef56a67]644              "show view [<view>]\n"
[f17bff98]645              "show zpunts\n",
[7d4fbcd]646
647              "Show colors will display a list of valid colors for the\n"
648              "     terminal."
649              "Show filters will list the names of all filters.\n"
650              "Show filter <filter> will show the definition of a particular\n"
651              "     filter.\n\n"
[f17bff98]652              "Show startup will display the custom startup config\n\n"
[7d4fbcd]653              "Show zpunts will show the active zpunt filters.\n\n"
654              "Show keymaps will list the names of all keymaps.\n"
655              "Show keymap <keymap> will show the key bindings in a keymap.\n\n"
656              "Show commands will list the names of all keymaps.\n"
657              "Show command <command> will provide information about a command.\n\n"
[f1e629d]658              "Show styles will list the names of all styles available\n"
659              "for formatting messages.\n\n"
[7d4fbcd]660              "Show variables will list the names of all variables.\n\n"
[ec6ff52]661              "Show errors will show a list of errors ecountered by Owl.\n\n"
[7d4fbcd]662              "SEE ALSO: filter, view, alias, bindkey, help\n"),
663 
664  OWLCMD_ARGS("delete", owl_command_delete, OWL_CTX_INTERACTIVE,
665              "mark a message for deletion",
[b950088]666              "delete [ -id msgid ] [ --no-move ]\n"
[7d4fbcd]667              "delete view\n"
668              "delete trash",
669              "If no message id is specified the current message is marked\n"
670              "for deletion.  Otherwise the message with the given message\n"
[451db9e]671              "id is marked for deletion.\n"
[b950088]672              "If '--no-move' is specified, don't move after deletion.\n"
[7d4fbcd]673              "If 'trash' is specified, deletes all trash/auto messages\n"
674              "in the current view.\n"
675              "If 'view' is specified, deletes all messages in the\n"
676              "current view.\n"),
677  OWLCMD_ALIAS("del", "delete"),
678
679  OWLCMD_ARGS("undelete", owl_command_undelete, OWL_CTX_INTERACTIVE,
680              "unmark a message for deletion",
[b950088]681              "undelete [ -id msgid ] [ --no-move ]\n"
[7d4fbcd]682              "undelete view",
683              "If no message id is specified the current message is\n"
684              "unmarked for deletion.  Otherwise the message with the\n"
[451db9e]685              "given message id is unmarked for deletion.\n"
[b950088]686              "If '--no-move' is specified, don't move after deletion.\n"
[7d4fbcd]687              "If 'view' is specified, undeletes all messages\n"
688              "in the current view.\n"),
689  OWLCMD_ALIAS("undel", "undelete"),
690
691  OWLCMD_VOID("beep", owl_command_beep, OWL_CTX_ANY,
692              "ring the terminal bell",
693              "beep",
694              "Beep will ring the terminal bell.\n"
695              "If the variable 'bell' has been\n"
696              "set to 'off' this command does nothing.\n"),
697
698  OWLCMD_ARGS("debug", owl_command_debug, OWL_CTX_ANY,
699              "prints a message into the debug log",
700              "debug <message>", ""),
701
[8ee73f8d]702  OWLCMD_ARGS("getview", owl_command_getview, OWL_CTX_INTERACTIVE,
703              "returns the name of the filter for the current view",
704              "", ""),
705
706  OWLCMD_ARGS("getvar", owl_command_getvar, OWL_CTX_INTERACTIVE,
707              "returns the value of a variable",
708              "getvar <varname>", ""),
709
[cdc6ff1]710  OWLCMD_ARGS("getfilter", owl_command_getfilter, OWL_CTX_INTERACTIVE,
711              "returns the definition of a filter",
712              "getfilter <filtername>", ""),
713
[216c734]714  OWLCMD_ARGS("getstyle", owl_command_getstyle, OWL_CTX_INTERACTIVE,
715              "returns the name of the style for the current view",
716              "", ""),
717
[1fd0b25]718  OWLCMD_ARGS("search", owl_command_search, OWL_CTX_INTERACTIVE,
719              "search messages for a particular string",
720              "search [-r] [<string>]",
721              "The search command will find messages that contain the\n"
722              "specified string and move the cursor there.  If no string\n"
723              "argument is supplied then the previous one is used.  By\n"
[451db9e]724              "default searches are done forwards; if -r is used the search\n"
[1fd0b25]725              "is performed backwards"),
726
[987ff51]727  OWLCMD_ARGS("setsearch", owl_command_setsearch, OWL_CTX_INTERACTIVE,
728              "set the search highlight string without searching",
729              "setsearch <string>",
730              "The setsearch command highlights all occurences of its\n"
731          "argument and makes it the default argument for future\n"
732          "search commands, but does not move the cursor.  With\n"
[451db9e]733          "no argument, it makes search highlighting inactive."),
[987ff51]734
[d09e5a1]735  OWLCMD_ARGS("aimlogin", owl_command_aimlogin, OWL_CTX_ANY,
736              "login to an AIM account",
[453bd70]737              "aimlogin <screenname> [<password>]\n",
[d09e5a1]738              ""),
739
740  OWLCMD_ARGS("aimlogout", owl_command_aimlogout, OWL_CTX_ANY,
741              "logout from AIM",
742              "aimlogout\n",
743              ""),
744
[4692b70]745  OWLCMD_ARGS("error", owl_command_error, OWL_CTX_ANY,
746              "Display an error message",
747              "error <message>",
748              ""),
749
750  OWLCMD_ARGS("message", owl_command_message, OWL_CTX_ANY,
[b1fd36e]751              "Display an informative message",
[4692b70]752              "message <message>",
753              ""),
[d09e5a1]754
[f4d32cd]755  OWLCMD_VOID("yes", owl_command_yes, OWL_CTX_RECV,
756              "Answer yes to a question",
757              "yes",
758              ""),
759
760  OWLCMD_VOID("no", owl_command_no, OWL_CTX_RECV,
761              "Answer no to a question",
762              "no",
763              ""),
764
[7d4fbcd]765  /****************************************************************/
766  /************************* EDIT-SPECIFIC ************************/
767  /****************************************************************/
768
769  OWLCMD_VOID_CTX("edit:move-next-word", owl_editwin_move_to_nextword, 
770                  OWL_CTX_EDIT,
771                  "moves cursor forward a word",
772                  "", ""),
773
774  OWLCMD_VOID_CTX("edit:move-prev-word", owl_editwin_move_to_previousword, 
775                  OWL_CTX_EDIT,
776                  "moves cursor backwards a word",
777                  "", ""),
778
779  OWLCMD_VOID_CTX("edit:move-to-buffer-start", owl_editwin_move_to_top,
780                  OWL_CTX_EDIT,
781                  "moves cursor to the top left (start) of the buffer",
782                  "", ""),
783
784  OWLCMD_VOID_CTX("edit:move-to-buffer-end", owl_editwin_move_to_end, 
785                  OWL_CTX_EDIT,
786                  "moves cursor to the bottom right (end) of the buffer",
787                  "", ""),
788
789  OWLCMD_VOID_CTX("edit:move-to-line-end", owl_editwin_move_to_line_end, 
790                  OWL_CTX_EDIT,
791                  "moves cursor to the end of the line",
792                  "", ""),
793
794  OWLCMD_VOID_CTX("edit:move-to-line-start", owl_editwin_move_to_line_start, 
795                  OWL_CTX_EDIT,
796                  "moves cursor to the beginning of the line",
797                  "", ""),
798
799  OWLCMD_VOID_CTX("edit:move-left", owl_editwin_key_left, 
800                  OWL_CTX_EDIT,
801                  "moves the cursor left by a character",
802                  "", ""),
803
804  OWLCMD_VOID_CTX("edit:move-right", owl_editwin_key_right,
805                  OWL_CTX_EDIT,
806                  "moves the cursor right by a character",
807                  "", ""),
808
809  OWLCMD_VOID_CTX("edit:delete-next-word", owl_editwin_delete_nextword,
810                  OWL_CTX_EDIT,
811                  "deletes the word to the right of the cursor",
812                  "", ""),
813
[b68f9cd]814  OWLCMD_VOID_CTX("edit:delete-prev-word", owl_editwin_delete_previousword,
815                  OWL_CTX_EDIT,
816                  "deletes the word to the left of the cursor",
817                  "", ""),
818
[7d4fbcd]819  OWLCMD_VOID_CTX("edit:delete-prev-char", owl_editwin_backspace,
820                  OWL_CTX_EDIT,
821                  "deletes the character to the left of the cursor",
822                  "", ""),
823
824  OWLCMD_VOID_CTX("edit:delete-next-char", owl_editwin_delete_char, 
825                  OWL_CTX_EDIT,
826                  "deletes the character to the right of the cursor",
827                  "", ""),
828
829  OWLCMD_VOID_CTX("edit:delete-to-line-end", owl_editwin_delete_to_endofline,
830                  OWL_CTX_EDIT,
831                  "deletes from the cursor to the end of the line",
832                  "", ""),
833
834  OWLCMD_VOID_CTX("edit:delete-all", owl_editwin_clear, 
835                  OWL_CTX_EDIT,
836                  "deletes all of the contents of the buffer",
837                  "", ""),
838
[f2e36b5]839  OWLCMD_VOID_CTX("edit:transpose-chars", owl_editwin_transpose_chars,
840                  OWL_CTX_EDIT,
841                  "Interchange characters around point, moving forward one character.",
842                  "", ""),
843
[7d4fbcd]844  OWLCMD_VOID_CTX("edit:fill-paragraph", owl_editwin_fill_paragraph, 
845                  OWL_CTX_EDIT,
846                  "fills the current paragraph to line-wrap well",
847                  "", ""),
848
849  OWLCMD_VOID_CTX("edit:recenter", owl_editwin_recenter, 
850                  OWL_CTX_EDIT,
851                  "recenters the buffer",
852                  "", ""),
853
854  OWLCMD_ARGS_CTX("edit:insert-text", owl_command_edit_insert_text, 
855                  OWL_CTX_EDIT,
856                  "inserts text into the buffer",
857                  "edit:insert-text <text>", ""),
858
859  OWLCMD_VOID_CTX("edit:cancel", owl_command_edit_cancel, 
860                  OWL_CTX_EDIT,
861                  "cancels the current command",
862                  "", ""),
863
864  OWLCMD_VOID_CTX("edit:history-next", owl_command_edit_history_next, 
[10b866d]865                  OWL_CTX_EDIT,
[5ade618]866                  "replaces the text with the next history",
[7d4fbcd]867                  "", ""),
868
869  OWLCMD_VOID_CTX("edit:history-prev", owl_command_edit_history_prev, 
[10b866d]870                  OWL_CTX_EDIT,
[7d4fbcd]871                  "replaces the text with the previous history",
872                  "", ""),
873
[7f0c26f]874  OWLCMD_VOID_CTX("edit:set-mark", owl_editwin_set_mark,
875                  OWL_CTX_EDIT,
876                  "sets the mark",
877                  "", ""),
878
879  OWLCMD_VOID_CTX("edit:exchange-point-and-mark", owl_editwin_exchange_point_and_mark,
880                  OWL_CTX_EDIT,
881                  "exchanges the point and the mark",
882                  "", ""),
883
[a60edf2]884  OWLCMD_VOID_CTX("edit:copy-region-as-kill", owl_editwin_copy_region_as_kill,
885                  OWL_CTX_EDIT,
886                  "copy the text between the point and the mark",
887                  "", ""),
888
889  OWLCMD_VOID_CTX("edit:kill-region", owl_editwin_kill_region,
890                  OWL_CTX_EDIT,
891                  "kill text between the point and the mark",
892                  "", ""),
893
894  OWLCMD_VOID_CTX("edit:yank", owl_editwin_yank,
895                  OWL_CTX_EDIT,
896                  "insert the current text from the kill buffer",
897                  "", ""),
898
[7d4fbcd]899  OWLCMD_VOID_CTX("editline:done", owl_command_editline_done, 
900                  OWL_CTX_EDITLINE,
901                  "completes the command (eg, executes command being composed)",
902                  "", ""),
903
[cf83b7a]904  OWLCMD_VOID_CTX("editresponse:done", owl_command_editresponse_done, 
905                  OWL_CTX_EDITRESPONSE,
906                  "completes the response to a question",
907                  "", ""),
908
[435d6b2]909  OWLCMD_VOID_CTX("edit:move-up-line", owl_editwin_key_up, 
[7d4fbcd]910                  OWL_CTX_EDITMULTI,
911                  "moves the cursor up one line",
912                  "", ""),
913
[435d6b2]914  OWLCMD_VOID_CTX("edit:move-down-line", owl_editwin_key_down, 
[7d4fbcd]915                  OWL_CTX_EDITMULTI,
916                  "moves the cursor down one line",
917                  "", ""),
918
[435d6b2]919  OWLCMD_VOID_CTX("edit:done", owl_command_edit_done, 
[7d4fbcd]920                  OWL_CTX_EDITMULTI,
921                  "completes the command (eg, sends message being composed)",
922                  "", ""),
923
[435d6b2]924  OWLCMD_VOID_CTX("edit:done-or-delete", owl_command_edit_done_or_delete, 
[217a43e]925                  OWL_CTX_EDITMULTI,
926                  "completes the command, but only if at end of message",
927                  "", 
928                  "If only whitespace is to the right of the cursor,\n"
[435d6b2]929                  "runs 'edit:done'.\n"\
[217a43e]930                  "Otherwise runs 'edit:delete-next-char'\n"),
931
[435d6b2]932  OWLCMD_VOID_CTX("edit:forward-paragraph", owl_editwin_forward_paragraph,
[2fc8397]933                  OWL_CTX_EDITMULTI,
934                  "Move forward to end of paragraph.",
935                  "",
936                  "Move the point to the end of the current paragraph"),
937
[435d6b2]938  OWLCMD_VOID_CTX("edit:backward-paragraph", owl_editwin_backward_paragraph,
[2fc8397]939                  OWL_CTX_EDITMULTI,
940                  "Move backward to the start of paragraph.",
941                  "",
942                  "Move the point to the start of the current paragraph"),
943
[7d4fbcd]944  /****************************************************************/
945  /********************** POPLESS-SPECIFIC ************************/
946  /****************************************************************/
947
948  OWLCMD_VOID_CTX("popless:scroll-down-page", owl_viewwin_pagedown, 
949                  OWL_CTX_POPLESS,
950                  "scrolls down one page",
951                  "", ""),
952
953  OWLCMD_VOID_CTX("popless:scroll-down-line", owl_viewwin_linedown, 
954                  OWL_CTX_POPLESS,
955                  "scrolls down one line",
956                  "", ""),
957
958  OWLCMD_VOID_CTX("popless:scroll-up-page", owl_viewwin_pageup, 
959                  OWL_CTX_POPLESS,
960                  "scrolls up one page",
961                  "", ""),
962
963  OWLCMD_VOID_CTX("popless:scroll-up-line", owl_viewwin_lineup, 
964                  OWL_CTX_POPLESS,
965                  "scrolls up one line",
966                  "", ""),
967
968  OWLCMD_VOID_CTX("popless:scroll-to-top", owl_viewwin_top, 
969                  OWL_CTX_POPLESS,
970                  "scrolls to the top of the buffer",
971                  "", ""),
972
973  OWLCMD_VOID_CTX("popless:scroll-to-bottom", owl_viewwin_bottom, 
974                  OWL_CTX_POPLESS,
975                  "scrolls to the bottom of the buffer",
976                  "", ""),
977
978  OWLCMD_INT_CTX ("popless:scroll-right", owl_viewwin_right, 
979                  OWL_CTX_POPLESS,
980                  "scrolls right in the buffer",
981                  "popless:scroll-right <num-chars>", ""),
982
983  OWLCMD_INT_CTX ("popless:scroll-left", owl_viewwin_left, 
984                  OWL_CTX_POPLESS,
985                  "scrolls left in the buffer",
986                  "popless:scroll-left <num-chars>", ""),
987
988  OWLCMD_VOID_CTX("popless:quit", owl_command_popless_quit, 
989                  OWL_CTX_POPLESS,
990                  "exits the popless window",
991                  "", ""),
992
[0b6b689]993  OWLCMD_ALIAS("webzephyr", "zwrite daemon.webzephyr -c webzephyr -i"),
994
[7d4fbcd]995  /* This line MUST be last! */
[bc9020f]996  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
[7d4fbcd]997
998};
999
[c79a047]1000void owl_command_info(void)
[cf83b7a]1001{
[7d4fbcd]1002  owl_function_info();
1003}
1004
[c79a047]1005void owl_command_nop(void)
[cf83b7a]1006{
[ecd5dc5]1007}
1008
[e19eb97]1009char *owl_command_help(int argc, const char *const *argv, const char *buff)
[cf83b7a]1010{
[7d4fbcd]1011  if (argc!=2) {
1012    owl_help();
1013    return NULL;
1014  }
1015 
1016  owl_function_help_for_command(argv[1]);
1017  return NULL;
1018}
1019
[e19eb97]1020char *owl_command_zlist(int argc, const char *const *argv, const char *buff)
[cf83b7a]1021{
[e19eb97]1022  const char *file=NULL;
[42abb10]1023
1024  argc--;
1025  argv++;
1026  while (argc) {
[61de085]1027    if (!strcmp(argv[0], "-f")) {
[42abb10]1028      if (argc==1) {
1029        owl_function_makemsg("zlist: -f needs an argument");
1030        return(NULL);
1031      }
1032      file=argv[1];
1033      argc-=2;
1034      argv+=2;
1035    } else {
1036      owl_function_makemsg("zlist: unknown argument");
1037      return(NULL);
1038    }
1039  }
[aa5f725]1040  owl_function_buddylist(0, 1, file);
1041  return(NULL);
1042}
1043
[c79a047]1044void owl_command_alist(void)
[cf83b7a]1045{
[aa5f725]1046  owl_function_buddylist(1, 0, NULL);
1047}
1048
[c79a047]1049void owl_command_blist(void)
[cf83b7a]1050{
[aa5f725]1051  owl_function_buddylist(1, 1, NULL);
[42abb10]1052}
1053
[c79a047]1054void owl_command_toggleoneline(void)
[cf83b7a]1055{
[c3ab155]1056  owl_function_toggleoneline();
1057}
1058
[c79a047]1059void owl_command_about(void)
[cf83b7a]1060{
[7d4fbcd]1061  owl_function_about();
1062}
1063
[c79a047]1064void owl_command_version(void)
[cf83b7a]1065{
[554a2b8]1066  owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING);
[7d4fbcd]1067}
1068
[e19eb97]1069char *owl_command_aim(int argc, const char *const *argv, const char *buff)
[952bb256]1070{
1071  if (argc<2) {
1072    owl_function_makemsg("not enough arguments to aim command");
1073    return(NULL);
1074  }
1075
1076  if (!strcmp(argv[1], "search")) {
1077    if (argc!=3) {
1078      owl_function_makemsg("not enough arguments to aim search command");
1079      return(NULL);
1080    }
1081    owl_aim_search(argv[2]);
1082  } else {
[d4b84c0]1083    owl_function_makemsg("unknown subcommand '%s' for aim command", argv[1]);
[952bb256]1084    return(NULL);
1085  }
1086  return(NULL);
1087}
1088
[e19eb97]1089char *owl_command_addbuddy(int argc, const char *const *argv, const char *buff)
[fd93b41]1090{
1091  if (argc!=3) {
1092    owl_function_makemsg("usage: addbuddy <protocol> <buddyname>");
1093    return(NULL);
1094  }
1095
[65ad073]1096  if (!strcasecmp(argv[1], "aim")) {
1097    if (!owl_global_is_aimloggedin(&g)) {
1098      owl_function_makemsg("addbuddy: You must be logged into aim to use this command.");
1099      return(NULL);
1100    }
[03ad7b2]1101    /*
[aac889a]1102    owl_function_makemsg("This function is not yet operational.  Stay tuned.");
1103    return(NULL);
[03ad7b2]1104    */
[65ad073]1105    owl_aim_addbuddy(argv[2]);
1106    owl_function_makemsg("%s added as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
1107  } else if (!strcasecmp(argv[1], "zephyr")) {
1108    owl_zephyr_addbuddy(argv[2]);
1109    owl_function_makemsg("%s added as zephyr buddy", argv[2]);
1110  } else {
1111    owl_function_makemsg("addbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
[fd93b41]1112  }
1113
1114  return(NULL);
1115}
1116
[e19eb97]1117char *owl_command_delbuddy(int argc, const char *const *argv, const char *buff)
[fd93b41]1118{
1119  if (argc!=3) {
1120    owl_function_makemsg("usage: delbuddy <protocol> <buddyname>");
1121    return(NULL);
1122  }
1123
[65ad073]1124  if (!strcasecmp(argv[1], "aim")) {
1125    if (!owl_global_is_aimloggedin(&g)) {
1126      owl_function_makemsg("delbuddy: You must be logged into aim to use this command.");
1127      return(NULL);
1128    }
1129    owl_aim_delbuddy(argv[2]);
1130    owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g));
1131  } else if (!strcasecmp(argv[1], "zephyr")) {
1132    owl_zephyr_delbuddy(argv[2]);
1133    owl_function_makemsg("%s deleted as zephyr buddy", argv[2]);
1134  } else {
1135    owl_function_makemsg("delbuddy: currently the only supported protocols are 'zephyr' and 'aim'");
[fd93b41]1136  }
1137
[8c92848]1138  return(NULL);
1139}
[fd93b41]1140
[e19eb97]1141char *owl_command_join(int argc, const char *const *argv, const char *buff)
[8c92848]1142{
1143  if (argc!=3 && argc!=4) {
1144    owl_function_makemsg("usage: join <protocol> <buddyname> [exchange]");
1145    return(NULL);
1146  }
1147
1148  if (!strcasecmp(argv[1], "aim")) {
1149    if (!owl_global_is_aimloggedin(&g)) {
1150      owl_function_makemsg("join aim: You must be logged into aim to use this command.");
1151      return(NULL);
1152    }
1153    if (argc==3) {
1154      owl_aim_chat_join(argv[2], 4);
1155    } else {
1156      owl_aim_chat_join(argv[2], atoi(argv[3]));
1157    }
1158    /* owl_function_makemsg("%s deleted as AIM buddy for %s", argv[2], owl_global_get_aim_screenname(&g)); */
1159  } else {
1160    owl_function_makemsg("join: currently the only supported protocol is 'aim'");
1161  }
[fd93b41]1162  return(NULL);
1163}
1164
[e19eb97]1165char *owl_command_startup(int argc, const char *const *argv, const char *buff)
[38cf544c]1166{
[e19eb97]1167  const char *ptr;
[38cf544c]1168
1169  if (argc<2) {
1170    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
1171    return(NULL);
1172  }
1173
[3e96ff0]1174  ptr = skiptokens(buff, 1);
[38cf544c]1175
[3e96ff0]1176  owl_function_command(ptr);
1177  owl_function_addstartup(ptr);
[38cf544c]1178
1179  return(NULL);
1180}
1181
[e19eb97]1182char *owl_command_unstartup(int argc, const char *const *argv, const char *buff)
[38cf544c]1183{
[e19eb97]1184  const char *ptr;
[38cf544c]1185
1186  if (argc<2) {
1187    owl_function_makemsg("usage: %s <commands> ...", argv[0]);
1188    return(NULL);
1189  }
1190
[3e96ff0]1191  ptr = skiptokens(buff, 1);
[38cf544c]1192
[3e96ff0]1193  owl_function_delstartup(ptr);
[38cf544c]1194
1195  return(NULL);
1196}
1197
[e19eb97]1198char *owl_command_dump(int argc, const char *const *argv, const char *buff)
[cf83b7a]1199{
[f36222f]1200  char *filename;
1201 
[2adaf1d]1202  if (argc!=2) {
1203    owl_function_makemsg("usage: dump <filename>");
1204    return(NULL);
1205  }
[f36222f]1206  filename=owl_util_makepath(argv[1]);
1207  owl_function_dump(filename);
1208  owl_free(filename);
[2adaf1d]1209  return(NULL);
1210}
1211
[e19eb97]1212char *owl_command_source(int argc, const char *const *argv, const char *buff)
[2404c3a]1213{
1214  if (argc!=2) {
1215    owl_function_makemsg("usage: source <filename>");
1216    return(NULL);
1217  }
1218
1219  owl_function_source(argv[1]);
1220  return(NULL);
1221}
1222
[e19eb97]1223char *owl_command_next(int argc, const char *const *argv, const char *buff)
[cf83b7a]1224{
[b950088]1225  char *filter=NULL;
1226  int skip_deleted=0, last_if_none=0;
1227  while (argc>1) {
1228    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1229      skip_deleted=1;
1230      argc-=1; argv+=1; 
1231    } else if (argc>=1 && !strcmp(argv[1], "--last-if-none")) {
1232      last_if_none=1;
1233      argc-=1; argv+=1; 
1234    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
[7360fab]1235      filter = owl_strdup(argv[2]);
1236      argc-=2; argv+=2; 
1237    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1238      filter = owl_function_smartfilter(0);
1239      argc-=2; argv+=2; 
1240    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1241      filter = owl_function_smartfilter(1);
[b950088]1242      argc-=2; argv+=2; 
1243    } else {
1244      owl_function_makemsg("Invalid arguments to command 'next'.");
1245      return(NULL);
1246    }
1247  }
1248  owl_function_nextmsg_full(filter, skip_deleted, last_if_none);
[7360fab]1249  if (filter) owl_free(filter);
[b950088]1250  return(NULL);
[7d4fbcd]1251}
1252
[e19eb97]1253char *owl_command_prev(int argc, const char *const *argv, const char *buff)
[cf83b7a]1254{
[b950088]1255  char *filter=NULL;
1256  int skip_deleted=0, first_if_none=0;
1257  while (argc>1) {
1258    if (argc>=1 && !strcmp(argv[1], "--skip-deleted")) {
1259      skip_deleted=1;
1260      argc-=1; argv+=1; 
1261    } else if (argc>=1 && !strcmp(argv[1], "--first-if-none")) {
1262      first_if_none=1;
1263      argc-=1; argv+=1; 
1264    } else if (argc>=2 && !strcmp(argv[1], "--filter")) {
[7360fab]1265      filter = owl_strdup(argv[2]);
[b950088]1266      argc-=2; argv+=2; 
[7360fab]1267    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter")) {
1268      filter = owl_function_smartfilter(0);
1269      argc-=2; argv+=2; 
1270    } else if (argc>=2 && !strcmp(argv[1], "--smart-filter-instance")) {
1271      filter = owl_function_smartfilter(1);
1272      argc-=2; argv+=2; 
1273   } else {
[b950088]1274      owl_function_makemsg("Invalid arguments to command 'prev'.");
1275      return(NULL);
1276    }
1277  }
1278  owl_function_prevmsg_full(filter, skip_deleted, first_if_none);
[7360fab]1279  if (filter) owl_free(filter);
[b950088]1280  return(NULL);
[7d4fbcd]1281}
1282
[e19eb97]1283char *owl_command_smartnarrow(int argc, const char *const *argv, const char *buff)
[cf83b7a]1284{
[7360fab]1285  char *filtname = NULL;
1286
[7d4fbcd]1287  if (argc == 1) {
[7360fab]1288    filtname = owl_function_smartfilter(0);
1289  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1290    filtname = owl_function_smartfilter(1);
[7d4fbcd]1291  } else {
1292    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1293  }
[7360fab]1294  if (filtname) {
[3895e23]1295    owl_function_change_currentview_filter(filtname);
[7360fab]1296    owl_free(filtname);
1297  }
[7d4fbcd]1298  return NULL;
1299}
1300
[e19eb97]1301char *owl_command_smartfilter(int argc, const char *const *argv, const char *buff)
[cf83b7a]1302{
[7360fab]1303  char *filtname = NULL;
1304
1305  if (argc == 1) {
1306    filtname = owl_function_smartfilter(0);
1307  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
1308    filtname = owl_function_smartfilter(1);
1309  } else {
1310    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
1311  }
1312  return filtname;
1313}
1314
[c79a047]1315void owl_command_expunge(void)
[cf83b7a]1316{
[7d4fbcd]1317  owl_function_expunge();
1318}
1319
[c79a047]1320void owl_command_first(void)
[cf83b7a]1321{
[7d4fbcd]1322  owl_global_set_rightshift(&g, 0);
1323  owl_function_firstmsg();
1324}
1325
[c79a047]1326void owl_command_last(void)
[cf83b7a]1327{
[7d4fbcd]1328  owl_function_lastmsg();
1329}
1330
[c79a047]1331void owl_command_resize(void)
[cf83b7a]1332{
[7d4fbcd]1333  owl_function_resize();
1334}
1335
[c79a047]1336void owl_command_redisplay(void)
[cf83b7a]1337{
[7d4fbcd]1338  owl_function_full_redisplay();
1339  owl_global_set_needrefresh(&g);
1340}
1341
[c79a047]1342void owl_command_shift_right(void)
[cf83b7a]1343{
[7d4fbcd]1344  owl_function_shift_right();
1345}
1346
[c79a047]1347void owl_command_shift_left(void)
[cf83b7a]1348{
[7d4fbcd]1349  owl_function_shift_left();
1350}
1351
[c79a047]1352void owl_command_unsuball(void)
[cf83b7a]1353{
[7d4fbcd]1354  owl_function_unsuball();
1355}
1356
[e19eb97]1357char *owl_command_loadsubs(int argc, const char *const *argv, const char *buff)
[cf83b7a]1358{
[7d4fbcd]1359  if (argc == 2) {
1360    owl_function_loadsubs(argv[1]);
1361  } else if (argc == 1) {
1362    owl_function_loadsubs(NULL);
1363  } else {
1364    owl_function_makemsg("Wrong number of arguments for load-subs.");
[7933748]1365    return(NULL);
[7d4fbcd]1366  }
[7933748]1367  return(NULL);
1368}
1369
1370
[e19eb97]1371char *owl_command_loadloginsubs(int argc, const char *const *argv, const char *buff)
[cf83b7a]1372{
[7933748]1373  if (argc == 2) {
1374    owl_function_loadloginsubs(argv[1]);
1375  } else if (argc == 1) {
1376    owl_function_loadloginsubs(NULL);
1377  } else {
1378    owl_function_makemsg("Wrong number of arguments for load-subs.");
1379    return(NULL);
1380  }
1381  return(NULL);
[7d4fbcd]1382}
1383
[c79a047]1384void owl_command_suspend(void)
[cf83b7a]1385{
[7d4fbcd]1386  owl_function_suspend();
1387}
1388
[e19eb97]1389char *owl_command_start_command(int argc, const char *const *argv, const char *buff)
[cf83b7a]1390{
[7d4fbcd]1391  buff = skiptokens(buff, 1);
1392  owl_function_start_command(buff);
[cf83b7a]1393  return(NULL);
[7d4fbcd]1394}
1395
[e19eb97]1396char *owl_command_zaway(int argc, const char *const *argv, const char *buff)
[cf83b7a]1397{
[7d4fbcd]1398  if ((argc==1) ||
1399      ((argc==2) && !strcmp(argv[1], "on"))) {
1400    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
1401    owl_function_zaway_on();
1402    return NULL;
1403  }
1404
1405  if (argc==2 && !strcmp(argv[1], "off")) {
1406    owl_function_zaway_off();
1407    return NULL;
1408  }
1409
1410  if (argc==2 && !strcmp(argv[1], "toggle")) {
1411    owl_function_zaway_toggle();
1412    return NULL;
1413  }
1414
1415  buff = skiptokens(buff, 1);
1416  owl_global_set_zaway_msg(&g, buff);
1417  owl_function_zaway_on();
1418  return NULL;
1419}
1420
1421
[e19eb97]1422char *owl_command_aaway(int argc, const char *const *argv, const char *buff)
[4b660cc]1423{
1424  if ((argc==1) ||
1425      ((argc==2) && !strcmp(argv[1], "on"))) {
1426    owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
1427    owl_function_aaway_on();
1428    return NULL;
1429  }
1430
1431  if (argc==2 && !strcmp(argv[1], "off")) {
1432    owl_function_aaway_off();
1433    return NULL;
1434  }
1435
1436  if (argc==2 && !strcmp(argv[1], "toggle")) {
1437    owl_function_aaway_toggle();
1438    return NULL;
1439  }
1440
1441  buff = skiptokens(buff, 1);
1442  owl_global_set_aaway_msg(&g, buff);
1443  owl_function_aaway_on();
1444  return NULL;
1445}
1446
1447
[e19eb97]1448char *owl_command_away(int argc, const char *const *argv, const char *buff)
[4b660cc]1449{
[8ba37ec]1450  if ((argc==1) ||
1451      ((argc==2) && !strcmp(argv[1], "on"))) {
1452    owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
1453    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
1454    owl_function_aaway_on();
1455    owl_function_zaway_on();
[2b237308]1456    owl_function_makemsg("Away messages set.");
[8ba37ec]1457    return NULL;
1458  }
1459
1460  if (argc==2 && !strcmp(argv[1], "off")) {
1461    owl_function_aaway_off();
1462    owl_function_zaway_off();
1463    return NULL;
1464  }
1465
1466  if (argc==2 && !strcmp(argv[1], "toggle")) {
1467    /* if either one is on, turn it off, otherwise toggle both (turn
1468     *  them both on)
1469     */
1470    if (!owl_global_is_zaway(&g) && !owl_global_is_aaway(&g)) {
1471      owl_function_aaway_toggle();
1472      owl_function_zaway_toggle();
1473      owl_function_makemsg("Away messages set.");
1474    } else {
1475      if (owl_global_is_zaway(&g)) owl_function_zaway_toggle();
1476      if (owl_global_is_aaway(&g)) owl_function_aaway_toggle();
1477      owl_function_makemsg("Away messages off.");
1478    }
1479    return NULL;
1480  }
1481
1482  buff = skiptokens(buff, 1);
1483  owl_global_set_aaway_msg(&g, buff);
1484  owl_global_set_zaway_msg(&g, buff);
1485  owl_function_aaway_on();
1486  owl_function_zaway_on();
1487  owl_function_makemsg("Away messages set.");
[4b660cc]1488  return NULL;
1489}
1490
[e19eb97]1491char *owl_command_set(int argc, const char *const *argv, const char *buff)
[cf83b7a]1492{
[e19eb97]1493  const char *var, *val;
[7d4fbcd]1494  int  silent=0;
[486688f]1495  int requirebool=0;
[7d4fbcd]1496
1497  if (argc == 1) {
1498    owl_function_printallvars();
1499    return NULL;
[486688f]1500  } 
1501
1502  if (argc > 1 && !strcmp("-q",argv[1])) {
[7d4fbcd]1503    silent = 1;
[486688f]1504    argc--; argv++;
1505  }
1506
1507  if (argc == 2) {
1508    var=argv[1];
1509    val="on";
1510    requirebool=1;
[7d4fbcd]1511  } else if (argc == 3) {
1512    var=argv[1];
1513    val=argv[2];
1514  } else {
1515    owl_function_makemsg("Wrong number of arguments for set command");
1516    return NULL;
1517  }
[486688f]1518  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool);
1519  return NULL;
1520}
[7d4fbcd]1521
[e19eb97]1522char *owl_command_unset(int argc, const char *const *argv, const char *buff)
[cf83b7a]1523{
[e19eb97]1524  const char *var, *val;
[486688f]1525  int  silent=0;
1526
1527  if (argc > 1 && !strcmp("-q",argv[1])) {
1528    silent = 1;
1529    argc--; argv++;
1530  }
1531  if (argc == 2) {
1532    var=argv[1];
1533    val="off";
1534  } else {
1535    owl_function_makemsg("Wrong number of arguments for unset command");
1536    return NULL;
1537  }
1538  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1);
[7d4fbcd]1539  return NULL;
1540}
1541
[e19eb97]1542char *owl_command_print(int argc, const char *const *argv, const char *buff)
[cf83b7a]1543{
[e19eb97]1544  const char *var;
[7d4fbcd]1545  char valbuff[1024];
1546
1547  if (argc==1) {
1548    owl_function_printallvars();
1549    return NULL;
1550  } else if (argc!=2) {
1551    owl_function_makemsg("Wrong number of arguments for print command");
1552    return NULL;
1553  }
1554
1555  var=argv[1];
1556   
1557  if (0 == owl_variable_get_tostring(owl_global_get_vardict(&g), 
1558                                     var, valbuff, 1024)) {
1559    owl_function_makemsg("%s = '%s'", var, valbuff);
1560  } else {
1561    owl_function_makemsg("Unknown variable '%s'.", var);
1562  }
1563  return NULL;
1564}
1565
1566
[e19eb97]1567char *owl_command_exec(int argc, const char *const *argv, const char *buff)
[cf83b7a]1568{
[7d4fbcd]1569  return owl_function_exec(argc, argv, buff, 0);
1570}
1571
[e19eb97]1572char *owl_command_pexec(int argc, const char *const *argv, const char *buff)
[cf83b7a]1573{
[7d4fbcd]1574  return owl_function_exec(argc, argv, buff, 1);
1575}
1576
[e19eb97]1577char *owl_command_aexec(int argc, const char *const *argv, const char *buff)
[cf83b7a]1578{
[7d4fbcd]1579  return owl_function_exec(argc, argv, buff, 2);
1580}
1581
[e19eb97]1582char *owl_command_perl(int argc, const char *const *argv, const char *buff)
[cf83b7a]1583{
[7d4fbcd]1584  return owl_function_perl(argc, argv, buff, 0);
1585}
1586
[e19eb97]1587char *owl_command_pperl(int argc, const char *const *argv, const char *buff)
[cf83b7a]1588{
[7d4fbcd]1589  return owl_function_perl(argc, argv, buff, 1);
1590}
1591
[e19eb97]1592char *owl_command_aperl(int argc, const char *const *argv, const char *buff)
[cf83b7a]1593{
[7d4fbcd]1594  return owl_function_perl(argc, argv, buff, 2);
1595}
1596
[e19eb97]1597char *owl_command_multi(int argc, const char *const *argv, const char *buff)
[cf83b7a]1598{
[42c2a80]1599  char *lastrv = NULL, *newbuff;
[7d4fbcd]1600  char **commands;
1601  int  ncommands, i;
1602  if (argc < 2) {
1603    owl_function_makemsg("Invalid arguments to 'multi' command.");   
1604    return NULL;
1605  }
[42c2a80]1606  newbuff = owl_strdup(skiptokens(buff, 1));
[7d4fbcd]1607  if (!strcmp(argv[0], "(")) {
1608    for (i=strlen(newbuff)-1; i>=0; i--) {
1609      if (newbuff[i] == ')') {
1610        newbuff[i] = '\0';
1611        break;
1612      } else if (newbuff[i] != ' ') {
1613        owl_function_makemsg("Invalid arguments to 'multi' command.");   
1614        owl_free(newbuff);
1615        return NULL;
1616      }
1617    }
1618  }
1619  commands = atokenize(newbuff, ";", &ncommands);
1620  for (i=0; i<ncommands; i++) {
1621    if (lastrv) {
1622      owl_free(lastrv);
1623    }
1624    lastrv = owl_function_command(commands[i]);
1625  }
[42c2a80]1626  owl_free(newbuff);
[7d4fbcd]1627  atokenize_free(commands, ncommands);
1628  return lastrv;
1629}
1630
1631
[e19eb97]1632char *owl_command_alias(int argc, const char *const *argv, const char *buff)
[cf83b7a]1633{
[7d4fbcd]1634  if (argc < 3) {
1635    owl_function_makemsg("Invalid arguments to 'alias' command.");
1636    return NULL;
1637  }
1638  buff = skiptokens(buff, 2);
1639  owl_function_command_alias(argv[1], buff);
1640  return (NULL);
1641}
1642
1643
[e19eb97]1644char *owl_command_bindkey(int argc, const char *const *argv, const char *buff)
[cf83b7a]1645{
[7d4fbcd]1646  owl_keymap *km;
1647  int ret;
1648
1649  if (argc < 5 || strcmp(argv[3], "command")) {
[f1e629d]1650    owl_function_makemsg("Usage: bindkey <keymap> <binding> command <cmd>");
[7d4fbcd]1651    return NULL;
1652  }
1653  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]);
1654  if (!km) {
1655    owl_function_makemsg("No such keymap '%s'", argv[1]);
1656    return NULL;
1657  }
1658  buff = skiptokens(buff, 4);
1659  ret = owl_keymap_create_binding(km, argv[2], buff, NULL, "*user*");
1660  if (ret!=0) {
1661    owl_function_makemsg("Unable to bind '%s' in keymap '%s' to '%s'.",
1662                         argv[2], argv[1], buff);
1663    return NULL;
1664  }
1665  return NULL;
1666}
1667
[c79a047]1668void owl_command_quit(void)
[cf83b7a]1669{
[7d4fbcd]1670  owl_function_quit();
1671}
1672
[e19eb97]1673char *owl_command_debug(int argc, const char *const *argv, const char *buff)
[cf83b7a]1674{
[7d4fbcd]1675  if (argc<2) {
1676    owl_function_makemsg("Need at least one argument to debug command");
[ecd5dc5]1677    return(NULL);
[7d4fbcd]1678  }
1679
1680  if (!owl_global_is_debug_fast(&g)) {
1681    owl_function_makemsg("Debugging is not turned on");
[ecd5dc5]1682    return(NULL);
[7d4fbcd]1683  }
1684
[554a2b8]1685  owl_function_debugmsg("%s", argv[1]);
[ecd5dc5]1686  return(NULL);
[7d4fbcd]1687}
1688
[e19eb97]1689char *owl_command_term(int argc, const char *const *argv, const char *buff)
[cf83b7a]1690{
[ecd5dc5]1691  if (argc<2) {
1692    owl_function_makemsg("Need at least one argument to the term command");
1693    return(NULL);
1694  }
1695
1696  if (!strcmp(argv[1], "raise")) {
1697    owl_function_xterm_raise();
1698  } else if (!strcmp(argv[1], "deiconify")) {
1699    owl_function_xterm_deiconify();
1700  } else {
[d09e5a1]1701    owl_function_makemsg("Unknown terminal subcommand");
[ecd5dc5]1702  }
1703  return(NULL);
[7d4fbcd]1704}
1705
[e19eb97]1706char *owl_command_zlog(int argc, const char *const *argv, const char *buff)
[cf83b7a]1707{
[425c013]1708  if ((argc<2) || (argc>3)) {
[7d4fbcd]1709    owl_function_makemsg("Wrong number of arguments for zlog command");
[425c013]1710    return(NULL);
[7d4fbcd]1711  }
1712
1713  if (!strcmp(argv[1], "in")) {
[425c013]1714    if (argc>2) {
1715      owl_global_set_tty(&g, argv[2]);
1716    }
[31e48a3]1717    owl_zephyr_zlog_in();
[7d4fbcd]1718  } else if (!strcmp(argv[1], "out")) {
[425c013]1719    if (argc!=2) {
1720      owl_function_makemsg("Wrong number of arguments for zlog command");
1721      return(NULL);
1722    }
[31e48a3]1723    owl_zephyr_zlog_out();
[7d4fbcd]1724  } else {
1725    owl_function_makemsg("Invalid subcommand for zlog");
1726  }
[425c013]1727  return(NULL);
[7d4fbcd]1728}
1729
[e19eb97]1730char *owl_command_subscribe(int argc, const char *const *argv, const char *buff)
[cf83b7a]1731{
[e19eb97]1732  const char *class, *instance, *recip="";
[bde7714]1733  int temp=0;
[3617286]1734  int ret=0;
[f830d84]1735
1736  if (argc < 2) {
[7d4fbcd]1737    owl_function_makemsg("Not enough arguments to the subscribe command");
[bde7714]1738    return(NULL);
1739  }
1740  argc--;
1741  argv++;
1742
1743  if (!strcmp(argv[0], "-t")) {
1744    temp=1;
1745    argc--;
1746    argv++;
1747  }
[f830d84]1748  if (argc < 1) {
[bde7714]1749    owl_function_makemsg("Not enough arguments to the subscribe command");
1750    return(NULL);
1751  }
1752
[f830d84]1753  if (argc > 3) {
[7d4fbcd]1754    owl_function_makemsg("Too many arguments to the subscribe command");
[bde7714]1755    return(NULL);
[7d4fbcd]1756  }
1757
[f830d84]1758  class = argv[0];
1759
1760  if (argc == 1) {
1761    instance = "*";
1762  } else {
1763    instance = argv[1];
1764  }
1765
1766  if (argc <= 2) {
[7d4fbcd]1767    recip="";
[bde7714]1768  } else if (argc==3) {
1769    recip=argv[2];
[7d4fbcd]1770  }
1771
[f830d84]1772  ret = owl_function_subscribe(class, instance, recip);
[3617286]1773  if (!temp && !ret) {
[f830d84]1774    owl_zephyr_addsub(NULL, class, instance, recip);
[bde7714]1775  }
1776  return(NULL);
[7d4fbcd]1777}
1778
1779
[e19eb97]1780char *owl_command_unsubscribe(int argc, const char *const *argv, const char *buff)
[cf83b7a]1781{
[e19eb97]1782  const char *class, *instance, *recip="";
[bde7714]1783  int temp=0;
[7d4fbcd]1784
[f830d84]1785  if (argc < 2) {
[7d4fbcd]1786    owl_function_makemsg("Not enough arguments to the unsubscribe command");
[bde7714]1787    return(NULL);
1788  }
1789  argc--;
1790  argv++;
1791
1792  if (!strcmp(argv[0], "-t")) {
1793    temp=1;
1794    argc--;
1795    argv++;
1796  }
[f830d84]1797  if (argc < 1) {
1798    owl_function_makemsg("Not enough arguments to the unsubscribe command");
[bde7714]1799    return(NULL);
1800  }
1801
[f830d84]1802  if (argc > 3) {
[7d4fbcd]1803    owl_function_makemsg("Too many arguments to the unsubscribe command");
[bde7714]1804    return(NULL);
[7d4fbcd]1805  }
1806
[f830d84]1807  class = argv[0];
1808
1809  if (argc == 1) {
1810    instance = "*";
1811  } else {
1812    instance = argv[1];
1813  }
1814
1815  if (argc <= 2) {
[7d4fbcd]1816    recip="";
[bde7714]1817  } else if (argc==3) {
1818    recip=argv[2];
[7d4fbcd]1819  }
1820
[f830d84]1821  owl_function_unsubscribe(class, instance, recip);
[bde7714]1822  if (!temp) {
[f830d84]1823    owl_zephyr_delsub(NULL, class, instance, recip);
[bde7714]1824  }
1825  return(NULL);
[7d4fbcd]1826}
1827
[e19eb97]1828char *owl_command_echo(int argc, const char *const *argv, const char *buff)
[cf83b7a]1829{
[7d4fbcd]1830  buff = skiptokens(buff, 1);
1831  owl_function_popless_text(buff);
1832  return NULL;
1833}
1834
[cf83b7a]1835void owl_command_getsubs(void)
1836{
[7d4fbcd]1837  owl_function_getsubs();
1838}
1839
[cf83b7a]1840void owl_command_status(void)
1841{
[7d4fbcd]1842  owl_function_status();
1843}
1844
[e19eb97]1845char *owl_command_zwrite(int argc, const char *const *argv, const char *buff)
[cf83b7a]1846{
[ce7db4d]1847  owl_zwrite z;
[1c6c4d3]1848
[5b85d19]1849  if (!owl_global_is_havezephyr(&g)) {
1850    owl_function_makemsg("Zephyr is not available");
1851    return(NULL);
1852  }
[1c6c4d3]1853  /* check for a zwrite -m */
[ce7db4d]1854  owl_zwrite_create_from_line(&z, buff);
1855  if (owl_zwrite_is_message_set(&z)) {
1856    owl_function_zwrite(buff, NULL);
1857    owl_zwrite_free(&z);
1858    return (NULL);
[1c6c4d3]1859  }
1860
[7d4fbcd]1861  if (argc < 2) {
1862    owl_function_makemsg("Not enough arguments to the zwrite command.");
1863  } else {
[ce7db4d]1864    owl_function_zwrite_setup(buff);
[7d4fbcd]1865  }
[ce7db4d]1866  return(NULL);
[7d4fbcd]1867}
1868
[e19eb97]1869char *owl_command_aimwrite(int argc, const char *const *argv, const char *buff)
[cf83b7a]1870{
[65b2173]1871  char *newbuff, *recip;
[e19eb97]1872  const char *const *myargv;
[944004c]1873  int i, j, myargc;
[fa4f9c3]1874  owl_message *m;
[658dc2f]1875 
[aa5f725]1876  if (!owl_global_is_aimloggedin(&g)) {
1877    owl_function_makemsg("You are not logged in to AIM.");
1878    return(NULL);
1879  }
1880
[d09e5a1]1881  if (argc < 2) {
1882    owl_function_makemsg("Not enough arguments to the aimwrite command.");
[aa5f725]1883    return(NULL);
[d09e5a1]1884  }
[aa5f725]1885
[944004c]1886  myargv=argv;
1887  if (argc<0) {
1888    owl_function_error("Unbalanced quotes in aimwrite");
1889    return(NULL);
1890  }
1891  myargc=argc;
1892  if (myargc && *(myargv[0])!='-') {
1893    myargc--;
1894    myargv++;
1895  }
1896  while (myargc) {
1897    if (!strcmp(myargv[0], "-m")) {
1898      if (myargc<2) {
1899        break;
1900      }
1901
1902      /* Once we have -m, gobble up everything else on the line */
1903      myargv++;
1904      myargc--;
1905      newbuff=owl_strdup("");
1906      while (myargc) {
[27f6487]1907        newbuff=owl_realloc(newbuff, strlen(newbuff)+strlen(myargv[0])+5);
[944004c]1908        strcat(newbuff, myargv[0]);
1909        strcat(newbuff, " ");
1910        myargc--;
1911        myargv++;
1912      }
[4083c49]1913      if (strlen(newbuff) >= 1)
1914        newbuff[strlen(newbuff) - 1] = '\0'; /* remove last space */
[944004c]1915
1916      recip=owl_malloc(strlen(argv[0])+5);
1917      sprintf(recip, "%s ", argv[1]);
1918      owl_aim_send_im(recip, newbuff);
[fa4f9c3]1919      m=owl_function_make_outgoing_aim(newbuff, recip);
1920      if (m) { 
1921          owl_global_messagequeue_addmsg(&g, m);
1922      } else {
1923          owl_function_error("Could not create outgoing AIM message");
1924      }
1925
[944004c]1926      owl_free(recip);
1927      owl_free(newbuff);
1928      return(NULL);
1929    } else {
1930      /* we don't care */
1931      myargv++;
1932      myargc--;
1933    }
1934  }
1935
[658dc2f]1936  /* squish arguments together to make one screenname w/o spaces for now */
1937  newbuff=owl_malloc(strlen(buff)+5);
1938  sprintf(newbuff, "%s ", argv[0]);
1939  j=argc-1;
1940  for (i=0; i<j; i++) {
1941    strcat(newbuff, argv[i+1]);
1942  }
1943   
1944  owl_function_aimwrite_setup(newbuff);
1945  owl_free(newbuff);
[aa5f725]1946  return(NULL);
[d09e5a1]1947}
1948
[e19eb97]1949char *owl_command_loopwrite(int argc, const char *const *argv, const char *buff)
[37eab7f]1950{
1951  owl_function_loopwrite_setup();
1952  return(NULL);
1953}
1954
[e19eb97]1955char *owl_command_zcrypt(int argc, const char *const *argv, const char *buff)
[cf83b7a]1956{
[9ceee9d]1957#ifdef OWL_ENABLE_ZCRYPT
[ce7db4d]1958  owl_zwrite z;
1959
[9ceee9d]1960  if (!owl_global_is_havezephyr(&g)) {
1961    owl_function_makemsg("Zephyr is not available");
1962    return(NULL);
1963  }
1964  /* check for a zcrypt -m */
[ce7db4d]1965  owl_zwrite_create_from_line(&z, buff);
1966  if (owl_zwrite_is_message_set(&z)) {
[9ceee9d]1967    owl_function_zcrypt(buff, NULL);
[ce7db4d]1968    owl_zwrite_free(&z);
1969    return (NULL);
[d309eb3]1970  }
1971
1972  if (argc < 2) {
1973    owl_function_makemsg("Not enough arguments to the zcrypt command.");
1974  } else {
[ce7db4d]1975    owl_function_zwrite_setup(buff);
[d309eb3]1976  }
1977  return(NULL);
[9ceee9d]1978#else
1979  owl_function_makemsg("This Owl does not support zcrypt");
[fea5ddf]1980  return NULL;
[9ceee9d]1981#endif
[d309eb3]1982}
1983
[e19eb97]1984char *owl_command_reply(int argc, const char *const *argv, const char *buff)
[cf83b7a]1985{
[7d4fbcd]1986  int edit=0;
1987 
[8df36cc]1988  if (argc>=2 && !strcmp("-e", argv[1])) {
[7d4fbcd]1989    edit=1;
1990    argv++;
[217a43e]1991    argc--;
[7d4fbcd]1992  }
1993
1994  if ((argc==1) || (argc==2 && !strcmp(argv[1], "all"))) {   
1995    owl_function_reply(0, !edit);
[e75011e]1996  } else if (argc==2 && !strcmp(argv[1], "sender")) {
[7d4fbcd]1997    owl_function_reply(1, !edit);
[e75011e]1998  } else if (argc==2 && !strcmp(argv[1], "zaway")) {
[c08c70a]1999    const owl_message *m;
[9e5c9f3]2000    const owl_view    *v;
[e75011e]2001    v = owl_global_get_current_view(&g);   
2002    m = owl_view_get_element(v, owl_global_get_curmsg(&g));
2003    if (m) owl_zephyr_zaway(m);
[7d4fbcd]2004  } else {
2005    owl_function_makemsg("Invalid arguments to the reply command.");
2006  }
2007  return NULL;
2008}
2009
[e19eb97]2010char *owl_command_filter(int argc, const char *const *argv, const char *buff)
[cf83b7a]2011{
[7d4fbcd]2012  owl_function_create_filter(argc, argv);
2013  return NULL;
2014}
2015
[e19eb97]2016char *owl_command_zlocate(int argc, const char *const *argv, const char *buff)
[cf83b7a]2017{
[2527615]2018  int auth;
2019 
2020  if (argc<2) {
2021    owl_function_makemsg("Too few arguments for zlocate command");
2022    return NULL;
2023  }
2024
2025  auth=1;
2026  if (!strcmp(argv[1], "-d")) {
2027    if (argc>2) {
2028      auth=0;
2029      argc--;
2030      argv++;
[7d4fbcd]2031    } else {
[2527615]2032      owl_function_makemsg("Missing arguments for zlocate command");
[7d4fbcd]2033      return NULL;
2034    }
2035  }
[2527615]2036
2037  argc--;
2038  argv++;
2039  owl_function_zlocate(argc, argv, auth);
[7d4fbcd]2040  return NULL;
2041}
2042
[3895e23]2043
2044/* Backwards compatability has made this kind of complicated:
2045 * view [<viewname>] [-f <filter> | -d <expression> | --home | -r ] [-s <style>]
2046 * view <filter>
2047 * view -d <expression>
2048 * view --home
2049 */
[e19eb97]2050char *owl_command_view(int argc, const char *const *argv, const char *buff)
[cf83b7a]2051{
[3895e23]2052  /* First take the 'view --home' and 'view -r' cases */
2053  if (argc == 2) {
2054    if (!strcmp(argv[1], "--home")) {
2055      owl_function_change_currentview_filter(owl_global_get_view_home(&g));
2056      return(NULL);
2057    } else if (!strcmp(argv[1], "-r")) {
2058      char *foo;
2059      foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g)));
2060      owl_function_change_currentview_filter(foo);
[c0a90c2]2061      owl_free(foo);
[3895e23]2062      return(NULL);
2063    }
[7d4fbcd]2064  }
2065
[ef56a67]2066  /* Now look for 'view <filter>' */
2067  if (argc==2) {
[3895e23]2068    owl_function_change_currentview_filter(argv[1]);
[ef56a67]2069    return(NULL);
2070  }
2071
2072  /* Now get 'view -d <expression>' */
[94e4899]2073  if (argc>=3 && !strcmp(argv[1], "-d")) {
[e19eb97]2074    const char **myargv;
[7d4fbcd]2075    int i;
2076
[e19eb97]2077    myargv=owl_malloc((argc*sizeof(const char *))+50);
[7d4fbcd]2078    myargv[0]="";
2079    myargv[1]="owl-dynamic";
2080    for (i=2; i<argc; i++) {
2081      myargv[i]=argv[i];
2082    }
2083    owl_function_create_filter(argc, myargv);
[3895e23]2084    owl_function_change_currentview_filter("owl-dynamic");
[7d4fbcd]2085    owl_free(myargv);
2086    return NULL;
2087  }
2088
[ef56a67]2089  /* Finally handle the general case */
2090  if (argc<3) {
2091    owl_function_makemsg("Too few arguments to the view command.");
2092    return(NULL);
[7d4fbcd]2093  }
[ef56a67]2094  argc--;
2095  argv++;
[3895e23]2096  if (strcmp(argv[0], "-f") &&
2097      strcmp(argv[0], "-d") &&
2098      strcmp(argv[0], "--home") &&
2099      strcmp(argv[0], "-s") &&
2100      strcmp(argv[0], "-r")) {
[ef56a67]2101    if (strcmp(argv[0], "main")) {
2102      owl_function_makemsg("No view named '%s'", argv[0]);
2103      return(NULL);
2104    }
2105    argc--;
2106    argv++;
2107  }
2108  while (argc) {
2109    if (!strcmp(argv[0], "-f")) {
2110      if (argc<2) {
2111        owl_function_makemsg("Too few argments to the view command");
2112        return(NULL);
2113      }
[3895e23]2114      owl_function_change_currentview_filter(argv[1]);
[ef56a67]2115      argc-=2;
2116      argv+=2;
2117    } else if (!strcmp(argv[0], "--home")) {
[3895e23]2118      owl_function_change_currentview_filter(owl_global_get_view_home(&g));
[ef56a67]2119      argc--;
2120      argv++;
[3895e23]2121    } else if (!strcmp(argv[0], "-r")) {
[e19eb97]2122      const char *foo;
[3895e23]2123      foo=owl_function_create_negative_filter(owl_view_get_filtname(owl_global_get_current_view(&g)));
2124      owl_function_change_currentview_filter(foo);
[ef56a67]2125    } else if (!strcmp(argv[0], "-s")) {
2126      if (argc<2) {
2127        owl_function_makemsg("Too few argments to the view command");
2128        return(NULL);
2129      }
2130      owl_function_change_style(owl_global_get_current_view(&g), argv[1]);
2131      argc-=2;
2132      argv+=2;
2133    } else {
2134      owl_function_makemsg("Too few argments to the view command");
2135      return(NULL);
2136    }
2137   
2138  }
2139  return(NULL);
[7d4fbcd]2140}
2141
[e19eb97]2142char *owl_command_show(int argc, const char *const *argv, const char *buff)
[cf83b7a]2143{
[7d4fbcd]2144  if (argc<2) {
2145    owl_function_help_for_command("show");
2146    return NULL;
2147  }
2148
2149  if (!strcmp(argv[1], "filter") || !strcmp(argv[1], "filters")) {
2150    if (argc==2) {
2151      owl_function_show_filters();
2152    } else {
2153      owl_function_show_filter(argv[2]);
2154    }
2155  } else if (argc==2 
2156             && (!strcmp(argv[1], "zpunts") || !strcmp(argv[1], "zpunted"))) {
2157    owl_function_show_zpunts();
2158  } else if (!strcmp(argv[1], "command") || !strcmp(argv[1], "commands")) {
2159    if (argc==2) {
2160      owl_function_show_commands();
2161    } else {
2162      owl_function_show_command(argv[2]);
2163    }
2164  } else if (!strcmp(argv[1], "variable") || !strcmp(argv[1], "variables")) {
2165    if (argc==2) {
2166      owl_function_show_variables();
2167    } else {
2168      owl_function_show_variable(argv[2]);
2169    }
2170  } else if (!strcmp(argv[1], "keymap") || !strcmp(argv[1], "keymaps")) {
2171    if (argc==2) {
2172      owl_function_show_keymaps();
2173    } else {
2174      owl_function_show_keymap(argv[2]);
2175    }
[ef56a67]2176  } else if (!strcmp(argv[1], "view")) {
2177    if (argc==3) {
2178      owl_function_show_view(argv[2]);
2179    } else {
2180      owl_function_show_view(NULL);
2181    }
[7d4fbcd]2182  } else if (!strcmp(argv[1], "colors")) {
2183    owl_function_show_colors();
[f1e629d]2184  } else if (!strcmp(argv[1], "styles")) {
2185    owl_function_show_styles();
[7d4fbcd]2186  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
2187    owl_function_getsubs();
2188  } else if (!strcmp(argv[1], "terminal") || !strcmp(argv[1], "term")) {
2189    owl_function_show_term();
2190  } else if (!strcmp(argv[1], "version")) {
2191    owl_function_about();
2192  } else if (!strcmp(argv[1], "status")) {
2193    owl_function_status();
[debb15d]2194  } else if (!strcmp(argv[1], "license")) {
2195    owl_function_show_license();
[799b60e]2196  } else if (!strcmp(argv[1], "quickstart")) {
2197    owl_function_show_quickstart();
[f17bff98]2198  } else if (!strcmp(argv[1], "startup")) {
[e19eb97]2199    const char *filename;
[f17bff98]2200   
[b363d83]2201    filename=owl_global_get_startupfile(&g);
[f17bff98]2202    owl_function_popless_file(filename);
[ec6ff52]2203  } else if (!strcmp(argv[1], "errors")) {
2204    owl_function_showerrs();
[7d4fbcd]2205  } else {
2206    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
2207    return NULL;
2208  }
2209  return NULL;
2210}
2211
[e19eb97]2212char *owl_command_viewclass(int argc, const char *const *argv, const char *buff)
[cf83b7a]2213{
[7360fab]2214  char *filtname;
[7d4fbcd]2215  if (argc!=2) {
2216    owl_function_makemsg("Wrong number of arguments to viewclass command");
2217    return NULL;
2218  }
[3abf28b]2219  filtname = owl_function_classinstfilt(argv[1], NULL);
[3895e23]2220  owl_function_change_currentview_filter(filtname);
[7360fab]2221  owl_free(filtname);
[7d4fbcd]2222  return NULL;
2223}
2224
[e19eb97]2225char *owl_command_viewuser(int argc, const char *const *argv, const char *buff)
[cf83b7a]2226{
[7360fab]2227  char *filtname;
[7d4fbcd]2228  if (argc!=2) {
2229    owl_function_makemsg("Wrong number of arguments to viewuser command");
2230    return NULL;
2231  }
[3abf28b]2232  filtname=owl_function_zuserfilt(argv[1]);
[3895e23]2233  owl_function_change_currentview_filter(filtname);
[7360fab]2234  owl_free(filtname);
[7d4fbcd]2235  return NULL;
2236}
2237
2238
[cf83b7a]2239void owl_command_pop_message(void)
2240{
[7d4fbcd]2241  owl_function_curmsg_to_popwin();
2242}
2243
[e19eb97]2244char *owl_command_delete(int argc, const char *const *argv, const char *buff)
[cf83b7a]2245{
[b950088]2246  int move_after = 1;
2247
[8ee73f8d]2248  if (argc>1 && !strcmp(argv[1], "--no-move")) {
[b950088]2249    move_after = 0;
2250    argc--; 
2251    argv++;
2252  }
2253
[7d4fbcd]2254  if (argc==1) {
[b950088]2255    owl_function_deletecur(move_after);
[7d4fbcd]2256    return NULL;
2257  }
2258
2259  if (argc==2 && !strcmp(argv[1], "view")) {
2260    owl_function_delete_curview_msgs(1);
2261    return NULL;
2262  }
2263
2264  if (argc==2 && !strcmp(argv[1], "trash")) {
2265    owl_function_delete_automsgs();
2266    return NULL;
2267  }
2268
[7360fab]2269  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
[7d4fbcd]2270    owl_function_delete_by_id(atoi(argv[2]), 1);
2271    return NULL;
2272  }
2273
2274  owl_function_makemsg("Unknown arguments to delete command");
2275  return NULL;
2276}
2277
[e19eb97]2278char *owl_command_undelete(int argc, const char *const *argv, const char *buff)
[cf83b7a]2279{
[b950088]2280  int move_after = 1;
2281
[8ee73f8d]2282  if (argc>1 && !strcmp(argv[1], "--no-move")) {
[b950088]2283    move_after = 0;
2284    argc--; 
2285    argv++;
2286  }
2287
[7d4fbcd]2288  if (argc==1) {
[b950088]2289    owl_function_undeletecur(move_after);
[7d4fbcd]2290    return NULL;
2291  }
2292
2293  if (argc==2 && !strcmp(argv[1], "view")) {
2294    owl_function_delete_curview_msgs(0);
2295    return NULL;
2296  }
2297
[7360fab]2298  if (argc==3 && (!strcmp(argv[1], "-id") || !strcmp(argv[1], "--id"))) {
[7d4fbcd]2299    owl_function_delete_by_id(atoi(argv[2]), 0);
2300    return NULL;
2301  }
2302
2303  owl_function_makemsg("Unknown arguments to delete command");
2304  return NULL;
2305}
2306
[c79a047]2307void owl_command_beep(void)
[cf83b7a]2308{
[7d4fbcd]2309  owl_function_beep();
2310}
2311
[e19eb97]2312char *owl_command_colorview(int argc, const char *const *argv, const char *buff)
[cf83b7a]2313{
[8fa9562]2314  if (argc < 2 || argc > 3) {
[7d4fbcd]2315    owl_function_makemsg("Wrong number of arguments to colorview command");
2316    return NULL;
2317  }
[8fa9562]2318  owl_function_color_current_filter(argv[1], (argc == 3 ? argv[2] : NULL));
[7d4fbcd]2319  return NULL;
2320}
2321
[e19eb97]2322char *owl_command_colorclass(int argc, const char *const *argv, const char *buff)
[5e0b690]2323{
[e19eb97]2324  const char *filtname;
[5e0b690]2325 
[8fa9562]2326  if (argc < 3 || argc > 4) {
[5e0b690]2327    owl_function_makemsg("Wrong number of arguments to colorclass command");
2328    return NULL;
2329  }
2330
2331  filtname=owl_function_classinstfilt(argv[1], NULL);
[8fa9562]2332  (void) owl_function_color_filter(filtname, argv[2], (argc == 4 ? argv[3] : NULL));
[5e0b690]2333  return NULL;
2334}
2335
[e19eb97]2336char *owl_command_zpunt(int argc, const char *const *argv, const char *buff)
[cf83b7a]2337{
[7d4fbcd]2338  owl_command_zpunt_and_zunpunt(argc, argv, 0);
2339  return NULL;
2340}
2341
[e19eb97]2342char *owl_command_zunpunt(int argc, const char *const *argv, const char *buff)
[cf83b7a]2343{
[7d4fbcd]2344  owl_command_zpunt_and_zunpunt(argc, argv, 1);
2345  return NULL;
2346}
2347
[e19eb97]2348void owl_command_zpunt_and_zunpunt(int argc, const char *const *argv, int type)
[cf83b7a]2349{
[7d4fbcd]2350  /* if type==0 then zpunt
2351   * if type==1 then zunpunt
2352   */
[e19eb97]2353  const char *class, *inst, *recip;
[7d4fbcd]2354
2355  class="message";
2356  inst="";
2357  recip="*";
2358
2359  if (argc==1) {
2360    /* show current punt filters */
2361    owl_function_show_zpunts();
2362    return;
2363  } else if (argc==2) {
2364    inst=argv[1];
2365  } else if (argc==3) {
2366    class=argv[1];
2367    inst=argv[2];
2368  } else if (argc==4) {
2369    class=argv[1];
2370    inst=argv[2];
2371    recip=argv[3];
2372  } else {
2373    owl_function_makemsg("Wrong number of arguments to the zpunt command");
2374    return;
2375  }
2376
2377  owl_function_zpunt(class, inst, recip, type);
2378  if (type==0) {
2379    owl_function_makemsg("<%s, %s, %s> added to punt list.", class, inst, recip);
2380  } else if (type==1) {
2381    owl_function_makemsg("<%s, %s, %s> removed from punt list.", class, inst, recip);
2382  }
2383}
2384
[e19eb97]2385char *owl_command_smartzpunt(int argc, const char *const *argv, const char *buff)
[cf83b7a]2386{
[d36f2cb]2387  if (argc == 1) {
2388    owl_function_smartzpunt(0);
2389  } else if (argc == 2 && (!strcmp(argv[1], "-i") || !strcmp(argv[1], "--instance"))) {
2390    owl_function_smartzpunt(1);
2391  } else {
2392    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
2393  }
2394  return NULL;
2395}
2396
[e19eb97]2397char *owl_command_punt(int argc, const char *const *argv, const char *buff)
[ce7b824]2398{
2399  owl_command_punt_unpunt(argc, argv, buff, 0);
2400  return NULL;
2401}
2402
[e19eb97]2403char *owl_command_unpunt(int argc, const char *const *argv, const char *buff)
[ce7b824]2404{
2405  owl_command_punt_unpunt(argc, argv, buff, 1);
2406  return NULL;
2407}
2408
[e19eb97]2409void owl_command_punt_unpunt(int argc, const char *const * argv, const char *buff, int unpunt)
[ce7b824]2410{
2411  owl_list * fl;
2412  owl_filter * f;
2413  char * text;
2414  int i;
2415
2416  fl = owl_global_get_puntlist(&g);
2417  if(argc == 1) {
2418    owl_function_show_zpunts();
2419  }
2420
2421  if(argc == 2) {
2422    /* Handle :unpunt <number> */
2423    if(unpunt && (i=atoi(argv[1])) !=0) {
2424      i--;      /* Accept 1-based indexing */
2425      if(i < owl_list_get_size(fl)) {
[4d86e06]2426        f = owl_list_get_element(fl, i);
[ce7b824]2427        owl_list_remove_element(fl, i);
2428        owl_filter_free(f);
2429        return;
2430      } else {
2431        owl_function_error("No such filter number: %d", i+1);
2432      }
2433    }
2434    text = owl_sprintf("filter %s", argv[1]);
[3e328b8]2435    owl_function_punt(text, unpunt);
2436    owl_free(text);
[ce7b824]2437  } else {
[3e328b8]2438    owl_function_punt(skiptokens(buff, 1), unpunt);
[ce7b824]2439  }
2440}
2441
2442
[e19eb97]2443char *owl_command_getview(int argc, const char *const *argv, const char *buff)
[cf83b7a]2444{
[e19eb97]2445  const char *filtname;
[8ee73f8d]2446  if (argc != 1) {
2447    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2448    return NULL;
2449  }
2450  filtname = owl_view_get_filtname(owl_global_get_current_view(&g));
[fa4562c]2451  if (filtname) return owl_strdup(filtname);
2452  return NULL;
[8ee73f8d]2453}
[d36f2cb]2454
[e19eb97]2455char *owl_command_getvar(int argc, const char *const *argv, const char *buff)
[cf83b7a]2456{
[8ee73f8d]2457  char tmpbuff[1024];
2458  if (argc != 2) {
2459    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2460    return NULL;
2461  }
2462  if (owl_variable_get_tostring(owl_global_get_vardict(&g), 
2463                                argv[1], tmpbuff, 1024)) {
2464    return NULL;
2465  }
2466  return owl_strdup(tmpbuff); 
2467}
[7d4fbcd]2468
[e19eb97]2469char *owl_command_getfilter(int argc, const char *const *argv, const char *buf)
[cdc6ff1]2470{
[4542047]2471  const owl_filter *f;
[cdc6ff1]2472  if (argc != 2) {
2473    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2474    return NULL;
2475  }
2476  f = owl_global_get_filter(&g, argv[1]);
2477  if (!f) {
2478    return NULL;
2479  }
2480  return owl_filter_print(f);
2481}
2482
[e19eb97]2483char *owl_command_search(int argc, const char *const *argv, const char *buff)
[cf83b7a]2484{
[1fd0b25]2485  int direction;
[e19eb97]2486  const char *buffstart;
[1fd0b25]2487
2488  direction=OWL_DIRECTION_DOWNWARDS;
2489  buffstart=skiptokens(buff, 1);
2490  if (argc>1 && !strcmp(argv[1], "-r")) {
2491    direction=OWL_DIRECTION_UPWARDS;
2492    buffstart=skiptokens(buff, 2);
2493  }
2494   
2495  if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) {
2496    owl_function_search_continue(direction);
2497  } else {
2498    owl_function_search_start(buffstart, direction);
2499  }
2500 
2501  return(NULL);
2502}
2503
[e19eb97]2504char *owl_command_setsearch(int argc, const char *const *argv, const char *buff)
[987ff51]2505{
[e19eb97]2506  const char *buffstart;
[987ff51]2507
2508  buffstart=skiptokens(buff, 1);
[ab225e0]2509  owl_function_search_start(*buffstart ? buffstart : NULL, OWL_DIRECTION_NONE);
[987ff51]2510 
2511  return(NULL);
2512}
2513
[e19eb97]2514char *owl_command_aimlogin(int argc, const char *const *argv, const char *buff)
[cf83b7a]2515{
[453bd70]2516  if ((argc<2) || (argc>3)) {
[d09e5a1]2517    owl_function_makemsg("Wrong number of arguments to aimlogin command");
2518    return(NULL);
2519  }
[aa5f725]2520
[453bd70]2521  /* if we get two arguments, ask for the password */
2522  if (argc==2) {
[4211f50b]2523    owl_global_set_buffercommand(&g, argv[1]);
[1b6b2f3]2524    owl_global_set_buffercallback(&g, &owl_callback_aimlogin);
[f1e629d]2525    owl_function_start_password("AIM Password: ");
[453bd70]2526    return(NULL);
[4211f50b]2527  } else {
2528    owl_function_aimlogin(argv[1], argv[2]);
[453bd70]2529  }
2530
[a352335c]2531  /* this is a test */
[d09e5a1]2532  return(NULL);
2533}
2534
[e19eb97]2535char *owl_command_aimlogout(int argc, const char *const *argv, const char *buff)
[cf83b7a]2536{
[aa5f725]2537  /* clear the buddylist */
2538  owl_buddylist_clear(owl_global_get_buddylist(&g));
2539
[d09e5a1]2540  owl_aim_logout();
2541  return(NULL);
2542}
2543
[e19eb97]2544char *owl_command_getstyle(int argc, const char *const *argv, const char *buff)
[216c734]2545{
[e19eb97]2546  const char *stylename;
[216c734]2547  if (argc != 1) {
2548    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);
2549    return NULL;
2550  }
2551  stylename = owl_view_get_style_name(owl_global_get_current_view(&g));
[fa4562c]2552  if (stylename) return owl_strdup(stylename);
2553  return NULL;
[216c734]2554}
2555
[e19eb97]2556char *owl_command_error(int argc, const char *const *argv, const char *buff)
[4692b70]2557{
2558    buff = skiptokens(buff, 1);
[554a2b8]2559    owl_function_error("%s", buff);
[4692b70]2560    return NULL;
2561}
2562
[e19eb97]2563char *owl_command_message(int argc, const char *const *argv, const char *buff)
[4692b70]2564{
2565    buff = skiptokens(buff, 1);
[554a2b8]2566    owl_function_makemsg("%s", buff);
[4692b70]2567    return NULL;
2568}
2569
[12e5f17]2570void owl_command_yes(void)
[f4d32cd]2571{
[cba04e0]2572  owl_message *m;
[9e5c9f3]2573  const owl_view *v;
[e19eb97]2574  const char *cmd;
[cba04e0]2575
2576  v = owl_global_get_current_view(&g);
2577
2578  /* bail if there's no current message */
2579  if (owl_view_get_size(v) < 1) {
2580    owl_function_error("No current message.");
[12e5f17]2581    return;
[cba04e0]2582  }
2583
2584  m = owl_view_get_element(v, owl_global_get_curmsg(&g));
[f4d32cd]2585  if(!owl_message_is_question(m)) {
2586    owl_function_error("That message isn't a question.");
[12e5f17]2587    return;
[f4d32cd]2588  }
2589  if(owl_message_is_answered(m)) {
2590    owl_function_error("You already answered that question.");
[12e5f17]2591    return;
[f4d32cd]2592  }
[ad15610]2593  cmd = owl_message_get_attribute_value(m, "yescommand");
[f4d32cd]2594  if(!cmd) {
[451db9e]2595    owl_function_error("No 'yes' command!");
[12e5f17]2596    return;
[f4d32cd]2597  }
2598
2599  owl_function_command_norv(cmd);
2600  owl_message_set_isanswered(m);
[12e5f17]2601  return;
[f4d32cd]2602}
2603
[12e5f17]2604void owl_command_no(void)
[f4d32cd]2605{
[cba04e0]2606  owl_message *m;
[9e5c9f3]2607  const owl_view *v;
[e19eb97]2608  const char *cmd;
[cba04e0]2609
2610  v = owl_global_get_current_view(&g);
2611
2612  /* bail if there's no current message */
2613  if (owl_view_get_size(v) < 1) {
2614    owl_function_error("No current message.");
[12e5f17]2615    return;
[cba04e0]2616  }
2617
2618  m = owl_view_get_element(v, owl_global_get_curmsg(&g));
[f4d32cd]2619  if(!owl_message_is_question(m)) {
2620    owl_function_error("That message isn't a question.");
[12e5f17]2621    return;
[f4d32cd]2622  }
2623  if(owl_message_is_answered(m)) {
2624    owl_function_error("You already answered that question.");
[12e5f17]2625    return;
[f4d32cd]2626  }
[ad15610]2627  cmd = owl_message_get_attribute_value(m, "nocommand");
[f4d32cd]2628  if(!cmd) {
[451db9e]2629    owl_function_error("No 'no' command!");
[12e5f17]2630    return;
[f4d32cd]2631  }
2632
2633  owl_function_command_norv(cmd);
2634  owl_message_set_isanswered(m);
[12e5f17]2635  return;
[f4d32cd]2636}
2637
[7d4fbcd]2638/*********************************************************************/
2639/************************** EDIT SPECIFIC ****************************/
2640/*********************************************************************/
2641
[cf83b7a]2642void owl_command_edit_cancel(owl_editwin *e)
2643{
[10b866d]2644  owl_history *hist;
2645
[7d4fbcd]2646  owl_function_makemsg("Command cancelled.");
[10b866d]2647
[a556caa]2648  if(owl_editwin_get_echochar(e) == 0) {
[6e400cc]2649    hist=owl_editwin_get_history(e);
2650    owl_history_store(hist, owl_editwin_get_text(e));
2651    owl_history_reset(hist);
2652  }
[10b866d]2653
[7d4fbcd]2654  owl_editwin_fullclear(e);
2655  owl_global_set_needrefresh(&g);
2656  wnoutrefresh(owl_editwin_get_curswin(e));
2657  owl_global_set_typwin_inactive(&g);
[10b866d]2658  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
[cf83b7a]2659
2660  owl_function_activate_keymap("recv");
[7d4fbcd]2661}
2662
[cf83b7a]2663void owl_command_edit_history_prev(owl_editwin *e)
2664{
[7d4fbcd]2665  owl_history *hist;
[e19eb97]2666  const char *ptr;
[7d4fbcd]2667
[10b866d]2668  hist=owl_editwin_get_history(e);
[7d4fbcd]2669  if (!owl_history_is_touched(hist)) {
2670    owl_history_store(hist, owl_editwin_get_text(e));
2671    owl_history_set_partial(hist);
2672  }
2673  ptr=owl_history_get_prev(hist);
2674  if (ptr) {
2675    owl_editwin_clear(e);
2676    owl_editwin_insert_string(e, ptr);
2677    owl_editwin_redisplay(e, 0);
2678    owl_global_set_needrefresh(&g);
2679  } else {
2680    owl_function_beep();
2681  }
2682}
2683
[cf83b7a]2684void owl_command_edit_history_next(owl_editwin *e)
2685{
[7d4fbcd]2686  owl_history *hist;
[e19eb97]2687  const char *ptr;
[7d4fbcd]2688
[10b866d]2689  hist=owl_editwin_get_history(e);
[7d4fbcd]2690  ptr=owl_history_get_next(hist);
2691  if (ptr) {
2692    owl_editwin_clear(e);
2693    owl_editwin_insert_string(e, ptr);
2694    owl_editwin_redisplay(e, 0);
2695    owl_global_set_needrefresh(&g);
2696  } else {
2697    owl_function_beep();
2698  }
2699}
2700
[e19eb97]2701char *owl_command_edit_insert_text(owl_editwin *e, int argc, const char *const *argv, const char *buff)
[cf83b7a]2702{
[7d4fbcd]2703  buff = skiptokens(buff, 1);
2704  owl_editwin_insert_string(e, buff);
2705  owl_editwin_redisplay(e, 0);
2706  owl_global_set_needrefresh(&g); 
2707  return NULL;
2708}
2709
[cf83b7a]2710void owl_command_editline_done(owl_editwin *e)
2711{
[10b866d]2712  owl_history *hist=owl_editwin_get_history(e);
[8df36cc]2713  char *rv, *cmd;
[7d4fbcd]2714
2715  owl_history_store(hist, owl_editwin_get_text(e));
2716  owl_history_reset(hist);
[10b866d]2717  owl_global_set_typwin_inactive(&g);
[8df36cc]2718  cmd = owl_strdup(owl_editwin_get_text(e));
2719  owl_editwin_fullclear(e);
2720  rv = owl_function_command(cmd);
2721  owl_free(cmd);
2722
[7d4fbcd]2723  wnoutrefresh(owl_editwin_get_curswin(e));
2724  owl_global_set_needrefresh(&g);
2725
2726  if (rv) {
2727    owl_function_makemsg("%s", rv);
2728    owl_free(rv);
2729  }
2730}
2731
[cf83b7a]2732
2733void owl_command_editresponse_done(owl_editwin *e)
2734{
[db8b00b]2735  owl_function_run_buffercommand();
[cf83b7a]2736
2737  owl_global_set_typwin_inactive(&g);
2738  owl_editwin_fullclear(e);
2739  wnoutrefresh(owl_editwin_get_curswin(e));
2740  owl_global_set_needrefresh(&g);
2741}
2742
2743
[435d6b2]2744void owl_command_edit_done(owl_editwin *e)
[cf83b7a]2745{
[10b866d]2746  owl_history *hist=owl_editwin_get_history(e);
2747
2748  owl_history_store(hist, owl_editwin_get_text(e));
2749  owl_history_reset(hist);
2750
[7d4fbcd]2751  owl_function_run_buffercommand();
[10b866d]2752  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE, NULL);
[7d4fbcd]2753  owl_editwin_fullclear(e);
2754  owl_global_set_typwin_inactive(&g);
2755  owl_global_set_needrefresh(&g);
2756  wnoutrefresh(owl_editwin_get_curswin(e));
2757}
2758
[435d6b2]2759void owl_command_edit_done_or_delete(owl_editwin *e)
[cf83b7a]2760{
[217a43e]2761  if (owl_editwin_is_at_end(e)) {
[435d6b2]2762    owl_command_edit_done(e);
[217a43e]2763  } else {
2764    owl_editwin_delete_char(e);
2765  }
2766}
2767
[7d4fbcd]2768
2769/*********************************************************************/
2770/*********************** POPLESS SPECIFIC ****************************/
2771/*********************************************************************/
2772
[cf83b7a]2773void owl_command_popless_quit(owl_viewwin *vw)
2774{
[7d4fbcd]2775  owl_popwin_close(owl_global_get_popwin(&g));
2776  owl_viewwin_free(vw);
2777  owl_global_set_needrefresh(&g);
2778}
Note: See TracBrowser for help on using the repository browser.