File: gen.hh

package info (click to toggle)
lavaps 1.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 692 kB
  • ctags: 698
  • sloc: ansic: 2,390; cpp: 2,089; sh: 1,993; tcl: 542; makefile: 229; perl: 182
file content (661 lines) | stat: -rw-r--r-- 20,865 bytes parent folder | download
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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
const char lava_code[] = "\n\
\n\
proc init_canvas {} {\n\
global rdb\n\
if {[info exists rdb(geometry)]} {\n\
wm geometry . $rdb(geometry)\n\
}\n\
\n\
canvas .c -width 100 -height 200 -bg black\n\
pack append . .c expand\n\
\n\
bind . <Configure> \"canvas_configure %W %w %h %B\"\n\
.c bind p <Any-ButtonPress-1> \"info_click_down %W %x %y %X %Y\"\n\
bind .c <Any-ButtonRelease-1> \"info_click_up\"\n\
bind .c <Any-B1-Motion> \"info_click_down %W %x %y %X %Y\"\n\
bind .c <Any-ButtonPress-3> \"tk_popup .menu %X %Y 0\"\n\
bind .c <Any-ButtonPress-2> \"tk_popup .menu %X %Y 0\"\n\
\n\
set_rdb_default_boolean clicklessinfo 0\n\
if {$rdb(clicklessinfo)} {\n\
bind .c <Any-Motion> \"info_click_down %W %x %y %X %Y\"\n\
}\n\
}\n\
\n\
proc canvas_configure {W w h B} {\n\
if {\"$W\" != \".\"} {\n\
return\n\
}\n\
\n\
incr w [expr -2]\n\
incr h [expr -2]\n\
global old_canvas_w old_canvas_h\n\
if {[info exists old_canvas_w]} {\n\
if {$old_canvas_w == $w && $old_canvas_h == $h} {\n\
return\n\
}\n\
}\n\
lava_resize $w $h\n\
.c configure -height $h -width $w\n\
set old_canvas_w $w\n\
set old_canvas_h $h\n\
}\n\
\n\
proc init_menu {} {\n\
global menu rdb\n\
set m [menu .menu -tearoff 0]\n\
\n\
set mw .menu.who\n\
menu $mw -tearoff 0\n\
$mw add radiobutton -label \"Me\" -variable menu(who) -value me -command \"menu_set who me {my jobs\\n}\"\n\
$mw add radiobutton -label \"Everyone\" -variable menu(who) -value everyone -command \"menu_set who everyone {all jobs\\n}\"\n\
set_rdb_default who me\n\
set menu(who) $rdb(who)\n\
menu_set who $menu(who)\n\
$m add cascade -label \"Who\" -menu $mw\n\
\n\
set mw .menu.what\n\
menu $mw -tearoff 0\n\
$mw add radiobutton -label \"Virtual Memory\" -variable menu(what) -value virtual -command \"menu_set what virtual {virtual mem\\n}\"\n\
$mw add radiobutton -label \"Physical Memory\" -variable menu(what) -value physical -command \"menu_set what physical {physical mem\\n}\"\n\
$mw add radiobutton -label \"Both\" -variable menu(what) -value both -command \"menu_set what both {both mem\\n}\"\n\
set_rdb_default what virtual {virtual physical both}\n\
set menu(what) $rdb(what)\n\
menu_set what $rdb(what)\n\
$m add cascade -label \"What\" -menu $mw\n\
\n\
set mw .menu.how\n\
menu $mw -tearoff 0\n\
$mw add command -label \"Shrink\" -command {menu_set how shrink \"shrink mem\\n\"}\n\
$mw add command -label \"Grow\" -command {menu_set how grow \"grow mem\\n\"}\n\
$mw add checkbutton -label \"Autosizing\" -variable menu(how) -onvalue 1 -offvalue 0 -command {menu_autosize force}\n\
set_rdb_default_boolean autosize 1\n\
set menu(how) $rdb(autosize)\n\
menu_set how $menu(how)\n\
$m add cascade -label \"How\" -menu $mw\n\
\n\
set mw .menu.help\n\
menu $mw -tearoff 0\n\
$mw add command -label \"About...\" -command \"menuHelp about\"\n\
$mw add command -label \"Basics...\" -command \"menuHelp basics\"\n\
$mw add command -label \"Menus...\" -command \"menuHelp menus\"\n\
$mw add command -label \"Resources...\" -command \"menuHelp resources\"\n\
$mw add command -label \"Copyright...\" -command \"menuHelp copyright\"\n\
$m add cascade -label \"Help\" -menu $mw\n\
\n\
$m add separator\n\
$m add command -label \"Quit\" -command \"exit 0\"\n\
}\n\
\n\
proc menu_autosize {status} {\n\
global menu\n\
switch -exact $status {\n\
off {\n\
if {$menu(how) != 0} {\n\
set menu(how) 0\n\
menu_set how 0 \"manual resize\\n\"\n\
}\n\
}\n\
force {\n\
if {$menu(how)} {\n\
menu_set how 1 \"auto-resize\\n\"\n\
} else {\n\
menu_set how 0 \"manual resize\\n\"\n\
}\n\
}\n\
default {\n\
die \"bad menu_autosize argument\"\n\
}\n\
}\n\
}\n\
\n\
proc menu_set {what token {feedback \"\"}} {\n\
global menu\n\
lava_menu $what $token\n\
if {$feedback != \"\"} {\n\
splash_refresh $feedback\n\
}\n\
}\n\
\n\
proc init_debugging {} {\n\
global rdb\n\
set_rdb_default_boolean debug 0\n\
lava_menu debug $rdb(debug)\n\
}\n\
\n\
proc debugging {} {\n\
global rdb\n\
return $rdb(debug)\n\
}\n\
\n\
proc init_info {} {\n\
global rdb\n\
toplevel .info \n\
wm transient .info .\n\
wm group .\n\
wm withdraw .info\n\
wm iconname .info \"\"\n\
global info_default_wh\n\
set info_default_wh {24 6}\n\
if {[debugging]} {\n\
set info_default_wh {30 7}\n\
}\n\
label .info.color -height 1 -width [lindex $info_default_wh 0] -text \" \"\n\
text .info.text -width [lindex $info_default_wh 0] -height [lindex $info_default_wh 1]\n\
pack .info.color\n\
pack .info.text\n\
global info_last_x info_last_y info_last_id\n\
set info_last_x -1\n\
set info_last_y -1\n\
set info_last_id -1\n\
if {$rdb(clicklessinfo)} {\n\
bind .info <Any-Motion> \"info_click_down_in_info %W %x %y %X %Y\"\n\
}\n\
bind .info <Any-ButtonPress-3> \"tk_popup .menu %X %Y 0\"\n\
bind .info <Any-ButtonPress-2> \"tk_popup .menu %X %Y 0\"\n\
}\n\
\n\
proc info_click_down_in_info {w x y rx ry} {\n\
puts \"icdii: $w $x $y $rx $ry\"\n\
info_click_down $w $x $y $rx $ry\n\
}\n\
\n\
proc info_click_down {w x y rx ry} {\n\
global info_last_x info_last_y info_last_id\n\
\n\
if {![winfo exists .info]} {\n\
init_info\n\
}\n\
if {$w != \".c\"} {\n\
wm geometry .info \"+$rx+$ry\"\n\
return\n\
}\n\
set try_again 1\n\
while {$try_again} {\n\
set id [.c find closest $x $y]\n\
\n\
if {$info_last_id == $id && $info_last_x == $x && $info_last_y == $y} {\n\
return\n\
}\n\
if {$info_last_id == $id} {\n\
wm geometry .info \"+$rx+$ry\"\n\
return\n\
}\n\
global splash_id\n\
if {$id == $splash_id} {\n\
splash_destroy\n\
set try_again 1\n\
} else {\n\
set try_again 0\n\
}\n\
}\n\
set info_last_x $x\n\
set info_last_y $y\n\
set info_last_id $id\n\
\n\
.info.color config -background [lindex [.c itemconfigure $id -fill] 4]\n\
\n\
global env\n\
set text [lava_id_to_info $id]\n\
global info_default_wh\n\
.info.text delete 0.0 end\n\
.info.text insert 0.0 $text\n\
.info.text config -width [lindex $info_default_wh 0] -height [lindex $info_default_wh 1]\n\
wm geometry .info \"+$rx+$ry\"\n\
wm deiconify .info\n\
}\n\
proc info_click_up {} {\n\
global info_last_id\n\
if {![winfo exists .info]} {\n\
init_info\n\
}\n\
set info_last_id -1\n\
wm withdraw .info\n\
}\n\
\n\
proc splash_create {text} {\n\
global splash_id splash_gray splash_last\n\
set splash_id [.c create text 50 50 -anchor center -fill white -text $text -font {-family Helvetica -weight bold}]\n\
set splash_gray 255\n\
set splash_last $text\n\
after 4000 splash_fade\n\
}\n\
proc splash_destroy {} {\n\
global splash_id\n\
.c delete $splash_id\n\
set splash_id dead\n\
}\n\
proc splash_refresh {text} {\n\
global splash_id splash_gray splash_last splash_last_count\n\
if {$splash_id == \"dead\"} {\n\
splash_create $text\n\
set splash_last \"\"\n\
set splash_last_count 0\n\
} else {\n\
set splash_gray 255\n\
if {\"$text\" == \"$splash_last\"} {\n\
if {$splash_last_count > 1} {\n\
set len [string length $splash_last_count]\n\
set e [expr [.c index $splash_id end] - 2 - $len]\n\
.c dchars $splash_id $e [expr $e + 1 + $len]\n\
} else {\n\
set e [expr [.c index $splash_id end] - 1]\n\
}\n\
incr splash_last_count\n\
.c insert $splash_id $e \" $splash_last_count\\n\"\n\
} else {\n\
.c insert $splash_id end $text\n\
set splash_last $text\n\
set splash_last_count 1\n\
}\n\
}\n\
}\n\
proc splash_fade {} {\n\
global splash_id splash_gray\n\
incr splash_gray -6\n\
if {$splash_gray <= 0} {\n\
splash_destroy\n\
} else {\n\
set g [format \"%02x\" $splash_gray]\n\
.c itemconf $splash_id -fill \"#$g$g$g\"\n\
.c itemconf raise $splash_id\n\
after 1000 splash_fade\n\
}\n\
}\n\
proc init_splash {} {\n\
global splash_id\n\
set splash_id dead\n\
}\n\
\n\
proc make_scale {tag} {\n\
}\n\
proc make_scales {} {\n\
make_scale mem\n\
}\n\
\n\
if {0} {\n\
fconfigure stdin -blocking false -buffering line\n\
fileevent stdin readable lava_debug_callback\n\
proc lava_debug_callback {} {\n\
gets stdin line\n\
puts \"lava_debug_callback: $line\"\n\
eval $line\n\
}\n\
}\n\
\n\
proc lava_ticker {cookie} {\n\
global lava_tick_cookie\n\
if {$cookie < $lava_tick_cookie} {\n\
return\n\
}\n\
\n\
lava_tick\n\
\n\
global splash_id\n\
if {$splash_id != \"dead\"} {\n\
.c raise $splash_id\n\
}\n\
\n\
global rdb\n\
incr lava_tick_cookie\n\
after $rdb(checkinterval) \"lava_ticker $lava_tick_cookie\"\n\
}\n\
proc lava_ticker_always {} {\n\
global lava_tick_cookie\n\
lava_ticker $lava_tick_cookie\n\
}\n\
proc init_ticker {} {\n\
global lava_tick_cookie rdb\n\
set_rdb_default checkinterval 2000\n\
set lava_tick_cookie 0\n\
after 10 lava_ticker_always\n\
}\n\
\n\
\n\
proc main {} {\n\
wm iconname . \"lavaps\"\n\
wm title . \"lavaps\"\n\
tk appname lavaps\n\
\n\
init_splash\n\
init_resources [lava_default_resources]\n\
init_debugging\n\
init_canvas\n\
init_help\n\
init_menu\n\
init_info\n\
\n\
\n\
init_ticker\n\
}\n\
proc init_help {} { global help\n\
set help(about) {\n\
<big>Lavaps 1.9</big>\n\
Copyright (C) 1999 by John Heidemann. All rights reserved. Comments to <computer>johnh@isi.edu</computer>, latest version at <computer>http://www.isi.edu/~johnh/SOFTWARE/LAVAPS/</computer>.\n\
\n\
\n\
<big>Description</big>\n\
Lavaps is an interactive process-tracking program like ``top'', but with a much different attitude.  Rather than presenting lots of specific info in digital form, it tries to present certain important information in a graphical analog form.  The idea is that you can run it in the background and get a rough idea of what's happening to your system without devoting much concentration to the task.\n\
\n\
Lavaps was inspired by Mark Weiser's idea of calm computing in this paper:\n\
\n\
Z<>  ``The Coming Age of Calm Technology'' by Mark Weiser and John Seely Brown. A revised version of Weiser & Brown. ``Designing Calm Technology'', PowerGrid Journal, v 1.01, <computer>http://powergrid.electriciti.com/1.01</computer> (July 1996). October, 1996.  <computer>http://www.ubiq.com/hypertext/weiser/acmfuture2endnote.htm</computer>.\n\
\n\
(This program dedicated to the memory of M.W.--I hope you would have thought it a good hack.)\n\
\n\
\n\
\n\
}\n\
set help(basics) {\n\
<big>Controlling Lavaps</big>\n\
Basic lavaps is quite simple. Blobs live and grow corresponding to processes in the system (see \"BLOBS\"). Clicking the left mouse button on a blob shows information about that process. Clicking the right mouse button pops up menus that let you control lavaps (see \"MENUS\").\n\
\n\
\n\
<big>Blobs</big>\n\
Lavaps is all about blobs of virtual, non-toxic lava. Blobs in lavaps correspond to processes in the system. When a process is started, a new blob is created. When a process exits, the corresponding blob disappears. Blob size is proportional to the amount of memory the process uses. Blob movement is proportional to the amount of time the process runs (if the process never runs, the blob will never move).\n\
\n\
Blob shows several things. First, the basic color (the hue) corresponds to the name of the program which is running.  Emacs is always one color, Netscape another (on my system, blue and yellow). Second, blobs get darker when the process doesn't run. Over time, the process will become nearly black and only  its border will remain colored. Finally, if both physical and virtual memory are shown, then the part of the process will be a slightly different color showing what percentage of the process is not in physical memory.\n\
\n\
Please don't ask me about the chemical composition of the virtual lava.\n\
\n\
\n\
\n\
}\n\
set help(menus) {\n\
<big>Menus</big>\n\
The right mouse button pops up menus which control lavaps, including:\n\
\n\
<italic>Who</italic>: track processes by <italic>me</italic> or by <italic>everyone</italic> (including root, httpd, etc.).\n\
\n\
<italic>What</italic>: track process physical or virtual memory or both. Most modern operating systems can keep all of a process in RAM (physical memory), or can let pages that aren't currently used float out to disk (virtual memory). Virtual memory is always a superset of physical memory. You can track either one, or both. When tracking both, virtual memory appears as a different colored strip down the middle of the process blob.\n\
\n\
<italic>How</italic>: controls blob sizing. Putting too little or too much lava in your lava lamp would make it boring or overflow. Lavaps therefore usually runs with patent-pending lava <italic>autosizing</italic> where blobs fill about a quarter of the lamp. This feature can be turned off (at your peril) with the How menu. You can also control the desired size of the blobs (when autosizing is enabled) or the absolute size of the blobs (when it's not) with the <italic>Grow</italic> and <italic>Shrink</italic> options.\n\
\n\
<italic>Help</italic>: you'll have to figure this one out on your own.\n\
\n\
<italic>Quit</italic>: this one's even harder than Help.\n\
\n\
\n\
\n\
}\n\
set help(resources) {\n\
<big>Resources</big>\n\
Lavaps can configured from X resources (only if they're loaded with xrdb) or with the file <computer>$HOME/.lavapsrc</computer>. In both cases, the format is like:\n\
\n\
lavaps.autosize: false\n\
\n\
setting whatever resource you want (in this case autosize) to some value (false). In the <computer>.lavapsrc</computer> file, the ``lavaps'' before the period can be omitted.\n\
\n\
The following resources are supported:\n\
\n\
geometry  (default none). Specifies the initial window location and size in X-style (see X(1)).\n\
\n\
who  (default me). Whose processes should we be watching, anyway? My processes (set to ``me'') or everyones (set to... ``everyone''). Can also be the process id of a single process if you're very single-minded.\n\
\n\
what  (default both). What kind of memory should blob size correspond to, either both, physical, or virtual.\n\
\n\
autosize  (default true). Keep the blobs at a reasonable size?\n\
\n\
debug  (default false).  Enable debugging messages.\n\
\n\
checkInterval  (default 2000).  How frequently (in milliseconds) should we check to see who's run?  Defaults to 2 seconds which seems ``reasonable'' on my computer; shorten the interval if you want more frequent updates and have a faster computer (or are more tolerant than I am :-).\n\
\n\
clicklessInfo  (default false). If set, process information pops up without clicking. (Not yet fully working.)\n\
\n\
\n\
\n\
}\n\
set help(copyright) {\n\
<big>Copyright</big>\n\
Lavaps is Copyright (C) 1998-1999 by John Heidemann.\n\
\n\
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation.\n\
\n\
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.\n\
\n\
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.\n\
\n\
\n\
\n\
}\n\
}\n\
\n\
\n\
set rcsid(help.tcl) {$Id: help.tcl,v 1.5 1999/09/10 05:57:13 johnh Exp $}\n\
\n\
proc readRelease {} {\n\
global game\n\
set catchval [catch {\n\
set f [open $game(releasefile) r]\n\
gets $f release\n\
close $f\n\
return $release\n\
} ret]\n\
if { $catchval == 2 } {\n\
return $ret\n\
} else {\n\
return \"unknown-release\"\n\
}\n\
}\n\
\n\
\n\
proc menuHighScores {} {\n\
displayHighScores\n\
}\n\
\n\
proc menuFinishGame {} {\n\
endGame \"quit\"\n\
}\n\
\n\
proc menuQuit {} {\n\
global table\n\
endGame \"quit\"\n\
exit 0\n\
}\n\
\n\
\n\
\n\
\n\
proc wmConfig {w title} {\n\
global stackList\n\
\n\
if { [info exists stackList] == 0 } {\n\
set stackList \".\"\n\
}\n\
set geometry [wm geometry [lindex $stackList [expr [llength $stackList] - 1]]]\n\
set geoElems [split $geometry \"x+\"]\n\
set geoX [lindex $geoElems 2]\n\
set geoY [lindex $geoElems 3]\n\
set neoGeoX [expr $geoX + 50]\n\
set neoGeoY [expr $geoY + 50]\n\
wm geometry $w [format \"+%d+%d\" $neoGeoX $neoGeoY]\n\
lappend stackList $w\n\
wm protocol $w WM_DELETE_WINDOW \"unmenuHelp $w\"\n\
wm group $w .\n\
wm title $w $title\n\
wm iconname $w $title\n\
}\n\
proc unmenuHelp {w} {\n\
global stackList tk_version\n\
if { [set listPos [lsearch -exact $stackList $w]] != -1 } {\n\
set stackList [lreplace $stackList $listPos $listPos]\n\
}\n\
destroy $w\n\
}\n\
\n\
proc setMenuHelpKeyboardBindings {top target} {\n\
global tk_version\n\
if {$tk_version < 4.0} {\n\
bind $top <Any-Enter> \"focus $target\"\n\
} else {\n\
focus $target\n\
$target configure -takefocus 1\n\
}\n\
bind $target <Any-KeyPress-Return> \"unmenuHelp $top\"\n\
bind $target <Any-KeyPress-Escape> \"unmenuHelp $top\"\n\
bind $target <Any-KeyPress-KP_Enter> \"unmenuHelp $top\"\n\
}\n\
\n\
\n\
proc menuHelp {topic {titleWord \"\"}} {\n\
global help helpWindowList \n\
\n\
set w \".${topic}\"\n\
catch {unmenuHelp $w}\n\
set tl [toplevel $w]\n\
if { $titleWord == \"\" } { set titleWord	$topic }\n\
wmConfig $w \"Lava-ps--$titleWord\"\n\
set padValue 8\n\
button $w.ok -text OK -padx [expr 2*$padValue] -command \"unmenuHelp $w\"\n\
text $w.t \\\n\
-relief raised -bd 2 -yscrollcommand \"$w.s set\" \\\n\
-setgrid true -wrap word \\\n\
-width 60 -padx $padValue -pady $padValue \\\n\
-font -*-Times-Medium-R-*-140-*\n\
set defFg [lindex [$w.t configure -foreground] 4]\n\
set defBg [lindex [$w.t configure -background] 4]\n\
$w.t tag configure italic -font -*-Times-Medium-I-Normal-*-140-*\n\
$w.t tag configure computer -font -*-Courier-Medium-R-Normal-*-120-*\n\
$w.t tag configure big -font -*-Times-Bold-R-Normal-*-180-*\n\
$w.t tag configure reverse -foreground $defBg -background $defFg\n\
\n\
scrollbar $w.s -relief flat -command \"$w.t yview\"\n\
pack append $w $w.ok {bottom} $w.s {right filly} $w.t {expand fill}\n\
\n\
$w.t mark set insert 0.0\n\
\n\
setMenuHelpKeyboardBindings $w \"$w.ok\"\n\
\n\
set t $help($topic)\n\
while { [regexp -indices {<([^@>]*)>} $t match inds] == 1 } {\n\
set start [lindex $inds 0]\n\
set end [lindex $inds 1]\n\
\n\
set keyword [string range $t $start $end]\n\
\n\
set oldend [$w.t index end]\n\
$w.t insert end [string range $t 0 [expr $start-2]]\n\
purgeAllTags $w.t $oldend insert\n\
\n\
if { [string range $keyword 0 0] == \"/\" } {\n\
set keyword [string trimleft $keyword \"/\"]\n\
if { [info exists tags($keyword)] == 0 } {\n\
error \"end tag $keyword without beginning\"\n\
}\n\
$w.t tag add $keyword $tags($keyword) insert\n\
unset tags($keyword)\n\
} else {\n\
if { [info exists tags($keyword)] == 1 } {\n\
error \"nesting of begin tag $keyword\"\n\
}\n\
set tags($keyword) [$w.t index insert]\n\
}\n\
\n\
set t [string range $t [expr $end+2] end]\n\
}\n\
set oldend [$w.t index end]\n\
$w.t insert end $t\n\
purgeAllTags $w.t $oldend insert\n\
$w.t configure -state disabled\n\
}\n\
\n\
proc purgeAllTags {w start end} {\n\
foreach tag [$w tag names $start] {\n\
$w tag remove $tag $start $end\n\
}\n\
}\n\
\n\
proc menuHelpScrollToTag {topic tag} {\n\
set w \".${topic}\"\n\
\n\
catch {$w.t yview -pickplace reverse.first}\n\
}\n\
\n\
\n\
proc debugLog {s} {\n\
puts $s\n\
}\n\
proc debugLogPause {s} {\n\
update idletasks\n\
puts $s\n\
puts \"\\[pause\\]\"\n\
gets stdin dummy\n\
}\n\
\n\
proc set_rdb_default {elem default {acceptable \"\"}} {\n\
global rdb\n\
if {![info exists rdb($elem)]} {\n\
set rdb($elem) $default\n\
return 1\n\
} else {\n\
if {$acceptable != \"\"} {\n\
if {[lsearch -exact $acceptable $rdb($elem)] == -1} {\n\
puts stderr \"bad resource value: $elem $rdb($elem)\"\n\
set rdb($elem) $default\n\
return 1\n\
}\n\
}\n\
}\n\
return 0\n\
}\n\
\n\
proc rdb_boolean {v} {\n\
set v [string tolower $v]\n\
set v [string trim $v { 	}]\n\
set v [string trimleft $v { 	}]\n\
switch -regexp $v {\n\
{(false|off|0|no)} { set vv 0 }\n\
default { set vv 1 }\n\
}\n\
}\n\
\n\
proc set_rdb_default_boolean {elem default} {\n\
global rdb\n\
set_rdb_default $elem $default\n\
set rdb($elem) [rdb_boolean $rdb($elem)]\n\
}\n\
\n\
proc rdb_resource_line {ln} {\n\
global rdb\n\
if {[regexp {^[.*]([_A-Za-z0-9.]+):[ 	]+(.*)$} $ln t key value]} {\n\
set key [string tolower $key]\n\
set rdb($key) $value\n\
} elseif {[regexp {^[Ll]ava[Pp][Ss][.*]([_A-Za-z0-9.]+):[ 	]+(.*)$} $ln t key value]} {\n\
set key [string tolower $key]\n\
set rdb($key) $value\n\
}\n\
}\n\
\n\
\n\
proc rdb_resource_file {fn} {\n\
if {[catch {open $fn r} f]} {\n\
return\n\
}\n\
while {[gets $f ln] >= 0} {\n\
rdb_resource_line $ln\n\
}\n\
close $f\n\
}\n\
\n\
proc rdb_resource_string {str} {\n\
foreach ln [split $str \"\\n\"] {\n\
rdb_resource_line $ln\n\
}\n\
}\n\
\n\
proc init_resources {defres} {\n\
global rdb env\n\
\n\
set rdb(moduledir) \"$env(HOME)/.tk/lavaps\"\n\
set rdb(homemoduledir) \"$env(HOME)/.tk/lavaps\"\n\
set rdb(startupfile) \"$rdb(homemoduledir)/startup.tcl\"\n\
\n\
rdb_resource_file \"|xrdb -query\"\n\
rdb_resource_file \"$env(HOME)/.lavapsrc\"\n\
if {[file exists $rdb(startupfile)]} { \n\
}\n\
\n\
rdb_resource_string $defres\n\
}\n\
\n\
";