source: commands.c @ fd93b41

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