source: commands.c @ 3895e23

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