source: commands.c @ 1aee7d9

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 1aee7d9 was 1aee7d9, checked in by Erik Nygren <nygren@mit.edu>, 18 years ago
* Added RCS Id strings to all files. * 'show keymaps' shows details of all keymaps after summary list.
  • Property mode set to 100644
File size: 41.2 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\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.\n"),
54
55  OWLCMD_VOID("quit", owl_command_quit, OWL_CTX_ANY,
56              "exit owl",
57              "",
58              "Exit owl and run any shutdown activities."),
59  OWLCMD_ALIAS("exit", "quit"),
60  OWLCMD_ALIAS("q",    "quit"),
61 
62  OWLCMD_ARGS("start-command", owl_command_start_command, OWL_CTX_INTERACTIVE,
63              "prompts the user to enter a command",
64              "start-command [initial-value]",
65              "Initializes the command field to initial-value."),
66
67  OWLCMD_ARGS("alias", owl_command_alias, OWL_CTX_ANY,
68              "creates a command alias",
69              "alias <new_command> <old_command>",
70              "Creates a command alias from new_command to old_command.\n"
71              "Any arguments passed to <new_command> will be appended to\n"
72              "<old_command> before it is executed.\n"),
73
74  OWLCMD_ARGS("bindkey", owl_command_bindkey, OWL_CTX_ANY,
75              "creates a binding in a keymap",
76              "bindkey <keymap> <keyseq> command <command>",
77              "Binds a key sequence to a command within a keymap.\n"
78              "Use 'show keymaps' to see the existing keymaps.\n"
79              "Key sequences may be things like M-C-t or NPAGE.\n"),
80
81  OWLCMD_ARGS("zwrite", owl_command_zwrite, OWL_CTX_INTERACTIVE,
82              "send a zephyr",
83              "zwrite [-n] [-C] [-c class] [-i instance] [-r realm] [-O opcde] [<user> ...] ",
84              "Zwrite send a zephyr to the one or more users specified.\n\n"
85              "The following options are available:\n\n"
86              "-n    Do not send a ping message.\n\n"
87              "-C    If the message is sent to more than one user include a\n"
88              "      \"cc:\" line in the text\n\n"
89              "-c class\n"
90              "      Send to the specified zephyr class\n\n"
91              "-i instance\n"
92              "      Send to the specified zephyr instance\n\n"
93              "-r realm\n"
94              "      Send to a foreign realm\n"
95              "-O opcode\n"
96              "      Send to the specified opcode\n"),
97 
98  OWLCMD_ARGS("reply", owl_command_reply,  OWL_CTX_INTERACTIVE,
99              "reply to the current message",
100              "reply [-e] [ sender | all ]",
101              "If -e is specified, the zwrite command line is presented to\n"
102              "allow editing.\n\n"
103              "If 'sender' is specified, reply to the sender.\n\n"
104              "If 'all' or no args are specified, reply publically to the\n"
105              "same class/instance for non-personal messages and to the\n"
106              "sender for personal messages.\n"),
107
108  OWLCMD_ARGS("set", owl_command_set, OWL_CTX_ANY,
109              "set a variable value",
110              "set [-q] <variable> <value>\n"
111              "set",
112              "Set the named variable to the specified value.  If no\n"
113              "arguments are used print the value of all variables.\n"
114              "If -q is specified, is silent and doesn't print a message.\n"),
115
116  OWLCMD_ARGS("print", owl_command_print, OWL_CTX_ANY,
117              "print a variable value",
118              "print <variable>\n"
119              "print",
120              "Print the value of the named variable.  If no arugments\n"
121              "are used print the value of all variables.\n"),
122
123  OWLCMD_VOID("version", owl_command_version, OWL_CTX_ANY,
124              "print the version of the running owl", "", ""),
125
126  OWLCMD_ARGS("subscribe", owl_command_subscribe, OWL_CTX_ANY,
127              "subscribe to a zephyr class, instance, recipient",
128              "subscribe <class> <instance> [recipient]",
129              "Subscribe the specified class and instance.  If the recipient\n"
130              "is not listed on the command line it defaults\n"
131              "to * (the wildcard recipient).\n"),
132  OWLCMD_ALIAS("sub", "subscribe"),
133
134  OWLCMD_ARGS("unsubscribe", owl_command_unsubscribe, OWL_CTX_ANY,
135              "unsubscribe from a zephyr class, instance, recipient",
136              "unsubscribe <class> <instance> [recipient]",
137              "Unsubscribe from the specified class and instance.  If the\n"
138              "recipient is not listed on the command line it defaults\n"
139              "to * (the wildcard recipient).\n"),
140  OWLCMD_ALIAS("unsub", "unsubscribe"),
141
142  OWLCMD_VOID("unsuball", owl_command_unsuball, OWL_CTX_ANY,
143              "unsubscribe from all zephyrs", "", ""),
144 
145  OWLCMD_VOID("getsubs", owl_command_getsubs, OWL_CTX_ANY,
146              "print all current subscriptions",
147              "getsubs",
148              "getsubs retrieves the current subscriptions from the server\n"
149              "and displays them.\n"),
150
151  OWLCMD_ARGS("zpunt", owl_command_zpunt, OWL_CTX_ANY,
152              "suppress a given zephyr triplet",
153              "zpunt <class> <instance> [recipient]\n"
154              "zpunt <instance>",
155              "The zpunt command will supress message to the specified\n"
156              "zephyr triplet.  In the second usage messages as supressed\n"
157              "for class MESSAGE and the named instance.\n\n"
158              "SEE ALSO:  zunpunt, show zpunts\n"),
159
160  OWLCMD_ARGS("zunpunt", owl_command_zunpunt, OWL_CTX_ANY,
161              "undo a previous zpunt",
162              "zunpunt <class> <instance> [recipient]\n"
163              "zunpunt <instance>",
164              "The zunpunt command will allow messages that were previosly\n"
165              "suppressed to be received again.\n\n"
166              "SEE ALSO:  zpunt, show zpunts\n"),
167
168  OWLCMD_VOID("info", owl_command_info, OWL_CTX_INTERACTIVE,
169              "display detailed information about the current message",
170              "", ""),
171 
172  OWLCMD_ARGS("help", owl_command_help, OWL_CTX_INTERACTIVE,
173              "display help on using owl",
174              "help [command]", ""),
175 
176  OWLCMD_VOID("recv:shiftleft", owl_command_shift_left, OWL_CTX_INTERACTIVE,
177              "scrolls receive window to the left", "", ""),
178
179  OWLCMD_VOID("recv:shiftright", owl_command_shift_right, OWL_CTX_INTERACTIVE,
180              "scrolls receive window to the left", "", ""),
181
182  OWLCMD_VOID("recv:pagedown", owl_function_mainwin_pagedown, 
183              OWL_CTX_INTERACTIVE,
184              "scrolls down by a page", "", ""),
185
186  OWLCMD_VOID("recv:pageup", owl_function_mainwin_pageup, OWL_CTX_INTERACTIVE,
187              "scrolls up by a page", "", ""),
188
189  OWLCMD_INT ("recv:scroll", owl_function_page_curmsg, OWL_CTX_INTERACTIVE,
190              "scrolls current message up or down", 
191              "recv:scroll <numlines>", 
192              "Scrolls the current message up or down by <numlines>.\n"
193              "Scrolls up if <numlines> is negative, else scrolls down.\n"),
194
195  OWLCMD_VOID("next", owl_command_next, OWL_CTX_INTERACTIVE,
196              "move the pointer to the next message", "", ""),
197  OWLCMD_ALIAS("recv:next", "next"),
198
199  OWLCMD_VOID("prev", owl_command_prev, OWL_CTX_INTERACTIVE,
200              "move the pointer to the previous message", "", ""),
201  OWLCMD_ALIAS("recv:prev", "prev"),
202
203  OWLCMD_VOID("next-notdel", owl_command_next_notdeleted, OWL_CTX_INTERACTIVE,
204              "move the pointer to the next non-deleted message", "", ""),
205  OWLCMD_ALIAS("recv:next-notdel", "next-notdel"),
206
207  OWLCMD_VOID("prev-notdel", owl_command_prev_notdeleted, OWL_CTX_INTERACTIVE,
208              "move the pointer to the previous non-deleted message", "", ""),
209  OWLCMD_ALIAS("recv:prev-notdel", "prev-notdel"),
210
211  OWLCMD_VOID("recv:next-personal", owl_function_next_personal, 
212              OWL_CTX_INTERACTIVE,
213              "move the pointer to the next personal message", "", ""),
214
215  OWLCMD_VOID("recv:prev-personal", owl_function_prev_personal, 
216              OWL_CTX_INTERACTIVE,
217              "move the pointer to the previous personal message", "", ""),
218
219  OWLCMD_VOID("first", owl_command_first, OWL_CTX_INTERACTIVE,
220              "move the pointer to the first message", "", ""),
221  OWLCMD_ALIAS("recv:first", "first"),
222
223  OWLCMD_VOID("last", owl_command_last, OWL_CTX_INTERACTIVE,
224              "move the pointer to the last message", "", ""),
225  OWLCMD_ALIAS("recv:last", "last"),
226
227  OWLCMD_VOID("expunge", owl_command_expunge, OWL_CTX_INTERACTIVE,
228              "remove all messages marked for deletion", "", ""),
229
230  OWLCMD_VOID("resize", owl_command_resize, OWL_CTX_ANY,
231              "resize the window to the current screen size", "", ""),
232
233  OWLCMD_VOID("redisplay", owl_command_redisplay, OWL_CTX_ANY,
234              "redraw the entire window", "", ""),
235
236  OWLCMD_VOID("suspend", owl_command_suspend, OWL_CTX_ANY,
237              "suspend owl", "", ""),
238
239  OWLCMD_ARGS("echo", owl_command_echo, OWL_CTX_ANY,
240              "pops up a message in popup window",
241              "echo [args .. ]\n\n", ""),
242
243  OWLCMD_ARGS("exec", owl_command_exec, OWL_CTX_ANY,
244              "run a command from the shell",
245              "exec [args .. ]", ""),
246
247  OWLCMD_ARGS("aexec", owl_command_aexec, OWL_CTX_INTERACTIVE,
248              "run a command from the shell and display in an admin message",
249              "aexec [args .. ]", ""),
250
251  OWLCMD_ARGS("pexec", owl_command_pexec, OWL_CTX_INTERACTIVE,
252              "run a command from the shell and display in a popup window",
253              "pexec [args .. ]", ""),
254
255  OWLCMD_ARGS("perl", owl_command_perl, OWL_CTX_ANY,
256              "run a perl expression",
257              "perl [args .. ]", ""),
258
259  OWLCMD_ARGS("aperl", owl_command_aperl, OWL_CTX_INTERACTIVE,
260              "run a perl expression and display in an admin message",
261              "aperl [args .. ]", ""),
262
263  OWLCMD_ARGS("pperl", owl_command_pperl, OWL_CTX_INTERACTIVE,
264              "run a perl expression and display in a popup window",
265              "pperl [args .. ]", ""),
266
267  OWLCMD_ARGS("multi", owl_command_multi, OWL_CTX_ANY,
268              "runs multiple ;-separated commands",
269              "multi <command1> ( ; <command2> )*\n",
270              "Runs multiple semicolon-separated commands in order.\n"
271              "Note quoting isn't supported here yet.\n"
272              "If you want to do something fancy, use perl.\n"),
273
274  OWLCMD_ARGS("(", owl_command_multi, OWL_CTX_ANY,
275              "runs multiple ;-separated commands",
276              "'(' <command1> ( ; <command2> )* ')'\n",
277              "Runs multiple semicolon-separated commands in order.\n"
278              "You must have a space before the final ')'\n"
279              "Note quoting isn't supported here yet.\n"
280              "If you want to do something fancy, use perl.\n"),
281
282  OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN,
283              "pops up a message in a window", "", ""),
284
285  OWLCMD_VOID("openurl", owl_command_openurl, OWL_CTX_INTERACTIVE,
286              "opens up a URL from the current message",
287              "", 
288              "Uses the 'webbrowser' variable to determine\n"
289              "which browser to use.  Currently, 'netscape'\n"
290              "and 'galeon' are supported.\n"),
291
292  OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE,
293              "running a command from the shell",
294              "zaway [ on | off | toggle ]\n"
295              "zaway <message>",
296              "Turn on or off the default zaway message.  If a message is\n"
297              "specified turn on zaway with that message\n"),
298
299  OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY,
300              "load subscriptions from a file",
301              "load-subs <file>\n", ""),
302
303  OWLCMD_VOID("about", owl_command_about, OWL_CTX_INTERACTIVE,
304              "print information about owl", "", ""),
305
306  OWLCMD_VOID("status", owl_command_status, OWL_CTX_ANY,
307              "print status information about the running owl", "", ""),
308 
309  OWLCMD_ARGS("zlocate", owl_command_zlocate, OWL_CTX_INTERACTIVE,
310              "locate a user",
311              "zlocate [-d] <user>", 
312              "Performs a zlocate on a user and puts the result into\n"
313              "a popwin.  If -d is specified, does not authenticate\n"
314              "the lookup request.\n"),
315 
316  OWLCMD_ARGS("filter", owl_command_filter, OWL_CTX_ANY,
317              "create a message filter",
318              "filter <name> [ -c color ] [ <expression> ... ]",
319              "The filter command creates a filter with the specified name,\n"
320              "or if one already exists it is replaced.  Example filter\n"
321              "syntax would be:\n\n"
322              "     filter myfilter -c red ( class ^foobar$ ) or ( class ^quux$ and instance ^bar$ )\n\n"
323              "Valid matching fields are class, instance, recipient, sender,\n"
324              "opcode and realm. Valid operations are 'and', 'or' and 'not'.\n"
325              "Spaces must be present before and after parenthesis.  If the\n"
326              "optional color argument is used it specifies the color that\n"
327              "messages matching this filter should be displayed in.\n\n"
328
329              "SEE ALSO: view, viewclass, viewuser\n"),
330
331  OWLCMD_ARGS("colorview", owl_command_colorview, OWL_CTX_INTERACTIVE,
332              "change the color on the current filter",
333              "colorview <color>",
334              "The color of messages in the current filter will be changed\n"
335              "to <color>.  Use the 'show colors' command for a list\n"
336              "of valid colors.\n\n"
337              "SEE ALSO: 'show colors'\n"),
338
339  OWLCMD_ARGS("view", owl_command_view, OWL_CTX_INTERACTIVE,
340              "view messages matching a filter",
341              "view <filter>\n"
342              "view -d <expression>\n"
343              "view --home",
344              "In the first usage, The view command sets the current view to\n"
345              "the specified filter.   This causes only messages matching\n"
346              "that filter to be displayed.\n"
347              "\n"
348              "In the second usage a filter expression\n"
349              "and be specified directly\n"
350              "after -d.  Owl will build an internal filter based on this\n"
351              "filter and change the current view to use it.\n\n"
352              "If --home is specified, switches to the view specified by\n"
353              "the 'view_home' variable.\n\n"
354              "SEE ALSO: filter, viewclass, viewuser\n"),
355
356  OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE,
357              "view only messages similar to the current message",
358              "smartnarrow [-i]",
359              "If the curmsg is a personal message narrow\n"
360              "   to the converstaion with that user.\n"
361              "If the curmsg is a class message, instance foo, recip *\n"
362              "   message, narrow to the class, inst.\n"
363              "If the curmsg is a class message then narrow\n"
364              "    to the class.\n"
365              "If the curmsg is a class message and '-i' is specied\n"
366              "    then narrow to the class, instance\n"),
367
368  OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE,
369              "view messages matching a particular class",
370              "viewclass <class>",
371              "The viewclass command will automatically create a filter\n"
372              "matching the specified class and switch the current view\n"
373              "to it.\n\n"
374              "SEE ALSO: filter, view, viewuser\n"),
375  OWLCMD_ALIAS("vc", "viewclass"),
376
377  OWLCMD_ARGS("viewuser", owl_command_viewuser, OWL_CTX_INTERACTIVE,
378              "view messages matching a particular user",
379              "viewuser <user>",
380              "The viewuser command will automatically create a filter\n"
381              "matching the specified user and switch the current\n"
382              "view to it.\n\n"
383              "SEE ALSO: filter, view, viewclass\n"),
384  OWLCMD_ALIAS("vu", "viewuser"),
385
386  OWLCMD_ARGS("show", owl_command_show, OWL_CTX_INTERACTIVE,
387              "show information",
388              "show variables\n"
389              "show variable <variable>\n"
390              "show filters\n"
391              "show filter <filter>\n"
392              "show keymaps\n"
393              "show keymap <keymap>\n"
394              "show commands\n"
395              "show command <command>\n"
396              "show subs\n"
397              "show subscriptions\n"
398              "show zpunts\n"
399              "show colors\n"
400              "show terminal\n"
401              "show version\n"
402              "show status\n",
403
404              "Show colors will display a list of valid colors for the\n"
405              "     terminal."
406              "Show filters will list the names of all filters.\n"
407              "Show filter <filter> will show the definition of a particular\n"
408              "     filter.\n\n"
409              "Show zpunts will show the active zpunt filters.\n\n"
410              "Show keymaps will list the names of all keymaps.\n"
411              "Show keymap <keymap> will show the key bindings in a keymap.\n\n"
412              "Show commands will list the names of all keymaps.\n"
413              "Show command <command> will provide information about a command.\n\n"
414              "Show variables will list the names of all variables.\n\n"
415              "SEE ALSO: filter, view, alias, bindkey, help\n"),
416 
417  OWLCMD_ARGS("delete", owl_command_delete, OWL_CTX_INTERACTIVE,
418              "mark a message for deletion",
419              "delete [ -id msgid ]\n"
420              "delete view\n"
421              "delete trash",
422              "If no message id is specified the current message is marked\n"
423              "for deletion.  Otherwise the message with the given message\n"
424              "id is marked for deltion.\n"
425              "If 'trash' is specified, deletes all trash/auto messages\n"
426              "in the current view.\n"
427              "If 'view' is specified, deletes all messages in the\n"
428              "current view.\n"),
429  OWLCMD_ALIAS("del", "delete"),
430
431  OWLCMD_ARGS("undelete", owl_command_undelete, OWL_CTX_INTERACTIVE,
432              "unmark a message for deletion",
433              "undelete [ -id msgid ]\n"
434              "undelete view",
435              "If no message id is specified the current message is\n"
436              "unmarked for deletion.  Otherwise the message with the\n"
437              "given message id is marked for undeltion.\n"
438              "If 'view' is specified, undeletes all messages\n"
439              "in the current view.\n"),
440  OWLCMD_ALIAS("undel", "undelete"),
441
442  OWLCMD_VOID("beep", owl_command_beep, OWL_CTX_ANY,
443              "ring the terminal bell",
444              "beep",
445              "Beep will ring the terminal bell.\n"
446              "If the variable 'bell' has been\n"
447              "set to 'off' this command does nothing.\n"),
448
449  OWLCMD_ARGS("debug", owl_command_debug, OWL_CTX_ANY,
450              "prints a message into the debug log",
451              "debug <message>", ""),
452
453  /****************************************************************/
454  /************************* EDIT-SPECIFIC ************************/
455  /****************************************************************/
456
457  OWLCMD_VOID_CTX("edit:move-next-word", owl_editwin_move_to_nextword, 
458                  OWL_CTX_EDIT,
459                  "moves cursor forward a word",
460                  "", ""),
461
462  OWLCMD_VOID_CTX("edit:move-prev-word", owl_editwin_move_to_previousword, 
463                  OWL_CTX_EDIT,
464                  "moves cursor backwards a word",
465                  "", ""),
466
467  OWLCMD_VOID_CTX("edit:move-to-buffer-start", owl_editwin_move_to_top,
468                  OWL_CTX_EDIT,
469                  "moves cursor to the top left (start) of the buffer",
470                  "", ""),
471
472  OWLCMD_VOID_CTX("edit:move-to-buffer-end", owl_editwin_move_to_end, 
473                  OWL_CTX_EDIT,
474                  "moves cursor to the bottom right (end) of the buffer",
475                  "", ""),
476
477  OWLCMD_VOID_CTX("edit:move-to-line-end", owl_editwin_move_to_line_end, 
478                  OWL_CTX_EDIT,
479                  "moves cursor to the end of the line",
480                  "", ""),
481
482  OWLCMD_VOID_CTX("edit:move-to-line-start", owl_editwin_move_to_line_start, 
483                  OWL_CTX_EDIT,
484                  "moves cursor to the beginning of the line",
485                  "", ""),
486
487  OWLCMD_VOID_CTX("edit:move-left", owl_editwin_key_left, 
488                  OWL_CTX_EDIT,
489                  "moves the cursor left by a character",
490                  "", ""),
491
492  OWLCMD_VOID_CTX("edit:move-right", owl_editwin_key_right,
493                  OWL_CTX_EDIT,
494                  "moves the cursor right by a character",
495                  "", ""),
496
497  OWLCMD_VOID_CTX("edit:delete-next-word", owl_editwin_delete_nextword,
498                  OWL_CTX_EDIT,
499                  "deletes the word to the right of the cursor",
500                  "", ""),
501
502  OWLCMD_VOID_CTX("edit:delete-prev-char", owl_editwin_backspace,
503                  OWL_CTX_EDIT,
504                  "deletes the character to the left of the cursor",
505                  "", ""),
506
507  OWLCMD_VOID_CTX("edit:delete-next-char", owl_editwin_delete_char, 
508                  OWL_CTX_EDIT,
509                  "deletes the character to the right of the cursor",
510                  "", ""),
511
512  OWLCMD_VOID_CTX("edit:delete-to-line-end", owl_editwin_delete_to_endofline,
513                  OWL_CTX_EDIT,
514                  "deletes from the cursor to the end of the line",
515                  "", ""),
516
517  OWLCMD_VOID_CTX("edit:delete-all", owl_editwin_clear, 
518                  OWL_CTX_EDIT,
519                  "deletes all of the contents of the buffer",
520                  "", ""),
521
522  OWLCMD_VOID_CTX("edit:fill-paragraph", owl_editwin_fill_paragraph, 
523                  OWL_CTX_EDIT,
524                  "fills the current paragraph to line-wrap well",
525                  "", ""),
526
527  OWLCMD_VOID_CTX("edit:recenter", owl_editwin_recenter, 
528                  OWL_CTX_EDIT,
529                  "recenters the buffer",
530                  "", ""),
531
532  OWLCMD_ARGS_CTX("edit:insert-text", owl_command_edit_insert_text, 
533                  OWL_CTX_EDIT,
534                  "inserts text into the buffer",
535                  "edit:insert-text <text>", ""),
536
537  OWLCMD_VOID_CTX("edit:cancel", owl_command_edit_cancel, 
538                  OWL_CTX_EDIT,
539                  "cancels the current command",
540                  "", ""),
541
542  OWLCMD_VOID_CTX("edit:history-next", owl_command_edit_history_next, 
543                  OWL_CTX_EDITLINE,
544                  "replaces the text with the previous history",
545                  "", ""),
546
547  OWLCMD_VOID_CTX("edit:history-prev", owl_command_edit_history_prev, 
548                  OWL_CTX_EDITLINE,
549                  "replaces the text with the previous history",
550                  "", ""),
551
552  OWLCMD_VOID_CTX("editline:done", owl_command_editline_done, 
553                  OWL_CTX_EDITLINE,
554                  "completes the command (eg, executes command being composed)",
555                  "", ""),
556
557  OWLCMD_VOID_CTX("editmulti:move-up-line", owl_editwin_key_up, 
558                  OWL_CTX_EDITMULTI,
559                  "moves the cursor up one line",
560                  "", ""),
561
562  OWLCMD_VOID_CTX("editmulti:move-down-line", owl_editwin_key_down, 
563                  OWL_CTX_EDITMULTI,
564                  "moves the cursor down one line",
565                  "", ""),
566
567  OWLCMD_VOID_CTX("editmulti:done", owl_command_editmulti_done, 
568                  OWL_CTX_EDITMULTI,
569                  "completes the command (eg, sends message being composed)",
570                  "", ""),
571
572  /****************************************************************/
573  /********************** POPLESS-SPECIFIC ************************/
574  /****************************************************************/
575
576  OWLCMD_VOID_CTX("popless:scroll-down-page", owl_viewwin_pagedown, 
577                  OWL_CTX_POPLESS,
578                  "scrolls down one page",
579                  "", ""),
580
581  OWLCMD_VOID_CTX("popless:scroll-down-line", owl_viewwin_linedown, 
582                  OWL_CTX_POPLESS,
583                  "scrolls down one line",
584                  "", ""),
585
586  OWLCMD_VOID_CTX("popless:scroll-up-page", owl_viewwin_pageup, 
587                  OWL_CTX_POPLESS,
588                  "scrolls up one page",
589                  "", ""),
590
591  OWLCMD_VOID_CTX("popless:scroll-up-line", owl_viewwin_lineup, 
592                  OWL_CTX_POPLESS,
593                  "scrolls up one line",
594                  "", ""),
595
596  OWLCMD_VOID_CTX("popless:scroll-to-top", owl_viewwin_top, 
597                  OWL_CTX_POPLESS,
598                  "scrolls to the top of the buffer",
599                  "", ""),
600
601  OWLCMD_VOID_CTX("popless:scroll-to-bottom", owl_viewwin_bottom, 
602                  OWL_CTX_POPLESS,
603                  "scrolls to the bottom of the buffer",
604                  "", ""),
605
606  OWLCMD_INT_CTX ("popless:scroll-right", owl_viewwin_right, 
607                  OWL_CTX_POPLESS,
608                  "scrolls right in the buffer",
609                  "popless:scroll-right <num-chars>", ""),
610
611  OWLCMD_INT_CTX ("popless:scroll-left", owl_viewwin_left, 
612                  OWL_CTX_POPLESS,
613                  "scrolls left in the buffer",
614                  "popless:scroll-left <num-chars>", ""),
615
616  OWLCMD_VOID_CTX("popless:quit", owl_command_popless_quit, 
617                  OWL_CTX_POPLESS,
618                  "exits the popless window",
619                  "", ""),
620
621  /* This line MUST be last! */
622  { NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
623
624};
625
626void owl_command_info() {
627  owl_function_info();
628}
629
630char *owl_command_help(int argc, char **argv, char *buff) {
631  if (argc!=2) {
632    owl_help();
633    return NULL;
634  }
635 
636  owl_function_help_for_command(argv[1]);
637  return NULL;
638}
639
640void owl_command_about() {
641  owl_function_about();
642}
643
644void owl_command_version() {
645  char buff[1024];
646
647  sprintf(buff, "Owl version %s", OWL_VERSION_STRING);
648  owl_function_makemsg(buff);
649}
650
651void owl_command_next() {
652  owl_function_nextmsg();
653}
654
655void owl_command_prev() {
656  owl_function_prevmsg();
657}
658
659void owl_command_next_notdeleted() {
660  owl_function_nextmsg_notdeleted();
661}
662
663void owl_command_prev_notdeleted() {
664  owl_function_prevmsg_notdeleted();
665}
666
667char *owl_command_smartnarrow(int argc, char **argv, char *buff) {
668  if (argc == 1) {
669    owl_function_smartnarrow(0);
670  } else if (argc == 2 && !strcmp(argv[1], "-i")) {
671    owl_function_smartnarrow(1);
672  } else {
673    owl_function_makemsg("Wrong number of arguments for %s", argv[0]);   
674  }
675  return NULL;
676}
677
678void owl_command_expunge() {
679  owl_function_expunge();
680}
681
682void owl_command_first() {
683  owl_global_set_rightshift(&g, 0);
684  owl_function_firstmsg();
685}
686
687void owl_command_last() {
688  owl_function_lastmsg();
689}
690
691void owl_command_resize() {
692  owl_function_resize();
693}
694
695void owl_command_redisplay() {
696  owl_function_full_redisplay();
697  owl_global_set_needrefresh(&g);
698}
699
700void owl_command_shift_right() {
701  owl_function_shift_right();
702}
703
704void owl_command_shift_left() {
705  owl_function_shift_left();
706}
707
708void owl_command_unsuball() {
709  owl_function_unsuball();
710}
711
712char *owl_command_loadsubs(int argc, char **argv, char *buff) {
713  if (argc == 2) {
714    owl_function_loadsubs(argv[1]);
715  } else if (argc == 1) {
716    owl_function_loadsubs(NULL);
717  } else {
718    owl_function_makemsg("Wrong number of arguments for load-subs.");
719    return NULL;
720  }
721  return NULL;
722}
723
724void owl_command_suspend() {
725  owl_function_suspend();
726}
727
728char *owl_command_start_command(int argc, char **argv, char *buff) {
729  buff = skiptokens(buff, 1);
730  owl_function_start_command(buff);
731  return NULL;
732}
733
734char *owl_command_zaway(int argc, char **argv, char *buff) {
735 
736  if ((argc==1) ||
737      ((argc==2) && !strcmp(argv[1], "on"))) {
738    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
739    owl_function_zaway_on();
740    return NULL;
741  }
742
743  if (argc==2 && !strcmp(argv[1], "off")) {
744    owl_function_zaway_off();
745    return NULL;
746  }
747
748  if (argc==2 && !strcmp(argv[1], "toggle")) {
749    owl_function_zaway_toggle();
750    return NULL;
751  }
752
753  buff = skiptokens(buff, 1);
754  owl_global_set_zaway_msg(&g, buff);
755  owl_function_zaway_on();
756  return NULL;
757}
758
759
760char *owl_command_set(int argc, char **argv, char *buff) {
761  char *var, *val;
762  int  silent=0;
763
764  if (argc == 1) {
765    owl_function_printallvars();
766    return NULL;
767  } else if (argc == 4 && !strcmp("-q",argv[1])) {
768    silent = 1;
769    var=argv[2];
770    val=argv[3];
771  } else if (argc == 3) {
772    var=argv[1];
773    val=argv[2];
774  } else {
775    owl_function_makemsg("Wrong number of arguments for set command");
776    return NULL;
777  }
778
779  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent);
780  return NULL;
781}
782
783char *owl_command_print(int argc, char **argv, char *buff) {
784  char *var;
785  char valbuff[1024];
786
787  if (argc==1) {
788    owl_function_printallvars();
789    return NULL;
790  } else if (argc!=2) {
791    owl_function_makemsg("Wrong number of arguments for print command");
792    return NULL;
793  }
794
795  var=argv[1];
796   
797  if (0 == owl_variable_get_tostring(owl_global_get_vardict(&g), 
798                                     var, valbuff, 1024)) {
799    owl_function_makemsg("%s = '%s'", var, valbuff);
800  } else {
801    owl_function_makemsg("Unknown variable '%s'.", var);
802  }
803  return NULL;
804}
805
806
807char *owl_command_exec(int argc, char **argv, char *buff) {
808  return owl_function_exec(argc, argv, buff, 0);
809}
810
811char *owl_command_pexec(int argc, char **argv, char *buff) {
812  return owl_function_exec(argc, argv, buff, 1);
813}
814
815char *owl_command_aexec(int argc, char **argv, char *buff) {
816  return owl_function_exec(argc, argv, buff, 2);
817}
818
819char *owl_command_perl(int argc, char **argv, char *buff) {
820  return owl_function_perl(argc, argv, buff, 0);
821}
822
823char *owl_command_pperl(int argc, char **argv, char *buff) {
824  return owl_function_perl(argc, argv, buff, 1);
825}
826
827char *owl_command_aperl(int argc, char **argv, char *buff) {
828  return owl_function_perl(argc, argv, buff, 2);
829}
830
831char *owl_command_multi(int argc, char **argv, char *buff) {
832  char *lastrv = NULL, *newbuff;
833  char **commands;
834  int  ncommands, i;
835  if (argc < 2) {
836    owl_function_makemsg("Invalid arguments to 'multi' command.");   
837    return NULL;
838  }
839  newbuff = owl_strdup(buff);
840  newbuff = skiptokens(newbuff, 1);
841  if (!strcmp(argv[0], "(")) {
842    for (i=strlen(newbuff)-1; i>=0; i--) {
843      if (newbuff[i] == ')') {
844        newbuff[i] = '\0';
845        break;
846      } else if (newbuff[i] != ' ') {
847        owl_function_makemsg("Invalid arguments to 'multi' command.");   
848        owl_free(newbuff);
849        return NULL;
850      }
851    }
852  }
853  commands = atokenize(newbuff, ";", &ncommands);
854  for (i=0; i<ncommands; i++) {
855    if (lastrv) {
856      owl_free(lastrv);
857    }
858    lastrv = owl_function_command(commands[i]);
859  }
860  atokenize_free(commands, ncommands);
861  return lastrv;
862}
863
864
865char *owl_command_alias(int argc, char **argv, char *buff) {
866  if (argc < 3) {
867    owl_function_makemsg("Invalid arguments to 'alias' command.");
868    return NULL;
869  }
870  buff = skiptokens(buff, 2);
871  owl_function_command_alias(argv[1], buff);
872  return (NULL);
873}
874
875
876char *owl_command_bindkey(int argc, char **argv, char *buff) {
877  owl_keymap *km;
878  int ret;
879
880  if (argc < 5 || strcmp(argv[3], "command")) {
881    owl_function_makemsg("Usage: bindkey <keymap> <binding> command <cmd>", argv[3], argc);
882    return NULL;
883  }
884  km = owl_keyhandler_get_keymap(owl_global_get_keyhandler(&g), argv[1]);
885  if (!km) {
886    owl_function_makemsg("No such keymap '%s'", argv[1]);
887    return NULL;
888  }
889  buff = skiptokens(buff, 4);
890  ret = owl_keymap_create_binding(km, argv[2], buff, NULL, "*user*");
891  if (ret!=0) {
892    owl_function_makemsg("Unable to bind '%s' in keymap '%s' to '%s'.",
893                         argv[2], argv[1], buff);
894    return NULL;
895  }
896  return NULL;
897}
898
899void owl_command_quit() {
900  owl_function_quit();
901}
902
903char *owl_command_debug(int argc, char **argv, char *buff) {
904  if (argc<2) {
905    owl_function_makemsg("Need at least one argument to debug command");
906    return NULL;
907  }
908
909  if (!owl_global_is_debug_fast(&g)) {
910    owl_function_makemsg("Debugging is not turned on");
911    return NULL;
912  }
913
914  owl_function_debugmsg(argv[1]);
915  return NULL;
916}
917
918char *owl_command_ktest(int argc, char **argv, char *buff) {
919  owl_function_popless_text("foobar");
920  return NULL;
921}
922
923char *owl_command_zlog(int argc, char **argv, char *buff) {
924  if (argc != 2) {
925    owl_function_makemsg("Wrong number of arguments for zlog command");
926    return NULL;
927  }
928
929  if (!strcmp(argv[1], "in")) {
930    owl_function_zlog_in();
931  } else if (!strcmp(argv[1], "out")) {
932    owl_function_zlog_out();
933  } else {
934    owl_function_makemsg("Invalid subcommand for zlog");
935  }
936  return NULL;
937}
938
939
940void owl_command_zlog_out() {
941  owl_function_zlog_out();
942}
943
944
945char *owl_command_subscribe(int argc, char **argv, char *buff) {
946  char *recip="";
947
948  if (argc<3) {
949    owl_function_makemsg("Not enough arguments to the subscribe command");
950    return NULL;
951  } else if (argc>4) {
952    owl_function_makemsg("Too many arguments to the subscribe command");
953    return NULL;
954  }
955
956  if (argc==3) {
957    recip="";
958  } else if (argc==4) {
959    recip=argv[3];
960  }
961
962  owl_function_subscribe(argv[1], argv[2], recip);
963  return NULL;
964}
965
966
967char *owl_command_unsubscribe(int argc, char **argv, char *buff) {
968  char *recip="";
969
970  if (argc<3) {
971    owl_function_makemsg("Not enough arguments to the unsubscribe command");
972    return NULL;
973  } else if (argc>4) {
974    owl_function_makemsg("Too many arguments to the unsubscribe command");
975    return NULL;
976  }
977
978  if (argc==3) {
979    recip="";
980  } else if (argc==4) {
981    recip=argv[3];
982  }
983
984  owl_function_unsubscribe(argv[1], argv[2], recip);
985  return NULL;
986}
987
988char *owl_command_echo(int argc, char **argv, char *buff) {
989  buff = skiptokens(buff, 1);
990  owl_function_popless_text(buff);
991  return NULL;
992}
993
994void owl_command_getsubs() {
995  owl_function_getsubs();
996}
997
998void owl_command_status() {
999  owl_function_status();
1000}
1001
1002char *owl_command_zwrite(int argc, char **argv, char *buff) {
1003  char *tmpbuff;
1004  if (argc < 2) {
1005    owl_function_makemsg("Not enough arguments to the zwrite command.");
1006  } else {
1007    tmpbuff = owl_strdup(buff);
1008    owl_function_zwrite_setup(tmpbuff);
1009    owl_global_set_buffercommand(&g, tmpbuff);
1010    owl_free(tmpbuff);
1011  }
1012  return NULL;
1013}
1014
1015char *owl_command_reply(int argc, char **argv, char *buff) {
1016  int edit=0;
1017 
1018  if (argc==2 && !strcmp("-e", argv[1])) {
1019    edit=1;
1020    argv++;
1021  }
1022
1023  if ((argc==1) || (argc==2 && !strcmp(argv[1], "all"))) {   
1024    owl_function_reply(0, !edit);
1025  } else if ((argc==1) || (argc==2 && !strcmp(argv[1], "sender"))) {
1026    owl_function_reply(1, !edit);
1027  } else {
1028    owl_function_makemsg("Invalid arguments to the reply command.");
1029  }
1030  return NULL;
1031}
1032
1033char *owl_command_filter(int argc, char **argv, char *buff) {
1034  owl_function_create_filter(argc, argv);
1035  return NULL;
1036}
1037
1038char *owl_command_zlocate(int argc, char **argv, char *buff) {
1039  if (argc==2) {
1040    owl_function_zlocate(argv[1], 1);
1041  } else if (argc==3) {
1042    if (!strcmp(argv[1], "-d")) {
1043      owl_function_zlocate(argv[2], 0);
1044    } else {
1045      owl_function_makemsg("Invalid option to the zlocate command");
1046      return NULL;
1047    }
1048  } else {
1049    owl_function_makemsg("Wrong number of arguments for zlocate command");
1050    return NULL;
1051  }
1052  return NULL;
1053}
1054
1055char *owl_command_view(int argc, char **argv, char *buff) {
1056  if (argc<2) {
1057    owl_function_makemsg("Wrong number of arguments to view command");
1058    return NULL;
1059  }
1060
1061  if (argc == 2 && !strcmp(argv[1], "--home")) {
1062    owl_function_change_view(owl_global_get_view_home(&g));
1063    return NULL;
1064  }
1065
1066  /* is it a dynamic filter? */
1067  if (!strcmp(argv[1], "-d")) {
1068    char **myargv;
1069    int i;
1070
1071    myargv=owl_malloc((argc*sizeof(char *))+50);
1072    myargv[0]="";
1073    myargv[1]="owl-dynamic";
1074    for (i=2; i<argc; i++) {
1075      myargv[i]=argv[i];
1076    }
1077    owl_function_create_filter(argc, myargv);
1078    owl_function_change_view("owl-dynamic");
1079    owl_free(myargv);
1080    return NULL;
1081  }
1082
1083  /* otherwise it's a normal view command */
1084  if (argc>2) {
1085    owl_function_makemsg("Wrong number of arguments to view command");
1086    return NULL;
1087  }
1088  owl_function_change_view(argv[1]);
1089  return NULL;
1090}
1091
1092
1093char *owl_command_show(int argc, char **argv, char *buff) {
1094
1095  if (argc<2) {
1096    owl_function_help_for_command("show");
1097    return NULL;
1098  }
1099
1100  if (!strcmp(argv[1], "filter") || !strcmp(argv[1], "filters")) {
1101    if (argc==2) {
1102      owl_function_show_filters();
1103    } else {
1104      owl_function_show_filter(argv[2]);
1105    }
1106  } else if (argc==2 
1107             && (!strcmp(argv[1], "zpunts") || !strcmp(argv[1], "zpunted"))) {
1108    owl_function_show_zpunts();
1109  } else if (!strcmp(argv[1], "command") || !strcmp(argv[1], "commands")) {
1110    if (argc==2) {
1111      owl_function_show_commands();
1112    } else {
1113      owl_function_show_command(argv[2]);
1114    }
1115  } else if (!strcmp(argv[1], "variable") || !strcmp(argv[1], "variables")) {
1116    if (argc==2) {
1117      owl_function_show_variables();
1118    } else {
1119      owl_function_show_variable(argv[2]);
1120    }
1121  } else if (!strcmp(argv[1], "keymap") || !strcmp(argv[1], "keymaps")) {
1122    if (argc==2) {
1123      owl_function_show_keymaps();
1124    } else {
1125      owl_function_show_keymap(argv[2]);
1126    }
1127  } else if (!strcmp(argv[1], "colors")) {
1128    owl_function_show_colors();
1129  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
1130    owl_function_getsubs();
1131  } else if (!strcmp(argv[1], "terminal") || !strcmp(argv[1], "term")) {
1132    owl_function_show_term();
1133  } else if (!strcmp(argv[1], "version")) {
1134    owl_function_about();
1135  } else if (!strcmp(argv[1], "status")) {
1136    owl_function_status();
1137  } else {
1138    owl_function_makemsg("Unknown subcommand for 'show' command (see 'help show' for allowed args)");
1139    return NULL;
1140  }
1141  return NULL;
1142}
1143
1144char *owl_command_viewclass(int argc, char **argv, char *buff) {
1145  if (argc!=2) {
1146    owl_function_makemsg("Wrong number of arguments to viewclass command");
1147    return NULL;
1148  }
1149  owl_function_fastclassinstfilt(argv[1], NULL);
1150  return NULL;
1151}
1152
1153char *owl_command_viewuser(int argc, char **argv, char *buff) {
1154  if (argc!=2) {
1155    owl_function_makemsg("Wrong number of arguments to viewuser command");
1156    return NULL;
1157  }
1158  owl_function_fastuserfilt(argv[1]);
1159  return NULL;
1160}
1161
1162
1163void owl_command_pop_message(void) {
1164  owl_function_curmsg_to_popwin();
1165}
1166
1167void owl_command_openurl(void) {
1168  owl_function_openurl();
1169}
1170
1171char *owl_command_delete(int argc, char **argv, char *buff) {
1172  if (argc==1) {
1173    owl_function_deletecur();
1174    return NULL;
1175  }
1176
1177  if (argc==2 && !strcmp(argv[1], "view")) {
1178    owl_function_delete_curview_msgs(1);
1179    return NULL;
1180  }
1181
1182  if (argc==2 && !strcmp(argv[1], "trash")) {
1183    owl_function_delete_automsgs();
1184    return NULL;
1185  }
1186
1187  if (argc==3 && !strcmp(argv[1], "-id")) {
1188    owl_function_delete_by_id(atoi(argv[2]), 1);
1189    return NULL;
1190  }
1191
1192  owl_function_makemsg("Unknown arguments to delete command");
1193  return NULL;
1194}
1195
1196char *owl_command_undelete(int argc, char **argv, char *buff) {
1197  if (argc==1) {
1198    owl_function_undeletecur();
1199    return NULL;
1200  }
1201
1202  if (argc==2 && !strcmp(argv[1], "view")) {
1203    owl_function_delete_curview_msgs(0);
1204    return NULL;
1205  }
1206
1207  if (argc==3 && !strcmp(argv[1], "-id")) {
1208    owl_function_delete_by_id(atoi(argv[2]), 0);
1209    return NULL;
1210  }
1211
1212  owl_function_makemsg("Unknown arguments to delete command");
1213  return NULL;
1214}
1215
1216void owl_command_beep() {
1217  owl_function_beep();
1218}
1219
1220char *owl_command_colorview(int argc, char **argv, char *buff) {
1221  if (argc!=2) {
1222    owl_function_makemsg("Wrong number of arguments to colorview command");
1223    return NULL;
1224  }
1225  owl_function_color_current_filter(argv[1]);
1226  return NULL;
1227}
1228
1229char *owl_command_zpunt(int argc, char **argv, char *buff) {
1230  owl_command_zpunt_and_zunpunt(argc, argv, 0);
1231  return NULL;
1232}
1233
1234char *owl_command_zunpunt(int argc, char **argv, char *buff) {
1235  owl_command_zpunt_and_zunpunt(argc, argv, 1);
1236  return NULL;
1237}
1238
1239
1240void owl_command_zpunt_and_zunpunt(int argc, char **argv, int type) {
1241  /* if type==0 then zpunt
1242   * if type==1 then zunpunt
1243   */
1244  char *class, *inst, *recip;
1245
1246  class="message";
1247  inst="";
1248  recip="*";
1249
1250  if (argc==1) {
1251    /* show current punt filters */
1252    owl_function_show_zpunts();
1253    return;
1254  } else if (argc==2) {
1255    inst=argv[1];
1256  } else if (argc==3) {
1257    class=argv[1];
1258    inst=argv[2];
1259  } else if (argc==4) {
1260    class=argv[1];
1261    inst=argv[2];
1262    recip=argv[3];
1263  } else {
1264    owl_function_makemsg("Wrong number of arguments to the zpunt command");
1265    return;
1266  }
1267
1268  owl_function_zpunt(class, inst, recip, type);
1269  if (type==0) {
1270    owl_function_makemsg("<%s, %s, %s> added to punt list.", class, inst, recip);
1271  } else if (type==1) {
1272    owl_function_makemsg("<%s, %s, %s> removed from punt list.", class, inst, recip);
1273  }
1274}
1275
1276
1277/*********************************************************************/
1278/************************** EDIT SPECIFIC ****************************/
1279/*********************************************************************/
1280
1281void owl_command_edit_cancel(owl_editwin *e) {
1282  owl_function_makemsg("Command cancelled.");
1283  owl_editwin_fullclear(e);
1284  owl_global_set_needrefresh(&g);
1285  wnoutrefresh(owl_editwin_get_curswin(e));
1286  owl_global_set_typwin_inactive(&g);
1287  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE);
1288}
1289
1290void owl_command_edit_history_prev(owl_editwin *e) {
1291  owl_history *hist;
1292  char *ptr;
1293
1294  hist=owl_global_get_history(&g);
1295  if (!owl_history_is_touched(hist)) {
1296    owl_history_store(hist, owl_editwin_get_text(e));
1297    owl_history_set_partial(hist);
1298  }
1299  ptr=owl_history_get_prev(hist);
1300  if (ptr) {
1301    owl_editwin_clear(e);
1302    owl_editwin_insert_string(e, ptr);
1303    owl_editwin_redisplay(e, 0);
1304    owl_global_set_needrefresh(&g);
1305  } else {
1306    owl_function_beep();
1307  }
1308}
1309
1310void owl_command_edit_history_next(owl_editwin *e) {
1311  owl_history *hist;
1312  char *ptr;
1313
1314  hist=owl_global_get_history(&g);
1315  ptr=owl_history_get_next(hist);
1316  if (ptr) {
1317    owl_editwin_clear(e);
1318    owl_editwin_insert_string(e, ptr);
1319    owl_editwin_redisplay(e, 0);
1320    owl_global_set_needrefresh(&g);
1321  } else {
1322    owl_function_beep();
1323  }
1324}
1325
1326char *owl_command_edit_insert_text(owl_editwin *e, int argc, char **argv, char *buff) {
1327  buff = skiptokens(buff, 1);
1328  owl_editwin_insert_string(e, buff);
1329  owl_editwin_redisplay(e, 0);
1330  owl_global_set_needrefresh(&g); 
1331  return NULL;
1332}
1333
1334void owl_command_editline_done(owl_editwin *e) {
1335  owl_history *hist=owl_global_get_history(&g);
1336  char *rv;
1337
1338  owl_global_set_typwin_inactive(&g);
1339  owl_history_store(hist, owl_editwin_get_text(e));
1340  owl_history_reset(hist);
1341  rv = owl_function_command(owl_editwin_get_text(e));
1342 
1343  /* if we're still in ONELINE mode we can clear the buffer */
1344  if (owl_editwin_get_style(e)==OWL_EDITWIN_STYLE_ONELINE) {
1345    owl_editwin_fullclear(e);
1346  }
1347 
1348  wnoutrefresh(owl_editwin_get_curswin(e));
1349  owl_global_set_needrefresh(&g);
1350
1351  if (rv) {
1352    owl_function_makemsg("%s", rv);
1353    owl_free(rv);
1354  }
1355}
1356
1357void owl_command_editmulti_done(owl_editwin *e) {
1358  owl_function_run_buffercommand();
1359  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_ONELINE);
1360  owl_editwin_fullclear(e);
1361  owl_global_set_typwin_inactive(&g);
1362  owl_global_set_needrefresh(&g);
1363  wnoutrefresh(owl_editwin_get_curswin(e));
1364}
1365
1366
1367/*********************************************************************/
1368/*********************** POPLESS SPECIFIC ****************************/
1369/*********************************************************************/
1370
1371void owl_command_popless_quit(owl_viewwin *vw) {
1372  owl_popwin_close(owl_global_get_popwin(&g));
1373  owl_viewwin_free(vw);
1374  owl_global_set_needrefresh(&g);
1375}
1376
Note: See TracBrowser for help on using the repository browser.