source: commands.c @ 7d4fbcd

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