~ubuntu-branches/ubuntu/intrepid/tk707/intrepid

« back to all changes in this revision

Viewing changes to help.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2004-07-25 23:44:01 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040725234401-cl4g3i2m3jvqdtdl
Tags: 0.7.21-9
* debian/control:
  + Set policy to 3.6.1.1.
  + Use tk8.4-dev instead of tk8.3-dev. Fixes strange disappearing of the
    STOP and START buttons (Closes: #205607).
  + Recommend timidity and make a comment about timidity in the long
    description (Closes: #229689).
* debian/menu:
  + Quoted strings where appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
char tcl_help[] = "\
2
 
# =================================================================\n\
3
 
# The Help Module\n\
4
 
# =================================================================\n\
5
 
\n\
6
 
set HELP(UserGuide) $PKGDATADIR/tk707.help\n\
7
 
\n\
8
 
# ----------------------------------------------------------\n\
9
 
# formatText\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\
19
 
#               u  : underline\n\
20
 
#               i  : italic\n\
21
 
#               c  : command\n\
22
 
#               Cn : Content item, n is a positive integer. \n\
23
 
#               t  : title\n\
24
 
#               h  : highlight\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\
28
 
#          without tagging\n\
29
 
proc formatText { w char {format 1} } {\n\
30
 
   global HELP\n\
31
 
\n\
32
 
   # Format the text.\n\
33
 
   if {$format} {\n\
34
 
        switch $char {\n\
35
 
                u {     $w delete last \"last + 1 chars\"\n\
36
 
                        $w tag add underline \"last\" \"last wordend\"\n\
37
 
                  }\n\
38
 
                @ {     $w insert first @ }\n\
39
 
                c {     $w delete last \"last + 1 chars\"\n\
40
 
                        $w tag add command \"last\" \"last wordend\"\n\
41
 
                  }\n\
42
 
                C {     \n\
43
 
                        set tab \"\"\n\
44
 
                        set tabs [$w get \"last + 1 chars\" \"last + 2 chars\"]\n\
45
 
                        $w delete last \"last + 2 chars\"\n\
46
 
                        while {$tabs} {\n\
47
 
                            set tab \"$tab      \" ;\n\
48
 
                            incr tabs -1\n\
49
 
                        }\n\
50
 
                        lappend HELP(Contents)\\\n\
51
 
                         [list \"$tab[$w get \"first\" \"first lineend\"]\" \\\n\
52
 
                                [$w index first]]\n\
53
 
                  }\n\
54
 
                t {     $w delete last \"last + 1 chars\"\n\
55
 
                        $w tag add title \"last\" \"last lineend\"\n\
56
 
                  }\n\
57
 
                h {     $w delete last \"last + 1 chars\"\n\
58
 
                        $w tag add highlight \"last\" \"last wordend\"\n\
59
 
                  }\n\
60
 
                i {     $w delete last \"last + 1 chars\"\n\
61
 
                        $w tag add italic \"last\" \"last wordend\"\n\
62
 
                  }\n\
63
 
        default { }\n\
64
 
        }\n\
65
 
\n\
66
 
   # Remove all format data without formatting.\n\
67
 
   }  else {\n\
68
 
        set ok 0\n\
69
 
        foreach i {u c C t h i} {\n\
70
 
                if {$i==$char} { \n\
71
 
                        $w delete last \"last + 1 chars\"\n\
72
 
                        set ok 1 \n\
73
 
                }\n\
74
 
        }\n\
75
 
                if {!$ok} { $w insert last @ }\n\
76
 
  }\n\
77
 
}\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\
84
 
set HELP(HIL) red\n\
85
 
set HELP(COM) DarkGreen\n\
86
 
set HELP(Log) \"0\"\n\
87
 
\n\
88
 
# ----------------------------------------------------------\n\
89
 
# about\n\
90
 
# ----------------------------------------------------------\n\
91
 
proc about {} {\n\
92
 
  global VERSION\n\
93
 
  if {[winfo exists .about]} {\n\
94
 
    wm deiconify .about\n\
95
 
  } else {\n\
96
 
    toplevel .about\n\
97
 
    wm title .about \"About tk707...\"\n\
98
 
    label    .about.label -text \"\n\
99
 
TK 707\\n\n\
100
 
version $VERSION\\n\n\
101
 
\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\
105
 
\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\
109
 
\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\
114
 
\n\
115
 
Send comments and requests, bugs, suggestions and mods \n\
116
 
to the both authors.\"\n\
117
 
\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\
123
 
  }\n\
124
 
}\n\
125
 
# ----------------------------------------------------------\n\
126
 
# UserManual\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\
133
 
\n\
134
 
   # Only procede if the help window is non-existant.   \n\
135
 
   if {![winfo exists .help]} {\n\
136
 
        set HELP(Contents) \"\"\n\
137
 
\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\
145
 
\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\
152
 
                        -fg $HELP(FG)\\\n\
153
 
                        -activeforeground $HELP(FG)\\\n\
154
 
                        -activebackground $HELP(AFG)\\\n\
155
 
                        -width 10\\\n\
156
 
                        -command {.help.help.text yview 0}\n\
157
 
        # Create the Back button.\n\
158
 
        button .help.buttons.prev\\\n\
159
 
                        -text Back\\\n\
160
 
                        -bg $HELP(AFG)\\\n\
161
 
                        -fg $HELP(FG)\\\n\
162
 
                        -width 10\\\n\
163
 
                        -activebackground $HELP(AFG)\\\n\
164
 
                        -command {\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\
169
 
                                }\n\
170
 
        # Create the Exit button.\n\
171
 
        button .help.buttons.exit\\\n\
172
 
                        -text Exit\\\n\
173
 
                        -bg $HELP(AFG)\\\n\
174
 
                        -fg $HELP(FG)\\\n\
175
 
                        -activeforeground $HELP(FG)\\\n\
176
 
                        -activebackground $HELP(AFG)\\\n\
177
 
                        -width 10\\\n\
178
 
                        -command {destroy .help}\n\
179
 
\n\
180
 
        # Procedure to call when HELP(Log) is written\n\
181
 
        proc setlog {nm1 nm2 op} {\n\
182
 
          global HELP\n\
183
 
          if {$HELP(Log)==0} {\n\
184
 
            .help.buttons.prev config -state disabled \n\
185
 
          } else {\n\
186
 
            .help.buttons.prev config -state normal\n\
187
 
          }\n\
188
 
        }\n\
189
 
\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\
193
 
\n\
194
 
        # Set the current state of the Back button.\n\
195
 
        set HELP(Log) $HELP(Log)\n\
196
 
\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\
202
 
\n\
203
 
        pack .help.buttons  -anchor w -fill x\n\
204
 
\n\
205
 
        # Create and pack the text widget (with scrollbar)\n\
206
 
        setupText .help.help\n\
207
 
\n\
208
 
        # Load the User's Guide into widget and generate contents list.\n\
209
 
        loadFile .help.help.text $HELP(UserGuide)\n\
210
 
\n\
211
 
        # Insert the contents list.\n\
212
 
        set i 1\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\
216
 
                incr i\n\
217
 
        }\n\
218
 
        incr i 2\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\
225
 
        \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\
235
 
        }\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\
248
 
\n\
249
 
           # Store in the log.\n\
250
 
           lappend HELP(Log) \\$goto\n\
251
 
\n\
252
 
           # Adjust the view to the selected line.\n\
253
 
           %W yview \\$goto\"\n\
254
 
   } else {\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\
259
 
   }\n\
260
 
}\n\
261
 
