2
# =================================================================\n\
4
# =================================================================\n\
6
set HELP(UserGuide) $PKGDATADIR/tk707.help\n\
8
# ----------------------------------------------------------\n\
10
# ----------------------------------------------------------\n\
11
# This procedure tags the text in a text widget (if format is true),\n\
12
# based on the character in \"char\". \n\
13
# Text Marks \"first\" and \"last\" need to have been set prior to calling \n\
14
# the procedure. These mark the range of characters to be tagged.\n\
15
# The parameters are as follows:\n\
16
# w : is the path of the text widget.\n\
17
# char : is the character determining which tag is to be set.\n\
18
# The current valid characters are:\n\
22
# Cn : Content item, n is a positive integer. \n\
25
# @ : keep the @ character. \n\
26
# format : is a boolean value, which when true causes the text to be formatted.\n\
27
# when false it removes all format information from the text\n\
29
proc formatText { w char {format 1} } {\n\
35
u { $w delete last \"last + 1 chars\"\n\
36
$w tag add underline \"last\" \"last wordend\"\n\
38
@ { $w insert first @ }\n\
39
c { $w delete last \"last + 1 chars\"\n\
40
$w tag add command \"last\" \"last wordend\"\n\
44
set tabs [$w get \"last + 1 chars\" \"last + 2 chars\"]\n\
45
$w delete last \"last + 2 chars\"\n\
47
set tab \"$tab \" ;\n\
50
lappend HELP(Contents)\\\n\
51
[list \"$tab[$w get \"first\" \"first lineend\"]\" \\\n\
54
t { $w delete last \"last + 1 chars\"\n\
55
$w tag add title \"last\" \"last lineend\"\n\
57
h { $w delete last \"last + 1 chars\"\n\
58
$w tag add highlight \"last\" \"last wordend\"\n\
60
i { $w delete last \"last + 1 chars\"\n\
61
$w tag add italic \"last\" \"last wordend\"\n\
66
# Remove all format data without formatting.\n\
69
foreach i {u c C t h i} {\n\
71
$w delete last \"last + 1 chars\"\n\
75
if {!$ok} { $w insert last @ }\n\
78
# ----------------------------------------------------------\n\
79
# Set Help globals.\n\
80
# ----------------------------------------------------------\n\
85
set HELP(COM) DarkGreen\n\
86
set HELP(Log) \"0\"\n\
88
# ----------------------------------------------------------\n\
90
# ----------------------------------------------------------\n\
93
if {[winfo exists .about]} {\n\
94
wm deiconify .about\n\
97
wm title .about \"About tk707...\"\n\
98
label .about.label -text \"\n\
100
version $VERSION\\n\n\
102
Copyright(C) 2000, 2001\\n\n\
103
Chris Willing <chris@vislab.usyd.edu.au>,\\n\n\
104
Pierre Saramito <pierre.saramito@imag.fr>.\\n\n\
106
Go to the Help menu for the complete documentation.\n\
107
This documentation is available in HTML and INFO formats.\n\
108
Type `man tk707` to access the on-line reference manual.\n\
110
The tk707 documentation is also available in html, pdf, postscript and\n\
111
dvi formats from\\n\n\
112
http://www-lmc.imag.fr/lmc-edp/Pierre.Saramito/tk707\n\
113
http://www.vislab.usyd.edu.au/staff/chris/tk707\n\
115
Send comments and requests, bugs, suggestions and mods \n\
116
to the both authors.\"\n\
118
frame .about.sep -width 100p -height 2p -borderwidth 1p -relief sunken\n\
119
button .about.dismiss -text \"Dissmiss\" -command {wm iconify .about}\n\
121
pack .about.dismiss -side bottom -pady 4p\n\
122
pack .about.sep -side bottom -fill x -pady 4p\n\
125
# ----------------------------------------------------------\n\
127
# ----------------------------------------------------------\n\
128
# This procedure is the callback to to the Help-User's Manual menu item.\n\
129
# It creates a pop-up window containing the user's manual, with a few \n\
130
# basic highlighting and goto features.\n\
131
proc UserManual {} {\n\
134
# Only procede if the help window is non-existant. \n\
135
if {![winfo exists .help]} {\n\
136
set HELP(Contents) \"\"\n\
138
# Create the toplevel window.\n\
139
toplevel .help -bg $HELP(BG)\n\
140
# Set the geometry\n\
141
wm geometry .help 80x25\n\
142
wm title .help \"Tk-707 User's Guide\"\n\
143
# Set the Icon information.\n\
144
wm iconname .help Help\n\
146
# Create the buttons panel (Contents, Back, Exit)\n\
147
frame .help.buttons -bg $HELP(BG) -relief ridge -bd 4\n\
148
# Create the Contents button.\n\
149
button .help.buttons.contents\\\n\
153
-activeforeground $HELP(FG)\\\n\
154
-activebackground $HELP(AFG)\\\n\
156
-command {.help.help.text yview 0}\n\
157
# Create the Back button.\n\
158
button .help.buttons.prev\\\n\
163
-activebackground $HELP(AFG)\\\n\
165
set end [expr [llength $HELP(Log)]-1]\n\
166
set value [lindex $HELP(Log) [expr $end-1]]\n\
167
.help.help.text yview $value\n\
168
set HELP(Log) [lreplace $HELP(Log) $end $end]\n\
170
# Create the Exit button.\n\
171
button .help.buttons.exit\\\n\
175
-activeforeground $HELP(FG)\\\n\
176
-activebackground $HELP(AFG)\\\n\
178
-command {destroy .help}\n\
180
# Procedure to call when HELP(Log) is written\n\
181
proc setlog {nm1 nm2 op} {\n\
183
if {$HELP(Log)==0} {\n\
184
.help.buttons.prev config -state disabled \n\
186
.help.buttons.prev config -state normal\n\
190
# Set a variable trace on the Help(Log) variable to ensure that\n\
191
# the Back button is disabled when the log is empty.\n\
192
trace variable HELP(Log) w setlog\n\
194
# Set the current state of the Back button.\n\
195
set HELP(Log) $HELP(Log)\n\
197
# Pack the buttons.\n\
198
pack .help.buttons.contents \\\n\
199
.help.buttons.prev\\\n\
200
.help.buttons.exit\\\n\
201
-side left -anchor w\n\
203
pack .help.buttons -anchor w -fill x\n\
205
# Create and pack the text widget (with scrollbar)\n\
206
setupText .help.help\n\
208
# Load the User's Guide into widget and generate contents list.\n\
209
loadFile .help.help.text $HELP(UserGuide)\n\
211
# Insert the contents list.\n\
213
foreach item $HELP(Contents) {\n\
214
.help.help.text insert $i.0 [format \"[lindex $item 0]\\n\"]\n\
215
.help.help.text tag add content $i.0 \"$i.0 lineend\"\n\
219
# Insert the \"Contents\" title.\n\
220
.help.help.text insert 1.0 [format \"Contents\\n\\n\"]\n\
221
# Give it the format of a title.\n\
222
.help.help.text tag add title 1.0 \"1.0 lineend\"\n\
223
# Store the number of lines added after Contents line.\n\
224
set xtraLinesBefore 2\n\
226
# Add 3 blank lines after contents.\n\
227
# This has to be stored for later\n\
228
set xtraLinesAfter 3\n\
229
.help.help.text insert $i.0 [format \"\\n\\n\\n\"]\n\
230
# Strip the Format code from the Contents list\n\
231
forAllMatches .help.help.text @ {\n\
232
.help.help.text delete first last\n\
233
set char [.help.help.text get last \"last+ 1 chars\"]\n\
234
formatText .help.help.text $char 0\n\
236
# Configure and Bind content list.\n\
237
# A different cursor when above the item\n\
238
.help.help.text tag bind content <Any-Enter> \\\n\
239
\".help.help.text configure -cursor arrow\"\n\
240
.help.help.text tag bind content <Any-Leave> \\\n\
241
\".help.help.text configure -cursor {}\"\n\
242
# Skip to the relevant line.\n\
243
.help.help.text tag bind content <Button-1>\\\n\
244
\"set index \\[ expr \\[lindex \\[split \\[%W index @%x,%y\\] .\\] 0\\]\\\n\
245
-(1 +$xtraLinesBefore)\\]\n\
246
set goto \\[expr \\[lindex \\[lindex \\$HELP(Contents) \\$index\\] 1\\] +2\\\n\
247
+$xtraLinesAfter +\\[llength \\$HELP(Contents)\\]\\]\n\
249
# Store in the log.\n\
250
lappend HELP(Log) \\$goto\n\
252
# Adjust the view to the selected line.\n\
253
%W yview \\$goto\"\n\
255
# Bring the user manual to the front.\n\
256
# I am not using raise since it doesn't generally work for olwm.\n\
258
wm deiconify .help\n\
262
# ----------------------------------------------------------\n\
264
# ----------------------------------------------------------\n\
265
# This procedure creates a text widget and scroll bar.\n\
266
# The parameter \"w\" is a path for the combined widget.\n\
267
proc setupText {w} {\n\
270
#Create Widgets if the path name is valid.\n\
271
if {![winfo exists $w]} {\n\
272
# Create the general frame.\n\
275
# Create the text widget.\n\
276
# The configuration option \"setgrid\" sets up gridded \n\
277
# window management.\n\
278
text $w.text -yscrollcommand \"$w.scroll set\"\\\n\
281
# Create the scrollbar.\n\
282
scrollbar $w.scroll -command \"$w.text yview\"\n\
284
# Pack the widget.\n\
285
pack $w.text -fill both -expand 1 -side left\n\
286
pack $w.scroll -side left -fill y -expand 1\n\
287
pack $w -fill both -expand 1\n\
290
# Configure the Widgets.\n\
291
$w config -bg $HELP(BG)\n\
293
-background $HELP(BG)\\\n\
294
-foreground $HELP(FG)\\\n\
296
-font -adobe-helvetica-medium-r-normal--12-120-*\\\n\
297
-exportselection 0\n\
299
$w.scroll config -background $HELP(BG)\n\
301
# Remove the default bindings that make the text widget editable.\n\
302
bind $w.text <Any-KeyPress> { }\n\
303
bind $w.text <Any-Button> { }\n\
304
bind $w.text <Any-B1-Motion> { }\n\
306
# Set the configuration for text tags.\n\
308
$w.text tag configure underline -underline 1\n\
310
$w.text tag configure command \\\n\
311
-foreground DarkGreen\\\n\
312
-font -adobe-helvetica-medium-r-normal--14-140-*\n\
313
$w.text tag bind command <Button-1> { \n\
314
puts [%W get \"@%x,%y wordstart\" \"@%x,%y wordend\"] }\n\
315
$w.text tag bind command <Any-Enter> \"$w.text configure -cursor arrow\"\n\
316
$w.text tag bind command <Any-Leave> \"$w.text configure -cursor {}\"\n\
318
$w.text tag configure content \\\n\
319
-foreground DarkGreen \\\n\
320
-font -adobe-helvetica-medium-r-normal--14-140-*\n\
322
$w.text tag configure title -font -adobe-helvetica-medium-r-normal--24-240-*\n\
324
$w.text tag configure italic -font -adobe-helvetica-medium-o-normal--12-120-*\n\
326
$w.text tag configure highlight -foreground red\n\
330
# ----------------------------------------------------------\n\
332
# ----------------------------------------------------------\n\
333
# This procedure load a text file given by \"file\" formatted with a \n\
334
# simple form of hyper-text into the text widget given by \"w\". And\n\
336
proc loadFile {w file} {\n\
337
# Delete all previous text in the text widget.\n\
340
# Open the text file.\n\
341
set f [open $file]\n\
343
# Insert the text into the text widget.\n\
344
while {![eof $f]} {\n\
345
$w insert end [read $f 1000]\n\
348
# Close the text file.\n\
351
# Format the text. This is done by looking for all the \"@\" in the\n\
352
# text widget, deleting it and sending the following character to\n\
353
# the procedure formaText, which tags the text appropriately.\n\
354
forAllMatches $w @ {\n\
355
$w delete first last\n\
356
set char [$w get last \"last+ 1 chars\"]\n\
357
formatText $w $char\n\
361
# ----------------------------------------------------------\n\
363
# ----------------------------------------------------------\n\
364
# This procedure takes three arguments: the name of a text widget, \n\
365
# a regular expression pattern and a script. \n\
366
# It finds all of the ranges of characters that match the pattern. \n\
367
# For each matching range forAllMatches sets the marks first and last \n\
368
# to the beginning and end of the of the range, then it invokes the \n\
370
# This procedure has been taken from John K. Ousterhout's book,\n\
371
# Tcl and the Tk Toolkit (1994) p.219. \n\
372
proc forAllMatches {w pattern script} {\n\
373
scan [$w index end] %d numLines\n\
374
for {set i 1} {$i<=$numLines} {incr i } {\n\
375
$w mark set last $i.0\n\
376
while {[regexp -indices $pattern \\\n\
377
[$w get last \"last lineend\" ] indices ] } {\n\
378
$w mark set first \"last + [lindex $indices 0] chars\"\n\
379
$w mark set last \"last + 1 chars +[lindex $indices 1] chars\"\n\
2
"# =================================================================\n"
4
"# =================================================================\n"
6
"set HELP(UserGuide) $PKGDATADIR/tk707.help\n"
8
"# ----------------------------------------------------------\n"
10
"# ----------------------------------------------------------\n"
11
"# This procedure tags the text in a text widget (if format is true),\n"
12
"# based on the character in \"char\". \n"
13
"# Text Marks \"first\" and \"last\" need to have been set prior to calling \n"
14
"# the procedure. These mark the range of characters to be tagged.\n"
15
"# The parameters are as follows:\n"
16
"# w : is the path of the text widget.\n"
17
"# char : is the character determining which tag is to be set.\n"
18
"# The current valid characters are:\n"
22
"# Cn : Content item, n is a positive integer. \n"
25
"# @ : keep the @ character. \n"
26
"# format : is a boolean value, which when true causes the text to be formatted.\n"
27
"# when false it removes all format information from the text\n"
29
"proc formatText { w char {format 1} } {\n"
32
" # Format the text.\n"
35
" u { $w delete last \"last + 1 chars\"\n"
36
" $w tag add underline \"last\" \"last wordend\"\n"
38
" @ { $w insert first @ }\n"
39
" c { $w delete last \"last + 1 chars\"\n"
40
" $w tag add command \"last\" \"last wordend\"\n"
44
" set tabs [$w get \"last + 1 chars\" \"last + 2 chars\"]\n"
45
" $w delete last \"last + 2 chars\"\n"
47
" set tab \"$tab \" ;\n"
50
" lappend HELP(Contents)\\\n"
51
" [list \"$tab[$w get \"first\" \"first lineend\"]\" \\\n"
52
" [$w index first]]\n"
54
" t { $w delete last \"last + 1 chars\"\n"
55
" $w tag add title \"last\" \"last lineend\"\n"
57
" h { $w delete last \"last + 1 chars\"\n"
58
" $w tag add highlight \"last\" \"last wordend\"\n"
60
" i { $w delete last \"last + 1 chars\"\n"
61
" $w tag add italic \"last\" \"last wordend\"\n"
66
" # Remove all format data without formatting.\n"
69
" foreach i {u c C t h i} {\n"
70
" if {$i==$char} { \n"
71
" $w delete last \"last + 1 chars\"\n"
75
" if {!$ok} { $w insert last @ }\n"
78
"# ----------------------------------------------------------\n"
79
"# Set Help globals.\n"
80
"# ----------------------------------------------------------\n"
81
"set HELP(BG) snow2\n"
82
"set HELP(FG) black\n"
83
"set HELP(AFG) grey\n"
85
"set HELP(COM) DarkGreen\n"
86
"set HELP(Log) \"0\"\n"
88
"# ----------------------------------------------------------\n"
90
"# ----------------------------------------------------------\n"
93
" if {[winfo exists .about]} {\n"
94
" wm deiconify .about\n"
97
" wm title .about \"About tk707...\"\n"
98
" label .about.label -text \"\n"
100
"version $VERSION\\n\n"
102
"Copyright(C) 2000, 2001\\n\n"
103
"Chris Willing <chris@vislab.usyd.edu.au>,\\n\n"
104
"Pierre Saramito <pierre.saramito@imag.fr>.\\n\n"
106
"Go to the Help menu for the complete documentation.\n"
107
"This documentation is available in HTML and INFO formats.\n"
108
"Type `man tk707` to access the on-line reference manual.\n"
110
"The tk707 documentation is also available in html, pdf, postscript and\n"
111
"dvi formats from\\n\n"
112
"http://www-lmc.imag.fr/lmc-edp/Pierre.Saramito/tk707\n"
113
"http://www.vislab.usyd.edu.au/staff/chris/tk707\n"
115
"Send comments and requests, bugs, suggestions and mods \n"
116
"to the both authors.\"\n"
118
" frame .about.sep -width 100p -height 2p -borderwidth 1p -relief sunken\n"
119
" button .about.dismiss -text \"Dissmiss\" -command {wm iconify .about}\n"
120
" pack .about.label\n"
121
" pack .about.dismiss -side bottom -pady 4p\n"
122
" pack .about.sep -side bottom -fill x -pady 4p\n"
125
"# ----------------------------------------------------------\n"
127
"# ----------------------------------------------------------\n"
128
"# This procedure is the callback to to the Help-User's Manual menu item.\n"
129
"# It creates a pop-up window containing the user's manual, with a few \n"
130
"# basic highlighting and goto features.\n"
131
"proc UserManual {} {\n"
132
" global HELP FILE\n"
134
" # Only procede if the help window is non-existant. \n"
135
" if {![winfo exists .help]} {\n"
136
" set HELP(Contents) \"\"\n"
138
" # Create the toplevel window.\n"
139
" toplevel .help -bg $HELP(BG)\n"
140
" # Set the geometry\n"
141
" wm geometry .help 80x25\n"
142
" wm title .help \"Tk-707 User's Guide\"\n"
143
" # Set the Icon information.\n"
144
" wm iconname .help Help\n"
146
" # Create the buttons panel (Contents, Back, Exit)\n"
147
" frame .help.buttons -bg $HELP(BG) -relief ridge -bd 4\n"
148
" # Create the Contents button.\n"
149
" button .help.buttons.contents\\\n"
150
" -text Contents\\\n"
151
" -bg $HELP(AFG)\\\n"
153
" -activeforeground $HELP(FG)\\\n"
154
" -activebackground $HELP(AFG)\\\n"
156
" -command {.help.help.text yview 0}\n"
157
" # Create the Back button.\n"
158
" button .help.buttons.prev\\\n"
160
" -bg $HELP(AFG)\\\n"
163
" -activebackground $HELP(AFG)\\\n"
165
" set end [expr [llength $HELP(Log)]-1]\n"
166
" set value [lindex $HELP(Log) [expr $end-1]]\n"
167
" .help.help.text yview $value\n"
168
" set HELP(Log) [lreplace $HELP(Log) $end $end]\n"
170
" # Create the Exit button.\n"
171
" button .help.buttons.exit\\\n"
173
" -bg $HELP(AFG)\\\n"
175
" -activeforeground $HELP(FG)\\\n"
176
" -activebackground $HELP(AFG)\\\n"
178
" -command {destroy .help}\n"
180
" # Procedure to call when HELP(Log) is written\n"
181
" proc setlog {nm1 nm2 op} {\n"
183
" if {$HELP(Log)==0} {\n"
184
" .help.buttons.prev config -state disabled \n"
186
" .help.buttons.prev config -state normal\n"
190
" # Set a variable trace on the Help(Log) variable to ensure that\n"
191
" # the Back button is disabled when the log is empty.\n"
192
" trace variable HELP(Log) w setlog\n"
194
" # Set the current state of the Back button.\n"
195
" set HELP(Log) $HELP(Log)\n"
197
" # Pack the buttons.\n"
198
" pack .help.buttons.contents \\\n"
199
" .help.buttons.prev\\\n"
200
" .help.buttons.exit\\\n"
201
" -side left -anchor w\n"
203
" pack .help.buttons -anchor w -fill x\n"
205
" # Create and pack the text widget (with scrollbar)\n"
206
" setupText .help.help\n"
208
" # Load the User's Guide into widget and generate contents list.\n"
209
" loadFile .help.help.text $HELP(UserGuide)\n"
211
" # Insert the contents list.\n"
213
" foreach item $HELP(Contents) {\n"
214
" .help.help.text insert $i.0 [format \"[lindex $item 0]\\n\"]\n"
215
" .help.help.text tag add content $i.0 \"$i.0 lineend\"\n"
219
" # Insert the \"Contents\" title.\n"
220
" .help.help.text insert 1.0 [format \"Contents\\n\\n\"]\n"
221
" # Give it the format of a title.\n"
222
" .help.help.text tag add title 1.0 \"1.0 lineend\"\n"
223
" # Store the number of lines added after Contents line.\n"
224
" set xtraLinesBefore 2\n"
226
" # Add 3 blank lines after contents.\n"
227
" # This has to be stored for later\n"
228
" set xtraLinesAfter 3\n"
229
" .help.help.text insert $i.0 [format \"\\n\\n\\n\"]\n"
230
" # Strip the Format code from the Contents list\n"
231
" forAllMatches .help.help.text @ {\n"
232
" .help.help.text delete first last\n"
233
" set char [.help.help.text get last \"last+ 1 chars\"]\n"
234
" formatText .help.help.text $char 0\n"
236
" # Configure and Bind content list.\n"
237
" # A different cursor when above the item\n"
238
" .help.help.text tag bind content <Any-Enter> \\\n"
239
" \".help.help.text configure -cursor arrow\"\n"
240
" .help.help.text tag bind content <Any-Leave> \\\n"
241
" \".help.help.text configure -cursor {}\"\n"
242
" # Skip to the relevant line.\n"
243
" .help.help.text tag bind content <Button-1>\\\n"
244
" \"set index \\[ expr \\[lindex \\[split \\[%W index @%x,%y\\] .\\] 0\\]\\\n"
245
" -(1 +$xtraLinesBefore)\\]\n"
246
" set goto \\[expr \\[lindex \\[lindex \\$HELP(Contents) \\$index\\] 1\\] +2\\\n"
247
" +$xtraLinesAfter +\\[llength \\$HELP(Contents)\\]\\]\n"
249
" # Store in the log.\n"
250
" lappend HELP(Log) \\$goto\n"
252
" # Adjust the view to the selected line.\n"
253
" %W yview \\$goto\"\n"
255
" # Bring the user manual to the front.\n"
256
" # I am not using raise since it doesn't generally work for olwm.\n"
257
" wm withdraw .help\n"
258
" wm deiconify .help\n"
262
"# ----------------------------------------------------------\n"
264
"# ----------------------------------------------------------\n"
265
"# This procedure creates a text widget and scroll bar.\n"
266
"# The parameter \"w\" is a path for the combined widget.\n"
267
"proc setupText {w} {\n"
270
" #Create Widgets if the path name is valid.\n"
271
" if {![winfo exists $w]} {\n"
272
" # Create the general frame.\n"
275
" # Create the text widget.\n"
276
" # The configuration option \"setgrid\" sets up gridded \n"
277
" # window management.\n"
278
" text $w.text -yscrollcommand \"$w.scroll set\"\\\n"
281
" # Create the scrollbar.\n"
282
" scrollbar $w.scroll -command \"$w.text yview\"\n"
284
" # Pack the widget.\n"
285
" pack $w.text -fill both -expand 1 -side left\n"
286
" pack $w.scroll -side left -fill y -expand 1\n"
287
" pack $w -fill both -expand 1\n"
290
" # Configure the Widgets.\n"
291
" $w config -bg $HELP(BG)\n"
292
" $w.text config\\\n"
293
" -background $HELP(BG)\\\n"
294
" -foreground $HELP(FG)\\\n"
296
" -font -adobe-helvetica-medium-r-normal--12-120-*\\\n"
297
" -exportselection 0\n"
299
" $w.scroll config -background $HELP(BG)\n"
301
" # Remove the default bindings that make the text widget editable.\n"
302
" bind $w.text <Any-KeyPress> { }\n"
303
" bind $w.text <Any-Button> { }\n"
304
" bind $w.text <Any-B1-Motion> { }\n"
306
" # Set the configuration for text tags.\n"
308
" $w.text tag configure underline -underline 1\n"
310
" $w.text tag configure command \\\n"
311
" -foreground DarkGreen\\\n"
312
" -font -adobe-helvetica-medium-r-normal--14-140-*\n"
313
" $w.text tag bind command <Button-1> { \n"
314
" puts [%W get \"@%x,%y wordstart\" \"@%x,%y wordend\"] }\n"
315
" $w.text tag bind command <Any-Enter> \"$w.text configure -cursor arrow\"\n"
316
" $w.text tag bind command <Any-Leave> \"$w.text configure -cursor {}\"\n"
318
" $w.text tag configure content \\\n"
319
" -foreground DarkGreen \\\n"
320
" -font -adobe-helvetica-medium-r-normal--14-140-*\n"
322
" $w.text tag configure title -font -adobe-helvetica-medium-r-normal--24-240-*\n"
324
" $w.text tag configure italic -font -adobe-helvetica-medium-o-normal--12-120-*\n"
326
" $w.text tag configure highlight -foreground red\n"
330
"# ----------------------------------------------------------\n"
332
"# ----------------------------------------------------------\n"
333
"# This procedure load a text file given by \"file\" formatted with a \n"
334
"# simple form of hyper-text into the text widget given by \"w\". And\n"
336
"proc loadFile {w file} {\n"
337
" # Delete all previous text in the text widget.\n"
338
" $w delete 1.0 end\n"
340
" # Open the text file.\n"
341
" set f [open $file]\n"
343
" # Insert the text into the text widget.\n"
344
" while {![eof $f]} {\n"
345
" $w insert end [read $f 1000]\n"
348
" # Close the text file.\n"
351
" # Format the text. This is done by looking for all the \"@\" in the\n"
352
" # text widget, deleting it and sending the following character to\n"
353
" # the procedure formaText, which tags the text appropriately.\n"
354
" forAllMatches $w @ {\n"
355
" $w delete first last\n"
356
" set char [$w get last \"last+ 1 chars\"]\n"
357
" formatText $w $char\n"
361
"# ----------------------------------------------------------\n"
363
"# ----------------------------------------------------------\n"
364
"# This procedure takes three arguments: the name of a text widget, \n"
365
"# a regular expression pattern and a script. \n"
366
"# It finds all of the ranges of characters that match the pattern. \n"
367
"# For each matching range forAllMatches sets the marks first and last \n"
368
"# to the beginning and end of the of the range, then it invokes the \n"
370
"# This procedure has been taken from John K. Ousterhout's book,\n"
371
"# Tcl and the Tk Toolkit (1994) p.219. \n"
372
"proc forAllMatches {w pattern script} {\n"
373
" scan [$w index end] %d numLines\n"
374
" for {set i 1} {$i<=$numLines} {incr i } {\n"
375
" $w mark set last $i.0\n"
376
" while {[regexp -indices $pattern \\\n"
377
" [$w get last \"last lineend\" ] indices ] } {\n"
378
" $w mark set first \"last + [lindex $indices 0] chars\"\n"
379
" $w mark set last \"last + 1 chars +[lindex $indices 1] chars\"\n"