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