\n\
262
 
# ----------------------------------------------------------\n\
263
 
# setupText\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\
268
 
   global HELP\n\
269
 
\n\
270
 
   #Create Widgets if the path name is valid.\n\
271
 
   if {![winfo exists $w]} {\n\
272
 
        # Create the general frame.\n\
273
 
        frame $w\n\
274
 
\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\
279
 
                        -setgrid 1 \\\n\
280
 
                        -wrap word\n\
281
 
        # Create the scrollbar.\n\
282
 
        scrollbar $w.scroll -command \"$w.text yview\"\n\
283
 
\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\
288
 
   }\n\
289
 
\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\
295
 
                -cursor {}\\\n\
296
 
                -font -adobe-helvetica-medium-r-normal--12-120-*\\\n\
297
 
                -exportselection 0\n\
298
 
\n\
299
 
   $w.scroll config -background $HELP(BG)\n\
300
 
\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\
305
 
\n\
306
 
   # Set the configuration for text tags.\n\
307
 
   # Underline.\n\
308
 
   $w.text tag configure underline -underline 1\n\
309
 
   # Command\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\
317
 
   # Content\n\
318
 
   $w.text tag configure content \\\n\
319
 
                -foreground DarkGreen \\\n\
320
 
                -font -adobe-helvetica-medium-r-normal--14-140-*\n\
