This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstdlib.tf
618 lines (483 loc) · 18.3 KB
/
stdlib.tf
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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; TinyFugue - programmable mud client
;;;; Copyright (C) 1994 Ken Keys
;;;;
;;;; TinyFugue (aka "tf") is protected under the terms of the GNU
;;;; General Public License. See the file "COPYING" for details.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; $Id: stdlib.tf,v 35000.32 1998/04/14 18:40:30 hawkeye Exp $
;;; TF macro library
;;; DO NOT EDIT THIS FILE.
;;;
;;; Personal commands should be performed in %HOME/.tfrc; public commands
;;; for all users should be performed in %TFLIBDIR/local.tf. This file will
;;; be replaced when tf is upgraded; %HOME/.tfrc and %TFLIBDIR/local.tf will
;;; not, so changes you make to them will not be lost.
;;; This library is essential to the correct operation of TF. It is as
;;; much a part of TF as the executable file. It is designed so that
;;; it can be used by one or many users.
;;; Many "hidden" macros here are named starting with "~" to minimize
;;; conflicts with the user's namespace; you should not give your own
;;; macros names beginning with "~". Also, you probably don't want to
;;; use the -i flag in defining your personal macros, although you can.
;;; visual status bar
/set status_fields \
@more:8:Br :1 @world :1 \
@read:6 :1 @active:11 :1 @log:5 :1 @mail:6 :1 insert:6 :1 @clock:5
/set status_int_more \
moresize() == 0 ? "" : \
moresize() > 9999 ? "MuchMore" : \
pad("More", 0, moresize(), 4)
/set status_int_world ${world_name}
/set status_int_read nread() ? "(Read)" : ""
/set status_int_active nactive() ? pad("(Active:", 0, nactive(), 2, ")") : ""
/set status_int_log nlog() ? "(Log)" : ""
/set status_int_mail nmail() ? "(Mail)" : ""
/set status_var_insert insert ? "" : "(Over)"
/set status_int_clock ftime("%I:%M", time())
;;; file compression
/if ( systype() =~ "unix" ) \
/def -i COMPRESS_SUFFIX = .Z%;\
/def -i COMPRESS_READ = zcat%;\
/elseif ( systype() =~ "os/2" ) \
/def -i COMPRESS_SUFFIX = .zip%;\
/def -i COMPRESS_READ = unzip -p%;\
/endif
;;; High priority for library hooks/triggers. This is a hack.
/set maxpri=2147483647
;;; Commands
;; Some of these use helper macros starting with ~ to reduce conflicts with
;; the user's namespace.
;;; /echo [-a<attr>] [-p] [-oer] [-w[<world>]] <text>
/def -i echo = \
/if (!getopts("a:poerw:", "")) /return 0%; /endif%; \
/return echo({*}, opt_a, !!opt_p, \
(opt_w !~ "") ? strcat("w",opt_w) : opt_e ? "e" : opt_r ? "r" : "o")
;;; /sys <command>
; Executes an "inline" shell command.
; Only works for commands that do not require input or redraw the screen.
/def -i sys = /quote -S -decho \\!!%{*-:}
;;; /send [-nW] [-T<type>] [-w<world>] text
/def -i send = \
/if (!getopts("nWT:w:", "")) /return 0%; /endif%; \
/let text=%{*}%; \
/if (opt_W) \
/~send $(/listsockets -s)%; \
/elseif (opt_T !~ "") \
/~send $(/listsockets -s -T%{opt_T})%; \
/else \
/test send(text, {opt_w}, !opt_n)%; \
/endif
/def -i ~send = \
/while ({#}) \
/@test send(text, {1}, !opt_n)%; \
/shift%; \
/done
;; null commands
/def -i : = /@test 1
/def -i true = /@test 1
/def -i false = /@test 0
;;
/def -i bg = /fg -n
;; /ADDWORLD [-p] [-T<type>] <name> [[<char> <pass>] <host> <port> [<file>]]
;; /ADDWORLD [-T<type>] DEFAULT <char> <pass> [<file>]
/def -i addworld = \
/if (!getopts("pT:", "")) /return 0%; /endif%; \
/if ({1} =/ "default") \
/test addworld({1}, opt_T, "", "", {2}, {3}, {4})%;\
/elseif ({#} <= 4) \
/test addworld({1}, opt_T, {2}, {3}, "", "", {4}, !opt_p)%;\
/else \
/test addworld({1}, opt_T, {4}, {5}, {2}, {3}, {6}, !opt_p)%;\
/endif
;; /world [-nlq] [<name>]
;; /world [-nlq] <host> <port>
/def -i world = \
/let args=%*%; \
/if (args =~ "") \
/let args=$(/nth 1 $(/listworlds -s))%; \
/if (args =/ "default") \
/let args=$(/nth 2 $(/listworlds -s))%; \
/endif%; \
/endif%; \
/if /!@fg -s %args%; \
/then /@connect %args%; \
/endif
;; /purgeworld <name>...
/def -i purgeworld = /unworld $(/listworlds -s %*)
;; for loop.
; syntax: /for <var> <min> <max> <command>
/def -i for = \
/@eval \
/let %1=%2%%; \
/while ( %1 <= %3 ) \
%-3%%; \
/@test ++%1%%; \
/done
;; flag toggler.
/def -i toggle = /@test %1 := !%1
;; result negation.
/def -i not = /@eval %*%; /@test !%?
;; expression evaluator.
/def -i expr = /@test echo((%*))
;; replace text in input buffer.
/def -i grab = /@test kblen() & dokey("dline")%; /test input({*})
;; partial hilites.
/def -i partial = /def -F -p%{hpri-0} -Ph -t"$(/escape " %*)"
;; triggers.
/def -i trig = /trigpc 0 100 %*
/def -i trigc = /trigpc 0 %{1-x} %-1
/def -i trigp = /trigpc %{1-x} 100 %-1
/def -i undeft = /untrig -anGgurfdhbBC0 - %*
/def -i nogag = \
/if ({#}) \
/untrig -ag - %*%;\
/else \
/echo %% Gags disabled.%;\
/set gag=0%;\
/endif
/def -i nohilite = \
/if ({#}) \
/untrig -aurfdhbBC0 - %*%;\
/else \
/echo %% Hilites disabled.%;\
/set hilite=0%;\
/endif
;; macro existance test.
/def -i ismacro = /list -s -i %{*-@} %| /return %?
;; cut-and-paste tool
/def -i paste = \
/echo -ep %% Entering paste mode. Type "@{B}/endpaste@{n}" to end.%; \
/let line=%; \
/while ((tfread(line) >= 0) & (line !/ "/endpaste")) \
/if (line =/ "/quit" | line =/ "/help*") \
/echo -e %% Type "/endpaste" to end /paste.%; \
/endif%; \
/send - %{*-%{paste_prefix-:|}} %{line}%; \
/done
;; other useful stuff.
/def -i first = /result {1}
/def -i rest = /result {-1}
/def -i last = /result {L}
/def -i nth = /shift %1%; /result {1}
/def -i cd = /lcd %{*-%HOME}
/def -i pwd = /last $(/lcd)
/def -i man = /help %*
/def -i signal = /quote -S -decho !kill -%{1-l} $[{1}!~"" ? getpid() : ""]
/def -i split = /@test regmatch("^([^=]*[^ =])? *=? *(.*)", {*})
/def -i ver = \
/@test regmatch('version (.*). % Copyright', $$(/version))%; \
/result {P1}
;;; Extended world definition macros
/def -i addtiny = /addworld -T"tiny" %*
/def -i addlp = /addworld -T"lp" %*
/def -i addlpp = /addworld -T"lpp" %*
/def -i adddiku = /addworld -T"diku" %*
/def -i addtelnet = /addworld -T"telnet" %*
;; Auto-switch connect hook
/def -iFp0 -agG -hCONNECT ~connect_switch_hook = /@fg %1
;; Proxy server connect hook
/eval /def -iFp%{maxpri} -agG -hPROXY proxy_hook = /proxy_command
/def -i proxy_command = \
telnet ${world_host} ${world_port}%; \
/trigger -hCONNECT ${world_name}%; \
/if (login & ${world_character} !~ "" & ${world_login}) \
/trigger -hLOGIN ${world_name}%; \
/endif
;; Heuristics to detect worlds that use prompts, but have not been classified
;; as such by the user's /addworld definition.
/def -iFmregexp -h'PROMPT [Ll]ogin:( *)$' -T'^$' ~detect_worldtype_1 = \
/@test prompt(strcat({*}, {P1}))%;\
/addworld -Ttelnet ${world_name}%;\
/set lp=1%;\
/localecho on%;\
/echo %% This looks like a telnet world, so I'm redefining it as one.%;\
/echo %% You should use /addworld -T to explicitly set it yourself.
/def -iFmregexp -h'PROMPT ^By what name .* be known\\? *$' -T^$ \
~detect_worldtype_2 = \
/@test prompt({P0})%; \
/addworld -Tlp ${world_name}%; \
/set lp=1%; \
/echo %% This looks like an lp-prompt world, so I'm redefining it as one.%;\
/echo %% You should use /addworld -T to explicitly set it yourself.
;; Default worldtype hook: tiny login format (for backward compatibility),
;; but do not change any flags.
/eval \
/def -mglob -T{} -hLOGIN -iFp%{maxpri} ~default_login_hook = \
/~login_hook_tiny
;; Tiny hooks: login format, lp=off.
/eval \
/def -mglob -T{tiny|tiny.*} -hWORLD -iFp%{maxpri} ~world_hook_tiny = \
/set lp=0%; \
/def -mglob -T{tiny|tiny.*} -hLOGIN -iFp%{maxpri} ~login_hook_tiny = \
/let char=$${world_character}%%;\
/if (strchr(char, ' ') >= 0) /let char="%%char"%%; /endif%%; \
/let pass=$${world_password}%%;\
/if (strchr(pass, ' ') >= 0) /let pass="%%pass"%%; /endif%%; \
/send connect %%char %%pass
;; Generic prompt-world hooks: lp=on.
/eval \
/def -mglob -Tprompt -hWORLD -iFp%{maxpri} ~world_hook_prompt = \
/set lp=1
;; LP/Diku/Aber/etc. hooks: login format, lp=on.
/eval \
/def -mglob -T{lp|lp.*|diku|diku.*|aber|aber.*} -hWORLD -iFp%{maxpri} \
~world_hook_lp = \
/set lp=1%; \
/def -mglob -T{lp|lp.*|diku|diku.*|aber|aber.*} -hLOGIN -iFp%{maxpri} \
~login_hook_lp = \
/send -- $${world_character}%%; \
/send -- $${world_password}
;; Hooks for LP-worlds with telnet end-of-prompt markers:
;; login format, lp=off.
/eval \
/def -mglob -T{lpp|lpp.*} -hWORLD -iFp%{maxpri} ~world_hook_lpp = \
/set lp=0%; \
/def -mglob -T{lpp|lpp.*} -hLOGIN -iFp%{maxpri} ~login_hook_lpp = \
/send -- $${world_character}%%; \
/send -- $${world_password}
;; Telnet hooks: login format, lp=on, and localecho=on (except at
;; password prompt).
/eval \
/def -mglob -T{telnet|telnet.*} -hCONNECT -iFp%{maxpri} ~con_hook_telnet = \
/def -w -qhPROMPT -n1 -iFp%{maxpri} = /localecho on%;\
/def -mglob -T{telnet|telnet.*} -hWORLD -iFp%{maxpri} ~world_hook_telnet = \
/set lp=1%; \
/def -mglob -T{telnet|telnet.*} -hLOGIN -iFp%{maxpri} ~login_hook_telnet = \
/send -- $${world_character}%%; \
/send -- $${world_password}%; \
/def -mregexp -T'^telnet(\\\\..*)?$$' -h'PROMPT [Pp]assword:( *)$$' \
-iFp%{maxpri} ~telnet_passwd = \
/@test prompt(strcat({*}, {P1}))%%;\
/def -w -q -hSEND -iFn1p%{maxpri} ~echo_$${world_name} =\
/localecho on%%;\
/localecho off
;; /telnet <host> [<port>]
;; Defines a telnet-world and connects to it.
/def -i telnet = \
/addtelnet %{1},%{2-23} %1 %{2-23}%; \
/connect %{1},%{2-23}
;;; default filenames
; This is ugly, mainly to keep backward compatibility with the lame old
; "~/tiny.*" filenames and *FILE macros. The new style, "~/*.tf", has
; a sensible suffix, and works on 8.3 FAT filesystems. (A subdirectory
; would be nice, but then /save* would fail if the user hasn't created
; the subdirectory).
/if ( TINYPREFIX =~ "" & TINYSUFFIX =~ "" ) \
; New-style names make more sense.
/set TINYPREFIX=~/%; \
/set TINYSUFFIX=.tf%; \
; Old-style names on unix systems, for backward compatibility.
/if ( systype() =~ "unix" ) \
/set TINYPREFIX=~/tiny.%; \
/set TINYSUFFIX=%; \
/endif%; \
/endif
/eval /def -i MACROFILE = %{TINYPREFIX}macros%{TINYSUFFIX}
/eval /def -i HILITEFILE = %{TINYPREFIX}hilite%{TINYSUFFIX}
/eval /def -i GAGFILE = %{TINYPREFIX}gag%{TINYSUFFIX}
/eval /def -i TRIGFILE = %{TINYPREFIX}trig%{TINYSUFFIX}
/eval /def -i BINDFILE = %{TINYPREFIX}bind%{TINYSUFFIX}
/eval /def -i HOOKFILE = %{TINYPREFIX}hook%{TINYSUFFIX}
/eval /def -i WORLDFILE = %{TINYPREFIX}world%{TINYSUFFIX}
/eval /def -i LOGFILE = tiny.log
;;; define load* and save* macros with default filenames.
/def -i ~def_file_command = \
/def -i %1%2 = \
/%1 %%{1-$${%{3}FILE}} %{-3}
/~def_file_command load def MACRO
/~def_file_command load hilite HILITE
/~def_file_command load gag GAG
/~def_file_command load trig TRIG
/~def_file_command load bind BIND
/~def_file_command load hook HOOK
/~def_file_command load world WORLD
/~def_file_command save def MACRO -mglob -h0 -b{} -t{} ?*
/~def_file_command save gag GAG -mglob -h0 -b{} -t -ag
/~def_file_command save trig TRIG -mglob -h0 -b{} -t -an
/~def_file_command save bind BIND -mglob -h0 -b
/~def_file_command save hook HOOK -mglob -h
/def -i savehilite = \
/save %{1-${HILITEFILE}} -mglob -h0 -b{} -t -aurfdhbBC0%;\
/save -a %{1-${HILITEFILE}} -mglob -h0 -b{} -t -P
;;; list macros
/def -i listdef = /list %*
/def -i listfullhilite = /list -mglob -h0 -b{} -t'$(/escape ' %*)' -aurfdhbBC0
/def -i listpartial = /list -mglob -h0 -b{} -t'$(/escape ' %*)' -P
/def -i listhilite = /listfullhilite%; /listpartial
/def -i listgag = /list -mglob -h0 -b{} -t'$(/escape ' %*)' -ag
/def -i listtrig = /list -mglob -h0 -b{} -t'$(/escape ' %*)' -an
/def -i listbind = /list -mglob -h0 -b'$(/escape ' %*)'
/def -i listhook = /list -mglob -h'$(/escape ' %*)'
;;; purge macros
/def -i purgedef = /purge -mglob -h0 -b{} - %{1-?*}
/def -i purgehilite = /purge -mglob -h0 -b{} -t'$(/escape ' %*)' -aurfdhbBC0
/def -i purgegag = /purge -mglob -h0 -b{} -t'$(/escape ' %*)' -ag
/def -i purgetrig = /purge -mglob -h0 -b{} -t'$(/escape ' %*)' -an
/def -i purgedeft = /purge -mglob -h0 -b{} -t'$(/escape ' %*)' ?*
/def -i purgebind = /purge -mglob -h0 -b'$(/escape ' %*)'
/def -i purgehook = /purge -mglob -h'$(/escape ' %*)'
;; library loading
/set _loaded_libs=
/def -i ~loaded = \
/if /@test _loaded_libs !/ "*{%{1}}*"%; /then \
/set _loaded_libs=%{_loaded_libs} %{1}%;\
/elseif (_required) \
/exit%; \
/endif
/def -i require = \
/let _required=1%; \
/load %{-L} %{TFLIBDIR}/%{L}%;\
;; meta-character quoter
;; /escape <metachars> <string>
/def -i escape = \
/let meta=$[strcat({1}, "\\")]%;\
/let dest=%;\
/let tail=%-1%;\
/let i=garbage%;\
/while ((i := strchr(tail, meta)) >= 0) \
/let dest=$[strcat(dest, substr(tail,0,i), "\\", substr(tail,i,1))]%;\
/let tail=$[substr(tail, i+1)]%;\
/done%;\
/result strcat(dest, tail)
;;; /loadhist [-lig] [-w<world>] file
/def -i loadhist = \
/let file=%L%; \
/quote -S /recordline %-L '%%{file-${LOGFILE}}
;;; /keys simulation
;; For backward compatibilty only.
;; Supports '/keys <mnem> = <key>' and '/keys' syntax.
/def -i keys =\
/if ( {*} =/ "" ) \
/list -Ib%;\
/elseif ( {*} =/ "*,*" ) \
/echo -e %% The /keys comma syntax is no longer supported.%;\
/echo -e %% See /help bind, /help dokey.%;\
/elseif ( {*} =/ "{*} = ?*" ) \
/def -ib'%{-2}' = /dokey %1%;\
/elseif ( {*} =/ "*=*" ) \
/echo -e %% '=' must be surrounded by spaces.%;\
/echo -e %% See /help bind, /help dokey.%;\
/else \
/echo -e %% Bad /keys syntax.%;\
/endif
;;; Retry connections
;; /retry <world> [<delay>]
;; Try to connect to <world>. Repeat every <delay> seconds (default 60)
;; until successful.
/def -i retry = \
/def -mglob -p%{maxpri} -F -h'CONFAIL $(/escape ' %1) *' ~retry_fail_%1 =\
/repeat -%{2-60} 1 /connect %1%;\
/def -mglob -1 -p%{maxpri} -F -h'CONNECT $(/escape ' %1)' ~retry_succ_%1=\
/undef ~retry_fail_%1%;\
/connect %1
;; /retry_off [<world>]
;; Cancels "/retry <world>" (default: all worlds)
/def -i retry_off = /purge -mglob {~retry_fail_%{1-*}|~retry_succ_%{1-*}}
;;; Hilites for pages and whispers
;; Simulates "/hilite page" and "/hilite whisper" in old versions.
/def -i hilite_whisper = \
/def -ip2ah -mregexp -t'^[^ ]* whispers,? ".*" (to [^ ]*)?$$' ~hilite_whisper1
/def -i hilite_page = \
/def -ip2ah -mglob -t'{*} pages from *[,:] *' ~hilite_page1%;\
/def -ip2ah -mglob -t'You sense that {*} is looking for you in *' ~hilite_page2%;\
/def -ip2ah -mglob -t'The message was: *' ~hilite_page3%;\
/def -ip2ah -mglob -t'{*} pages[,:] *' ~hilite_page4%;\
/def -ip2ah -mglob -t'In a page-pose*' ~hilite_page5
/def -i nohilite_whisper = /purge -mglob -I ~hilite_whisper[1-9]
/def -i nohilite_page = /purge -mglob -I ~hilite_page[1-9]
;;; backward compatible commands
/def -i cat = \
/echo -e %% Entering cat mode. Type "." to end.%; \
/let line=%; \
/let all=%; \
/while ((tfread(line) >= 0) & (line !~ ".")) \
/if (line =/ "/quit") \
/echo -e %% Type "." to end /cat.%; \
/endif%; \
/@test all := \
strcat(all, (({1} =~ "%%" & all !~ "") ? "%%;" : ""), line)%; \
/done%; \
/recordline -i %all%; \
/@test eval(all)
/def -i time = /@test echo(ftime({*-%%{time_format}}, time())), time()
/def -i rand = \
/if ( {#} == 0 ) /echo $[rand()]%;\
/elseif ( {#} == 1 ) /echo $[rand({1})]%;\
/elseif ( {#} == 2 ) /echo $[rand({1}, {2})]%;\
/else /echo -e %% %0: too many arguments%;\
/endif
; Since the default page key (TAB) is not obvious to a new user, we display
; instructions when he executes "/more on" if he hasn't re-bound the key.
/def -i more = \
/if ( {*} =/ "{on|1}" & ismacro("-ib'^I' = /dokey page") ) \
/echo -e %% "More" paging enabled. Use TAB to scroll.%;\
/endif%; \
/set more %*
/def -i nolog = /log off
/def -i nowrap = /set wrap off
/def -i nologin = /set login off
/def -i noquiet = /set quiet off
/def -i act = /trig %*
/def -i reply = /set borg %*
/def -i background = /set background %*
/def -i bamf = /set bamf %*
/def -i borg = /set borg %*
/def -i clearfull = /set clearfull %*
/def -i cleardone = /set cleardone %*
/def -i insert = /set insert %*
/def -i login = /set login %*
/def -i lp = /set lp %*
/def -i lpquote = /set lpquote %*
/def -i quiet = /set quiet %*
/def -i quitdone = /set quitdone %*
/def -i redef = /set redef %*
/def -i shpause = /set shpause %*
/def -i sockmload = /set sockmload %*
/def -i sub = /set sub %*
/def -i visual = /set visual %*
/def -i gpri = /set gpri %*
/def -i hpri = /set hpri %*
/def -i isize = /set isize %*
/def -i ptime = /set ptime %*
/def -i wrapspace = /set wrapspace %*
/def -i wrap = \
/if ({*} =/ '[0-9]*') \
/set wrapsize=%*%; \
/set wrap=1%; \
/else \
/set wrap %*%;\
/endif
/def -i ~do_prefix = \
/if ( {-1} =/ "{|off|0|on|1}" ) \
/set %{1}echo %{-1}%; \
/elseif ( {-1} =/ "{all|2}" & {1} =~ "m" ) \
/set %{1}echo %{-1}%; \
/else \
/set %{1}prefix=%{-1}%; \
/set %{1}prefix%; \
/set %{1}echo=1%; \
/endif
/def -i kecho = /~do_prefix k %*
/def -i mecho = /~do_prefix m %*
/def -i qecho = /~do_prefix q %*
;;; Other standard libraries
/def -hload -ag ~gagload
/eval /load %TFLIBDIR/kbbind.tf
/eval /if (systype() =~ "os/2") /load %TFLIBDIR/kb-os2.tf%; /endif
/eval /load %TFLIBDIR/color.tf
/eval /load %TFLIBDIR/changes.tf
/undef ~gagload
;;; constants
/set pi=3.141592654
/set e=2.718281828
;;; Help for newbies
/def -i -h'SEND help' -Fq send_help = \
/if (${world_name} =~ "") \
/echo -e %% You are not connected to a world.%; \
/echo -e %% Use "/help" to get help on TinyFugue.%; \
/endif
;;; Load local public config file
/def -hloadfail -ag ~gagloadfail
/eval /load %{TFLIBDIR}/local.tf
/undef ~gagloadfail