File: cmds.master

package info (click to toggle)
lookup 1.08b-5
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 1,108 kB
  • ctags: 1,305
  • sloc: ansic: 12,634; makefile: 236; perl: 174; sh: 53
file content (447 lines) | stat: -rw-r--r-- 10,541 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
#!/usr/local/bin/perl -w
#
# Jeffrey Friedl            		襸ե꡼ 
# Omron Corporation			ʳ
# Nagaokakyoshi, Japan			617Ĺ
#
# jfriedl@nff.ncl.omron.co.jp
#
# This work is placed under the terms of the GNU General Purpose Licence
# (the "GNU Copyleft").
#

print <<END_OF_TEXT;
/*
 *
 *  This file generated from (and by) the file "$0".
 *
 */

#define S const unsigned char *

END_OF_TEXT

$/ = '';	## set record seperator to be double-newline.
$count = 0;

$linenum = &linenumbr_of_data;
while (<DATA>)
{
	++$count;

	($flag, $help, $usage, $regex, $execution, $empty, $other) =
	        split(/\s*\n\s*/);

        ##
	## We expect exactly $flag .. $execution. We expect $empty to be
	## defined but null. If $empty is undefined or non-null, or
	## or $other is defined, the count out of split was wrong.
	if (!defined($empty) || $empty ne '' || defined($other)) {
	    print qq/\n#error was bad record in "$0" at line $linenum.\n/;
	    die qq/$0:$linenum: bad command record.\n/;
	}

	$help =~ s/["\\]/\\$&/g;
	$help = ($help eq "#") ? "0" : qq/"$help"/;
	$usage =~ s/["\\]/\\$&/g;
	$usage = ($usage eq "#") ? "0" : qq/"$usage"/;

	$regex =~ s/\s+/\\s*/g;		# turn whitespace into a regex
	$regex = '^\\s*'.$regex.'\\s*$' if $regex !~ m/^\^/ && $regex !~ m/\$\$/;
	$regex =~ s/["\\]/\\$&/g;	# protect quotes and backslashes

	if ($execution eq "skip") {
           $fun = "0";
        } elsif ($execution =~ m/^(\w+)\(\);?$/) {
	   $fun = $1;
        } else {
	    $execution =~ s/\\(\d)/cmd_paren[$1-1]/g;
	    $fun = "_func${count}_";
	    print "\n/* generated from \"$0\", record at line $linenum */\n";
	    print "static int $fun(void)\n{\n  return $execution;\n}\n";
	}
	push(@entries, join("\n",
	    
	    qq#\n    /* generated from "$0" record at line $linenum*/#,
	    qq#    {#,
            qq#        $flag,#,
	    qq#        (S)$usage,#,
	    qq#        (S)$help,#,
	    qq#        (S)"$regex",#,
	    qq#         $fun,#,
	    qq#    }#));

	$linenum += tr/\n/\n/;
}
print "\nstatic struct command command[] = {\n", join(",\n",@entries), "};\n";

sub linenumbr_of_data { __LINE__ + 2; } ## make sure I'm just before __END__
__END__
CMD_FILE_ONLY /* comment line */
#
#
^\s*#
skip

CMD_FILE_ONLY /* blank line */
#
#
^\s*$
skip

CMD_FILE_ONLY /* search */
#
#
^\s*([+!=].*)
cmd_do_search(\1)

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
Turns automatic romaji conversion on or off, or reports current status.
[default] autokana [on|1|off|0]
default autokana> (on|1|off|0)?
cmd_set_local_autokana_flag(\1)

CMD_GENERAL
#
#
default autokana> (on|1|off|0)?
cmd_set_default_autokana_flag(\1)

CMD_GENERAL
clear the screen
clear|cls
(clear|cls)
cmd_clear()

CMD_GENERAL
set the this-is-a-command character
cmdchar ['bytechar']
cmd(char)? ('(\a)')?
cmd_cmdchar(\3)

CMD_GENERAL
Turns command debugging on or off, or reports current status.
command debug [on|1|off|0]
c(om(mand)?)?> debug> (on|1|off|0)?
cmd_set_default_cmd_debug_flag(\3)

CMD_GENERAL|CMD_LOAD_RELATED
Combines previously-loaded slots to one new slot.
combine> ["name"] [num =] num [num....]
comb(o|ine) ((["'])(.*)\3 =?)? (\d+ \+?=)? ((#? \d+ ,? )+)
cmd_combine(\4, \5 ? atoi(\5) : -1, \6)

CMD_GENERAL
Turns debugging on or off, or reports current status.
debug [on|1|off|0]
debug> (on|1|off|0)?
cmd_set_default_debug_flag(\1)


CMD_GENERAL
describes the encodings for the character(s) indicated
describe "string"|character|[kuten|euc|jis|sjis|ascii]code
describe> (['"])(.*)\1
cmd_describe_raw(\2);

CMD_GENERAL
#
#
describe> (\A+|[!-~])
cmd_describe_raw(\1);


CMD_GENERAL
#
#
describe> (kuten> )?(\d\d\d\d)
cmd_describe_kuten(\2);

CMD_GENERAL
#
#
describe ascii (\\|0)([0-7]+)
cmd_describe_ascii(8, \2);

CMD_GENERAL
#
#
describe ascii (\d+)
cmd_describe_ascii(10, \1);

CMD_GENERAL
#
#
describe ascii (0[xX])?([0-9a-f][0-9a-f])
cmd_describe_ascii(16, \1);


CMD_GENERAL
#
#
describe> (sjis>|jis>|euc>)? (0[xX])?(<[0-9a-f][0-9a-f][0-9a-f][0-9a-f]>)
cmd_describe_encoding(\1, \3);

CMD_GENERAL
#
#
describe> (\$@|\$B|\$@\$B)?(([!-~][!-~])+)(\(\$@|\$B|\$@\$B|\$\(D|\(J|\(H|\(B|\(I)?
cmd_describe_jis_string(\2)

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
Turns display of matching lines on or off.
[default] display [on|1|off|0]
display> (on|1|off|0)?
cmd_set_local_display_flag(\1)

CMD_GENERAL
#
#
default display> (on|1|off|0)?
cmd_set_default_display_flag(\1)

CMD_GENERAL|CMD_ENCODING_RELATED
set the input/output encoding-method
encoding (euc|jis|sjis)
encod(e|ing)> (euc|jis|sjis)?
cmd_encoding(\2)

CMD_GENERAL
list what files are loaded into what slots.
files|slots [-]
(slot|file)s?> (-|-?(help|long))?
cmd_list_files(\2 ? 1 : 0)

CMD_GENERAL|CMD_LOAD_RELATED
set the filter for the selected file.
filter ["name"] [!] /regex/[i]
filter> ("([^"]*)")? (!?) (\S)(.+)\4(i?)
cmd_filter(\5, \2, \3[0] == '!', \6[0] == 'i')

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
turn the filter (for the selected file) on or off, or report its status
filter [on|1|off|0]
filter> (on|1|off|0)?
cmd_toggle_filter(\1)

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
Turns case folding on or off, or reports current status.
[default] fold [on|1|off|0]
fold> (on|1|off|0)?
cmd_set_local_fold_flag(\1)

CMD_GENERAL
#
#
default fold> (on|1|off|0)?
cmd_set_default_fold_flag(\1)

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
Turns fuzzification on or off, or reports current status.
[default] fuzz [on|1|off|0]
fuzz> (on|1|off|0)?
cmd_set_local_fuzz_flag(\1)

CMD_GENERAL
#
#
default fuzz> (on|1|off|0)?
cmd_set_default_fuzz_flag(\1)

CMD_GENERAL
list help
help [string]
help (.*\S)?
cmd_help(\1)

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
Turns highlighting on or off, or reports current status.
[default] highlight [on|1|off|0]
h(igh)?l(ight)?> (on|1|off|0)?
cmd_set_local_highlight_flag(\3)

CMD_GENERAL
Sets the highlighting style (bold, inverse[standout], or to a given HTML tag)
highlight [bold|inverse|blink|under|<___>|black|red|green|yellow|blue|purple|cyan|white]
h(igh)?l(ight)?> (style)? (red|green|yellow|blue|purple|cyan|white|bold|inverse|standout|blink|under|\<([a-zA-Z]+)\>)?
cmd_set_highlighting_style(\4)

CMD_GENERAL
if {expr} command
Runs command only if EXPR is true.
if {([^}]*)} (.*)
cmd_if(\1,\2)

CMD_GENERAL
#
#
default h(igh)?l(ight)?> (on|1|off|0)?
cmd_set_default_highlight_flag(\3)

CMD_GENERAL|CMD_ENCODING_RELATED
report or set the input encoding-method for 8-bit bytes (JIS always OK)
input encoding [euc|sjis]
input (encoding)?> (euc|sjis)?
cmd_input_encoding(\2)

CMD_GENERAL
set the maximum number of lines to print during any one command.
limit [ <value> ]
limit (=? (\d+))?
cmd_set_limit(\2)

CMD_GENERAL|CMD_LOAD_RELATED
load a file (and read or compute its index as needed)
load "file"
(fast)?load> (-?(now)|-?(w(hen)?n(eeded)?))? (['"]?)(\S+)\7
((\3||\4) ? warn("flags no longer need for 'load' command\n") : 0), cmd_load((const char *)\8);

CMD_GENERAL
log output to a file
log [- | [+]"file"]
log> ((-|<off>)|((<to>)? (\+)? (['"]?)(.+)\6))?
cmd_log(\2 ? 1 : 0, \5 ? 1 : 0, \7)

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
sets the modify regular expression and replacement for the selected file.
modify /regex/replace/[ig]
modify> (\S)(.+)\1(.*)\1([ig]?)
cmd_modify(\2,\3, \4[0] == 'i' || \4[1] == 'i', \4[0] == 'g' || \4[1] == 'g')

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
sets the modify filter on or off (for the indicated file)
modify [on|1|off|0]
modify> (on|1|off|0)?
cmd_toggle_modify(\1)

CMD_GENERAL
prints a message to the screen
msg ....
msg (.*)
cmd_msg(\1)

CMD_GENERAL|CMD_ENCODING_RELATED
report or set the output encoding-method
output encoding [euc|sjis|jis|...]
output> (encoding>)? (euc|sjis|jis-?(78|83|90)?(-(ascii|roman))?)?((<(212|no212|hwk|nohwk|foldhwk|disp|nodisp|code|mark)>|[-,\s]+)*)
cmd_output_encoding(\2, \3, \5, \6)

CMD_GENERAL
configure (width x height) or toggle the output pager
pager [boolean | [W x] H]
pager> ((on|1|off|0)|(([1-9]\d* [,x])? ([1-9]\d*)))?
cmd_pager(\2, \4, \5)

CMD_GENERAL|CMD_NEEDS_SLOT
set the prompt format string
[local] prompt "string"
local prompt> ((['"])(.+)\2)?
cmd_set_prompt(1, \3)

CMD_GENERAL
#
#
prompt> ((['"])(.+)\2)?
cmd_set_prompt(0, \3)

CMD_GENERAL
Turns regex debugging on or off, or reports current status.
regex debug [on|1|off|0]
r(egex)? debug> (on|1|off|0)?
cmd_set_default_regex_debug_flag(\2)

CMD_GENERAL
set the number of elided lines to remember for the "show" command.
saved list size [ <value> ]
saved? (list)? (size|len(gth)?)? (=? (\d+))?
cmd_list_size(\5)

CMD_GENERAL|CMD_LOAD_RELATED
sets the default file
select [ num | name | . ]
select> ((\.)|(#? (\d+))|((["']?)(.+)\6))?
cmd_select(\4, (const char *)\7, \2 ? 1 : 0)

CMD_GENERAL
show the lines filtered by the last search, if any
show
show
cmd_show()

CMD_GENERAL
load commands from a file
source "filename"
source> (['"]?)(.+)\1
cmd_source((const char *)\2)

CMD_GENERAL
sets the spinner to move each <value> lines checked (0 to disable)
spinner [ <value> ]
spinner (=? (\d+))?
cmd_set_spinner(\2)

CMD_GENERAL
reports stats about the last search
stats
stats?
cmd_stats()

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
set, toggle, or report the tag for the slot.
tag [boolean] ["string"]
tag> (on|1|off|0)? ((['"])(.*)\3)?
cmd_tag(\1, \4)

CMD_GENERAL
Turns verbosity on or off, or reports current status.
verbose [on|1|off|0]
verbose> (on|1|off|0)?
set_verbose_flag(\1)

CMD_GENERAL
report the version number
version
version
cmd_version()

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
Turns word-preference mode on or off, or reports current status.
[default] word [on|1|off|0]
word> (on|1|off|0)?
cmd_set_local_word_flag(\1)

CMD_GENERAL
#
#
default word> (on|1|off|0)?
cmd_set_default_word_flag(\1)

CMD_GENERAL|CMD_LOAD_RELATED|CMD_NEEDS_SLOT
Selects wildcard "glob" patterns instead of regular expression patterns.
[default] wildcard [on|1|off|0]
(glob|wild(card)?)> (on|1|off|0)?
cmd_set_local_glob_flag(\3)

CMD_GENERAL
#
#
default (glob|wild(card)?)> (on|1|off|0)?
cmd_set_default_glob_flag(\3)

CMD_GENERAL
Exits the program
exit|quit|bye|leave|done
(exit|quit|bye|leave|done)
cmd_exit()

CMD_GENERAL
#
#
(load|describe|source)
cmd_error("expecting argument", \1)

CMD_GENERAL
#
#
(default|local)? (autokana|cmdchar|debug|describe|encoding|files?|filter|fold|fuzz|help|highlight (style)?|input (encoding)?|limit|load|modify|output (encoding)?|pager|prompt|r(egex)? debug|saved? (list)? (size|len(gth)?)?|select|show|source|spinner|stats?|verbose|version|word|exit|quit|bye|leave|done|combine|combo|tag).*
cmd_error("argument error", \2)