321
 
   # Title.\n\
322
 
   $w.text tag configure title -font -adobe-helvetica-medium-r-normal--24-240-*\n\
323
 
   # Italic\n\
324
 
   $w.text tag configure italic -font -adobe-helvetica-medium-o-normal--12-120-*\n\
325
 
   # Highlight.\n\
326
 
   $w.text tag configure highlight -foreground red\n\
327
 
}\n\
328
 
\n\
329
 
\n\
330
 
# ----------------------------------------------------------\n\
331
 
# loadFile\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\
335
 
# format it.\n\
336
 
proc loadFile {w file} {\n\
337
 
   # Delete all previous text in the text widget.\n\
338
 
   $w delete 1.0 end\n\
339
 
\n\
340
 
   # Open the text file.\n\
341
 
   set f [open $file]\n\
342
 
\n\
343
 
   # Insert the text into the text widget.\n\
344
 
   while {![eof $f]} {\n\
345
 
        $w insert end [read $f 1000]\n\
346
 
   }\n\
347
 
        \n\
348
 
   # Close the text file.\n\
349
 
   close $f\n\
350
 
\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\
358
 
        }\n\
359
 
}\n\
360
 
\n\
361
 
# ----------------------------------------------------------\n\
362
 
# forAllMatches\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\
369
 
# script.\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\
380
 
                uplevel $script\n\
381
 
           }\n\
382
 
        }\n\
383
 
}\n\
384
 
";
 
1
char tcl_help[] = ""
 
2
"# =================================================================\n"
 
3
"# The Help Module\n"
 
4
"# =================================================================\n"
 
5
"\n"
 
6
"set HELP(UserGuide) $PKGDATADIR/tk707.help\n"
 
7
"\n"
 
8
"# ----------------------------------------------------------\n"
 
9
"# formatText\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"
 
19
"#              u  : underline\n"
 
20
"#              i  : italic\n"
 
21
"#              c  : command\n"
 
22
"#              Cn : Content item, n is a positive integer. \n"
 
23
"#              t  : title\n"
 
24
"#              h  : highlight\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"
 
28
"#         without tagging\n"
 
29
"proc formatText { w char {format 1} } {\n"
 
30
"   global HELP\n"
 
31
"\n"
 
32
"   # Format the text.\n"
 
33
"   if {$format} {\n"
 
34
"       switch $char {\n"
 
35
"               u {     $w delete last \"last + 1 chars\"\n"
 
36
"                       $w tag add underline \"last\" \"last wordend\"\n"
 
37
"                 }\n"
 
38
"               @ {     $w insert first @ }\n"
 
39
"               c {     $w delete last \"last + 1 chars\"\n"
 
40
"                       $w tag add command \"last\" \"last wordend\"\n"
 
41
"                 }\n"
 
42
"               C {     \n"
 
43
"                       set tab \"\"\n"
 
44
"                       set tabs [$w get \"last + 1 chars\" \"last + 2 chars\"]\n"
 
45
"                       $w delete last \"last + 2 chars\"\n"
 
46
"                       while {$tabs} {\n"
 
47
"                           set tab \"$tab      \" ;\n"
 
48
"                           incr tabs -1\n"
 
49
"                       }\n"
 
50
"                       lappend HELP(Contents)\\\n"
 
51
"                        [list \"$tab[$w get \"first\" \"first lineend\"]\" \\\n"
 
52
"                               [$w index first]]\n"
 
53
"                 }\n"
 
54
"               t {     $w delete last \"last + 1 chars\"\n"
 
