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