55
"                       $w tag add title \"last\" \"last lineend\"\n"
 
56
"                 }\n"
 
57
"               h {     $w delete last \"last + 1 chars\"\n"
 
58
"                       $w tag add highlight \"last\" \"last wordend\"\n"
 
59
"                 }\n"
 
60
"               i {     $w delete last \"last + 1 chars\"\n"
 
61
"                       $w tag add italic \"last\" \"last wordend\"\n"
 
62
"                 }\n"
 
63
"       default { }\n"
 
64
"       }\n"
 
65
"\n"
 
66
"   # Remove all format data without formatting.\n"
 
67
"   }  else {\n"
 
68
"       set ok 0\n"
 
69
"       foreach i {u c C t h i} {\n"
 
70
"               if {$i==$char} { \n"
 
71
"                       $w delete last \"last + 1 chars\"\n"
 
72
"                       set ok 1 \n"
 
73
"               }\n"
 
74
"       }\n"
 
75
"               if {!$ok} { $w insert last @ }\n"
 
76
"  }\n"
 
77
"}\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"
 
84
"set HELP(HIL) red\n"
 
85
"set HELP(COM) DarkGreen\n"
 
86
"set HELP(Log) \"0\"\n"
 
87
"\n"
 
88
"# ----------------------------------------------------------\n"
 
89
"# about\n"
 
90
"# ----------------------------------------------------------\n"
 
91
"proc about {} {\n"
 
92
"  global VERSION\n"
 
93
"  if {[winfo exists .about]} {\n"
 
94
"    wm deiconify .about\n"
 
95
"  } else {\n"
 
96
"    toplevel .about\n"
 
97
"    wm title .about \"About tk707...\"\n"
 
98
"    label    .about.label -text \"\n"
 
99
"TK 707\\n\n"
 
100
"version $VERSION\\n\n"
 
101
"\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"
 
105
"\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"
 
109
"\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"
 
114
"\n"
 
115
"Send comments and requests, bugs, suggestions and mods \n"
 
116
"to the both authors.\"\n"
 
117
"\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"
 
123
"  }\n"
 
124
"}\n"
 
125
"# ----------------------------------------------------------\n"
 
126
"# UserManual\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"
 
133
"\n"
 
134
"   # Only procede if the help window is non-existant.  \n"
 
135
"   if {![winfo exists .help]} {\n"
 
136
"       set HELP(Contents) \"\"\n"
 
137
"\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"
 
145
"\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"
 
152
"                       -fg $HELP(FG)\\\n"
 
153
"                       -activeforeground $HELP(FG)\\\n"
 
154
"                       -activebackground $HELP(AFG)\\\n"
 
155
"                       -width 10\\\n"
 
156
"                       -command {.help.help.text yview 0}\n"
 
157
"       # Create the Back button.\n"
 
158
"       button .help.buttons.prev\\\n"
 
159
"                       -text Back\\\n"
 
160
"                       -bg $HELP(AFG)\\\n"
 
161
"                       -fg $HELP(FG)\\\n"
 
162
"                       -width 10\\\n"
 
163
"                       -activebackground $HELP(AFG)\\\n"
 
164
"                       -command {\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"
 
169
"                               }\n"
 
170
"       # Create the Exit button.\n"
 
171
"       button .help.buttons.exit\\\n"
 
172
"                       -text Exit\\\n"
 
173
"                       -bg $HELP(AFG)\\\n"
 
174
"                       -fg $HELP(FG)\\\n"
 
175
"                       -activeforeground $HELP(FG)\\\n"
 
176
"                       -activebackground $HELP(AFG)\\\n"
 
177
"                       -width 10\\\n"
 
178
"                       -command {destroy .help}\n"
 
179
"\n"
 
180
"        # Procedure to call when HELP(Log) is written\n"
 
181
"        proc setlog {nm1 nm2 op} {\n"
 
182
"         global HELP\n"
 
183
"         if {$HELP(Log)==0} {\n"
 
184
"           .help.buttons.prev config -state disabled \n"
 
185
"         } else {\n"
 
186
"           .help.buttons.prev config -state normal\n"
 
187
"         }\n"
 
188
"       }\n"
 
189
"\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"
 
193
"\n"
 
194
"       # Set the current state of the Back button.\n"
 
195
"       set HELP(Log) $HELP(Log)\n"
 
196
"\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"
 
202
"\n"
 
203
"       pack .help.buttons  -anchor w -fill x\n"
 
204
"\n"
 
205
"       # Create and pack the text widget (with scrollbar)\n"
 
206
"       setupText .help.help\n"
 
207
"\n"
 
208
"       # Load the User's Guide into widget and generate contents list.\n"
 
209
"       loadFile .help.help.text $HELP(UserGuide)\n"
 
210
"\n"
 
211
"       # Insert the contents list.\n"
 
212
"       set i 1\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"
 
216
"               incr i\n"
 
217
"       }\n"
 
218
"       incr i 2\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"
 
225
"       \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"
 
235
"       }\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"
 
248
"\n"
 
249
"          # Store in the log.\n"
 
250
"          lappend HELP(Log) \\$goto\n"
 
251
"\n"
 
252
"          # Adjust the view to the selected line.\n"
 
253
"          %W yview \\$goto\"\n"
 
254
"   } else {\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"
 
259
"   }\n"
 
260
"}\n"
 
261
"\n"
 
262
"# ----------------------------------------------------------\n"
 
263
"# setupText\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"
 
268
"   global HELP\n"
 
269
"\n"
 
270
"   #Create Widgets if the path name is valid.\n"
 
271
"   if {![winfo exists $w]} {\n"
 
272
"       # Create the general frame.\n"
 
273
"       frame $w\n"
 
274
"\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"
 
279
"                       -setgrid 1 \\\n"
 
280
"                       -wrap word\n"
 
281
"       # Create the scrollbar.\n"
 
282
"       scrollbar $w.scroll -command \"$w.text yview\"\n"
 
283
"\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"
 
288
"   }\n"
 
289
"\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"
 
295
"               -cursor {}\\\n"
 
296
"               -font -adobe-helvetica-medium-r-normal--12-120-*\\\n"
 
297
"               -exportselection 0\n"
 
298
"\n"
 
299
"   $w.scroll config -background $HELP(BG)\n"
 
300
"\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"
 
305
"\n"
 
306
"   # Set the configuration for text tags.\n"
 
307
"   # Underline.\n"
 
308
"   $w.text tag configure underline -underline 1\n"
 
309
"   # Command\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"
 
317
"   # Content\n"
 
318
"   $w.text tag configure content \\\n"
 
319
"               -foreground DarkGreen \\\n"
 
320
"               -font -adobe-helvetica-medium-r-normal--14-140-*\n"
 
321
"   # Title.\n"
 
322
"   $w.text tag configure title -font -adobe-helvetica-medium-r-normal--24-240-*\n"
 
323
"   # Italic\n"
 
324
"   $w.text tag configure italic -font -adobe-helvetica-medium-o-normal--12-120-*\n"
 
325
"   # Highlight.\n"
 
326
"   $w.text tag configure highlight -foreground red\n"
 
327
"}\n"
 
328
"\n"
 
329
"\n"
 
330
"# ----------------------------------------------------------\n"
 
331
"# loadFile\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"
 
335
"# format it.\n"
 
336
"proc loadFile {w file} {\n"
 
337
"   # Delete all previous text in the text widget.\n"
 
338
"   $w delete 1.0 end\n"
 
339
"\n"
 
340
"   # Open the text file.\n"
 
341
"   set f [open $file]\n"
 
342
"\n"
 
343
"   # Insert the text into the text widget.\n"
 
344
"   while {![eof $f]} {\n"
 
345
"       $w insert end [read $f 1000]\n"
 
346
"   }\n"
 
347
"       \n"
 
348
"   # Close the text file.\n"
 
349
"   close $f\n"
 
350
"\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"
 
358
"       }\n"
 
359
"}\n"
 
360
"\n"
 
361
"# ----------------------------------------------------------\n"
 
362
"# forAllMatches\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"
 
369
"# script.\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"
 
380
"               uplevel $script\n"
 
381
"          }\n"
 
382
"       }\n"
 
383
"}\n"
 
384
"";