~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to tcl/sciGUI/local_extra/HelpSystem-1.5/help.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
################################################################################
 
2
#      
 
3
#  Project       :  Help System
 
4
#
 
5
#  Developed by  :  Andrei A. Gratchev      <grand@deversys.com>
 
6
#
 
7
#  Filename      :  help.tcl
 
8
#  Version       :  1.5
 
9
#  Description   :  Help system based on HTML & HTML viewer
 
10
#
 
11
################################################################################
 
12
                                                                               
 
13
package provide help 1.5
 
14
 
 
15
namespace eval help {
 
16
 variable w
 
17
 variable gw
 
18
 variable abort         0
 
19
 variable showing       0
 
20
 variable stat          ""
 
21
 variable curfilename   ""
 
22
 variable data
 
23
 variable history       ""
 
24
 variable hpos          0
 
25
 variable index         ""
 
26
 variable attr
 
27
 variable perc
 
28
 variable font          "Helvetica"
 
29
 variable fontfixed     "Courier"
 
30
 variable fontsize      10
 
31
 variable backcolor     ""
 
32
 variable forecolor     black
 
33
 variable linkcolor     "#006800"
 
34
 variable alinkcolor    "#c00000"
 
35
 variable lmargin       6
 
36
 variable rmargin       6
 
37
 variable settings
 
38
 variable curtopic      ""
 
39
 variable _count
 
40
 variable _tags
 
41
 variable _images
 
42
 array set _images "broken  [image create photo -data "R0lGODlhIAAgALP/AP///8DAwP8A/7+/v39/f38AfwD//wB/AAAA/wAAfwAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAgACAAAAT/kMhJq50h60yA/2AoAtKmdWMqEgNhBuggz3Rdd60Z35NNx66Th3c4EBJI1u2T4wxnEhLyk/yBmjsZwZgYJZStUC7bOnRTX5lizV7Dntrj54iSQiuKN+B3BiAVUx5pcRN5ZAN9CQoSiWAzHoZwMkiUjHWDNJB6NhVfc5iPAJF7PpYgioWhoy0+np8ECAaoMppACjZ9UosGCKgstUMdtzR9R7sIvYu/opsow5NUx8i+A8B7HQKiM5RJvMjJEtXMQAAC2cPcX9/TyuKr2AIF2o3p1NZh5gXnjW1s4ffY9MUT0OjCv3HBABRYyDCdwYPv4j0M54MWwj39Mj6r6G5Ti4mOGHzcI/SQY8c6KlKOGKWyJYg8GmPK1BggAgA7"]
 
43
                    disc    [image create photo -data "R0lGODlhEAAFAID/AMDAwAAAACH5BAEAAAAALAAAAAAQAAUAAAINhA+hyKff2FvRzYogKwA7"]
 
44
                    circle  [image create photo -data "R0lGODlhEAAHAID/AMDAwAAAACH5BAEAAAAALAAAAAAQAAcAAAIShA+hyBfe0JPRTFivrbvztDAFADs="]
 
45
                    square  [image create photo -data "R0lGODlhEAAFAID/AMDAwAAAACH5BAEAAAAALAAAAAAQAAUAAAINhB+Zx6zb2gtRvuouKwA7"]
 
46
                    ugol    [image create photo -data "R0lGODlhDAAMAJH/AP///8DAwH9/fwAAACH5BAEAAAEALAAAAAAMAAwAAAIbjI8BmSB83IMSKvFWw3dnHnFV+GVGhZZXmaoFADs="]
 
47
                    d1      [image create photo -data "R0lGODlhEAAQAPf/AP///////P//+///7///6f//5f//5P//4f//3P//2f//0v//z///zv//zf//zP//y///yv//yf//x///xv//xf//xP//wv/+5v/+1f/82//82v/81//81v/81f7/8/783v373Pv9x/v9vfr9zPn5+vn5+fn57/n57ff7yfX4v/T68uv0w+Dvrdvtr9TU19TU0dTT19PptNLS1dLS0tLS0dLSz8znoczMzszMzMvLy8nkxsnIksjjw8fHx8fHwMbGxsLCwsHBwcDAwL+/v76+vri4uLbiyLGxsbCwsK+vr6ampqWlpaGhoaCgoJaWmJaWlpOTk5KSko+Pj4yMjIvFa4mJiX7HsHq+YXJycmy2WmmzRmSyV2Cfe16uN1udkVqsM1RUVE2XhExJTkpIPkhFSURBRkI/R0I/RkGgFD2dEzo4OSWSCiKQAB0cHRyAaxcWFwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAEAAQAAAI0QDhCBxIsOAQOEESKly4EAAcIEeiPJn4xIkTKEp+EBniEEgTHCVCkjhhwgWYKTmIdGQyA4BLDxUY+LiBpcqPlS1dKuiiYscYMW+KrJRhgICOLWy+KHgQgEySlTUcpHBjJA0PBREwnEECdcEKLgVYJAghYcPWlTQAHBABocUHLw0ynH3IhKiFEVS0WAkTdy4QJjUeOIixBk0WFGXnBmHyogGFBTauDJggQStXOD2WwLiQgQMCEBo2dBDg1KEQKWrKnDFj5sxqM2TaCOXosrbt2wEBADs="]
 
48
                    d2      [image create photo -data "R0lGODlhEAAQAPf/AP///////f///P//+///9///8v//5v//5P//4///4f//3///3f//2///2f//2P//1P//0P//zv//y///yv//yf//yP//x///xf//w///wP/+5f/+2f/+1f/82//81//81v/81f7+v/v96vv9zPn7yPn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VpI8AMJU1SqBARosParzYEoNHjpUELDBbsehUCdoEZOWHK1BlRwcNdIldiPHCxwkqVFRQscIhDdM8PKjI0INigwACDDyAGuMG5p0gXOm/iwIETRzYcN3cc7njJu7dvAAEBADs="]
 
49
                    d3      [image create photo -data "R0lGODlhEAAQAPf/AP///////P//+v//9f//7///6///5f//4f//4P//2///2P//0P//z///zf//zP//y///yv//yf//yP//x///xv//xf//w//+5v/+3f/+2v/+2f/+1f/91//82//81//81vz+zPz9y/v98vn5+vn5+fn57/n57fj7w/j7wvj7ufb62O33tOn2oefzv+PxntTU19TU0dTT19LS1dLS0tLS0dLSz9DjxczMzszMzMvLy8nfxsjIjcfHx8fHwcbiocbGxsLCwsHBwcDZ0sDAwL+/v77htr6+vrvfrbrijLncsri4uLbTtbXbirLYhrGxsbCwsK+vr6jUeqampqWlpaHM0aGhoaCgoJjJx5aWmJaWlpOTk5KSko+Pj4yMjImJiXS5WnJycmq0UWSxOla0aFRUVFGsSExJTkukM0pIPkhFSUeRhERBRkKQlkI/R0I/Rj2eGzo4OSSRAB0cHRcWFxKIABFragB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAEAAQAAAI1wDvCBxIsCCRO0ESKlyokAiAO0CcbMlCMQsWLFqk/DBi5CEQKzhIiBxhosQLMl1y/PBYZQaAlwMsQOhxA4wXJSxdvjxQYcEONGbmQGEpg0CUMF9ATFgAIUCaJyxrMPBBJ44IFDYebHADFWKVGgrGFBGT4kQdHRq4sqQBgI0QBy5UULlyQK1XGQaWqEnQ5EwZJAjsAvn6IEIIBUnsvGnBwW6QKjAaUJAQYcURJiwUuBl6h8eUGBc6ePiAocCBDALS4LwzhAucNW7atHETu00aOQ4dvtzNu3dAADs="]
 
50
 
 
51
                    back    [image create photo -data "R0lGODlhDwANAKL/AM///8DAwJD//y/I/y+X/y9n/wAAAAAAACH5BAEAAAEALAAAAAAPAA0AAAM0GLq2/qE0+AqYVFmB6eZFKEoRIAyCaaYCYWxDLM9uYBAxoe/7dA8ug3AoZOg6mRsyuUxmEgA7"]
 
52
                    forward [image create photo -data "R0lGODlhDwANAKL/AM///8DAwJD//y/I/y+X/y9n/wAAAAAAACH5BAEAAAEALAAAAAAPAA0AAAM3GLpa/K8YSMuYlBVwV/kgCAhdsAFoig7ktA1wLA9SQdw4DkuB4f8/Ag2TMRB4GYUBmewRm09FAgA7"]
 
53
                    stop    [image create photo -data "R0lGODlhDQANALP/AP///1Lq81I5Of+EhCEAAHsAAMYAAP+UQv9zCHuMjP8AMf8AKf+MnK1CSv8QIQAAACH5BAEAAAEALAAAAAANAA0AAARWMMjUTC1J6ubOQYdiCBuIIMuiiCT1OWu6Ys05AMPC4ItBGB8dYMdI+RoHR4qY6v1CwlvRcEQ4brndwFAgJAwIRdPIzVTEYiqXJBEU1FQCW5Mg2O0ZSQQAOw=="]
 
54
                    refresh [image create photo -data "R0lGODlhDAANALP/AP///zk5OVJSUoSEhKWlpcDAwP//1v//xr3erZTOezGcEFKtSimce3NzezkxOQAAACH5BAEAAAUALAAAAAAMAA0AAARRcJBJyRilEMC5AcjQaB1wHMYkCFuXLKDQONsBLIuynEBAGAcJAnYy0AyGBOLENPg4qGUISTMdEIoEg4A6ohK6BND4YyqBqCdyve453vB44BEBADs="]
 
55
 
 
56
                    inc     [image create photo -data "R0lGODlhDAAMAJECAICAgAAAAP///wAAACH5BAEAAAIALAAAAAAMAAwAAAIglH+BphxtQADi2fTWkY9qdS2S42HWtECVOmJleGqyUQAAOw=="]
 
57
                    dec     [image create photo -data "R0lGODlhDAAMAJECAICAgAAAAP///wAAACH5BAEAAAIALAAAAAAMAAwAAAIalC+hirjdApyUygoCqG/mtEEL03yGFjHdUQAAOw=="]
 
58
                    cont    [image create photo -data "R0lGODlhDAAMALMAADg4ONDQ0AEBAZqamv///4aGhrCwsGdnZ2wCAgCYmIaenoaGnj8/BJiYAAQ/P56GhiH5BAAAAAAALAAAAAAMAAwAAARBkAwhACGADqJJOEcgUcAwAGVxKQiSeoKBGqQ5C2JxvkF8VwPVSLRoMEq74GUCVPU2hEfCAaABTxTSBYbbZrJgcAQAOw=="]
 
59
                    index   [image create photo -data "R0lGODlhDAAMAKIEAACAAP//AP///wAAAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAMAAwAAAMpSLM89G+IMMWCimrpogWAxURaRXUcqAZoWaKfCrCkWcGDPLf2GTVAQgIAOw=="]
 
60
                    find    [image create photo -data "R0lGODlhDAAMAJEDAMDAwP///wAAAP///yH5BAEAAAMALAAAAAAMAAwAAAIgnI8oaysa3hDxuMtadFtegE3UAnYYh3XiuGzQqTjJPBQAOw=="]
 
61
                    search  [image create photo -data "R0lGODlhDAAMALMPADExMP//j2hoaGFhLgEBAYWFhe3t7a2tqv39aNPT0xcXFqGhH1BQXCoqHQgICv///yH5BAEAAA8ALAAAAAAMAAwAAARV8LR2kk3m6RZCGeAgaA/QIV0HkByKBgiQlafSLIECHA8XHAoBY6Eo8BggR4HAXMoMlgaAIJAyExoB4UAFJJiOLIMJUAKmWYNDdii4CdmGY/QwKBSOCAA7"]
 
62
                    open    [image create photo -data "R0lGODlhDAAMALMPAOvr605OOfv7iDk5FbGxsZ2dNM3NzY2NjcrKXYaGAImJABoaCIuLABkZAGFhYf///yH5BAEAAA8ALAAAAAAMAAwAAARJ8EkJyBhmanAeDwTXaY/TEE5ROCxrHAcQCAJiIw4xzXSfhAAZrdAoFheNwawwYCieDEZAhhgkrlcF5rGwMrCMLbexKJt1pPQkAgA7"]
 
63
                    reload  [image create photo -data "R0lGODlhDAAMAKIHAO3tYefnnkVFQTExgzc3J29vf8DAXv///yH5BAEAAAcALAAAAAAMAAwAAAM7eEJ8/sqAYAR0ZE7GyQqTURSGQTFTMYwDGHzGoI3gAtDTsL4EJYMqiS2gKrgmCwmloDl5BNBF1HOpHhIAOw=="]
 
64
                    prev    [image create photo -data "R0lGODlhDAAMAKIEAAAAgP//AP///wAAAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAMAAwAAAMpSLM89G+IMMWCimrpYqUAE2kCAFCdBJpTupqo97ZjBVuyTWdflTZAQgIAOw=="]
 
65
                    up      [image create photo -data "R0lGODlhDAAMAKIEAAAAgP//AP///wAAAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAMAAwAAAMnSLM89G+IMMWCimrpYt1XVgFVJ1FAOploqpqCK7Nf6WkfjVNm4xMJADs="]
 
66
                    next    [image create photo -data "R0lGODlhDAAMAKIEAAAAgP//////AAAAAP///wAAAAAAAAAAACH5BAEAAAQALAAAAAAMAAwAAAMrSLM89G8EMcOCimrp4gTblQUAWHWSUJoCSq0m+pVb9LKWp2qTW/GohpCQAAA7"]
 
67
 "
 
68
 variable btninfo
 
69
#Controls/buttons:  link_name     text/hint  vis_cond  activ_cond  button_name
 
70
 array set btninfo "__prev     {[list "Back"     1 {$help::hpos>0} "bback"]}
 
71
                    contents   {[list "Contents" 1 {[lsearch $help::index "contents"]!=-1} "bcont"]}
 
72
                    __dec      {[list "Decrease" 1 {$help::fontsize>6} "bdec"]}
 
73
                    __find     {[list "Find"     1 1 "bfind"]}
 
74
                    __next     {[list "Forward"  1 {$help::hpos<[expr [llength $help::history] - 1]} "bforward"]}
 
75
                    __inc      {[list "Increase" 1 {$help::fontsize<30} "binc"]}
 
76
                    __index    {[list "Index"    1 {$help::index!=""} "bindex"]}
 
77
                    __Next     {[list "Next"     {$help::h4contents!=""} {[lsearch $help::sequence $help::curtopic]<[expr [llength $help::sequence] - 1] && [lsearch $help::sequence $help::curtopic]>-1} "bnext"]}
 
78
                    __open     {[list "Open"     1 1 "bopen"]}
 
79
                    __Prev     {[list "Previous" {$help::h4contents!=""} {[lsearch $help::sequence $help::curtopic]>0} "bprev"]}
 
80
                    __refresh  {[list "Refresh"  1 1 "brefresh"]}
 
81
                    __reload   {[list "Reload"   1 1 "breload"]}
 
82
                    __search   {[list "Search"   1 {$help::index!=""} "bsearch"]}
 
83
                    __stop     {[list "Stop"     1 {$help::showing || $help::insearch} "bstop"]}
 
84
                    __up1level {[list "UpLevel"  {$help::h4contents!=""} {[array names help::up1level $help::curtopic]!=""} "bup"]}
 
85
 "
 
86
 variable _istitle      0
 
87
 variable _isscript     0
 
88
 variable _istext       1
 
89
 variable _t_title
 
90
 variable _dnum         1
 
91
 variable _focus_w      ""
 
92
 variable _need_tag
 
93
#sch
 
94
 variable up1level 
 
95
 variable sequence      ""
 
96
 variable hcontents     ""
 
97
 variable h2ignore      ""
 
98
 variable h4topics      ""
 
99
 variable h4contents    ""
 
100
#/sch
 
101
 variable h_appendlist  1
 
102
 array set settings     "back {$backcolor} fore {$forecolor} link {$linkcolor} alink {$alinkcolor}"
 
103
 variable fnd_str       ""
 
104
 variable fnd_len
 
105
 variable fnd_case      "-nocase"
 
106
 variable fnd_regexp    ""
 
107
 variable fnd_direction "-forwards"
 
108
 variable searchedtext  ""
 
109
 variable insearch      0
 
110
 variable controls
 
111
 variable buttons
 
112
 variable interp
 
113
 variable tables
 
114
 array set tables       "level 0 stack {} count 0 tables {}"
 
115
 variable ext_loaded    ""
 
116
}
 
117
 
 
118
#===============================================================================
 
119
 
 
120
#-------------------------------------------------------------------------------
 
121
# Functions      :  help::tag_*
 
122
# Description    :  Process corresponding open/close tag
 
123
# Parameters     :  params      - arguments of tag
 
124
# Return         :  Nothing
 
125
#-------------------------------------------------------------------------------
 
126
proc help::tag_\$ {params} {
 
127
 variable data
 
128
 upvar _text _text
 
129
 
 
130
 foreach {param value} $params {
 
131
  if {[info exists data(subst,$param,begin)]} {
 
132
   set _text "$data(subst,$param,begin)$_text"
 
133
  }
 
134
  break
 
135
 }
 
136
}
 
137
 
 
138
proc help::tag_/\$ {params} {
 
139
 variable data
 
140
 upvar _text _text
 
141
 
 
142
 foreach {param value} $params {
 
143
  if {[info exists data(subst,$param,end)]} {
 
144
   set _text "$data(subst,$param,end)$_text"
 
145
  }
 
146
  break
 
147
 }
 
148
}
 
149
 
 
150
proc help::tag_center {params} {
 
151
 variable w
 
152
 variable attr
 
153
 
 
154
 set attr(justify,global) [linsert $attr(justify,global) 0 "center"]
 
155
 if {[$w.text get "end -2c"]!="\n"} {
 
156
  $w.text insert end "\n" [gettags]
 
157
 }
 
158
}
 
159
 
 
160
proc help::tag_/center {params} {
 
161
 variable w
 
162
 variable attr
 
163
 
 
164
 catch {set attr(justify,global) [lreplace $attr(justify,global) 0 0]}
 
165
 if {[$w.text get "end -2c"]!="\n"} {
 
166
  $w.text insert end "\n" [gettags]
 
167
 }
 
168
}
 
169
 
 
170
proc help::tag_b {params} {
 
171
 variable attr
 
172
 
 
173
 set attr(style) [linsert $attr(style) 0 "b"]
 
174
}
 
175
 
 
176
proc help::tag_/b {params} {
 
177
 variable attr
 
178
 
 
179
 if {[set pos [lsearch $attr(style) "b"]]!=-1} {
 
180
  set attr(style) [lreplace $attr(style) $pos $pos]
 
181
 }
 
182
}
 
183
 
 
184
proc help::tag_i {params} {
 
185
 variable attr
 
186
 
 
187
 set attr(style) [linsert $attr(style) 0 "i"]
 
188
}
 
189
 
 
190
proc help::tag_/i {params} {
 
191
 variable attr
 
192
 
 
193
 if {[set pos [lsearch $attr(style) "i"]]!=-1} {
 
194
  set attr(style) [lreplace $attr(style) $pos $pos]
 
195
 }
 
196
}
 
197
 
 
198
proc help::tag_u {params} {
 
199
 variable attr
 
200
 
 
201
 set attr(style) [linsert $attr(style) 0 "u"]
 
202
}
 
203
 
 
204
proc help::tag_/u {params} {
 
205
 variable attr
 
206
 
 
207
 if {[set pos [lsearch $attr(style) "u"]]!=-1} {
 
208
  set attr(style) [lreplace $attr(style) $pos $pos]
 
209
 }
 
210
}
 
211
 
 
212
proc help::tag_pre {params} {
 
213
 variable attr
 
214
 
 
215
 set attr(style) [linsert $attr(style) 0 "p"]
 
216
}
 
217
 
 
218
proc help::tag_/pre {params} {
 
219
 variable attr
 
220
 
 
221
 if {[set pos [lsearch $attr(style) "p"]]!=-1} {
 
222
  set attr(style) [lreplace $attr(style) $pos $pos]
 
223
 }
 
224
}
 
225
 
 
226
proc help::tag_nobr {params} {
 
227
 variable attr
 
228
 
 
229
 set attr(style) [linsert $attr(style) 0 "n"]
 
230
}
 
231
 
 
232
proc help::tag_/nobr {params} {
 
233
 variable attr
 
234
 
 
235
 if {[set pos [lsearch $attr(style) "n"]]!=-1} {
 
236
  set attr(style) [lreplace $attr(style) $pos $pos]
 
237
 }
 
238
}
 
239
 
 
240
proc help::tag_hr {params} {
 
241
 variable attr
 
242
 variable w
 
243
 variable _text
 
244
 
 
245
 if {[$w.text get "end -2c"]!="\n"} {
 
246
  $w.text insert end "\n" [gettags]
 
247
 }
 
248
 set p_height ""
 
249
 set p_color ""
 
250
 foreach {param value} $params {
 
251
  set p_$param $value
 
252
 }
 
253
 eval "$w.text insert end [gethr $p_height $p_color]"
 
254
 if {[string index $_text 0]=="\n"} {
 
255
  set _text [string range $_text 1 end]
 
256
 }
 
257
}
 
258
 
 
259
proc help::tag_br {params} {
 
260
 variable w
 
261
 $w.text insert end "\n" [gettags]
 
262
}
 
263
 
 
264
proc help::tag_ul {params} {
 
265
 variable w
 
266
 variable attr
 
267
 
 
268
 set attr(justify) ""
 
269
 set p_type "disc"
 
270
 set p_indent 48
 
271
 foreach {param value} $params {
 
272
  set p_$param $value
 
273
 }
 
274
 incr attr(margin) $p_indent
 
275
 set attr(ul_type) [linsert $attr(ul_type) 0 $p_type]
 
276
 set attr(indent) [linsert $attr(indent) 0 $p_indent]
 
277
# if {[$w.text get "end -3c"]!="\n"} {
 
278
#  $w.text insert end "\n" [gettags]
 
279
# }
 
280
 if {[$w.text get "end -3c"]!="\n"} {
 
281
  $w.text insert end "\n" [gettags]
 
282
 }
 
283
}
 
284
 
 
285
proc help::tag_/ul {params} {
 
286
 variable w
 
287
 variable attr
 
288
 variable lmargin
 
289
 variable tables
 
290
 
 
291
 catch {incr attr(margin) [expr {-[lindex $attr(indent) 0]}]}
 
292
 if {$attr(margin)<$lmargin && $tables(stack)==""} {set attr(margin) $lmargin}
 
293
 if {[$w.text get "end-3c"]!="\n"} {
 
294
  $w.text insert end "\n" [gettags]
 
295
 }
 
296
 catch {set attr(indent) [lreplace $attr(indent) 0 0]}
 
297
 catch {set attr(ul_type) [lreplace $attr(ul_type) 0 0]}
 
298
}
 
299
 
 
300
proc help::tag_li {params} {
 
301
 variable w
 
302
 variable attr
 
303
 variable data
 
304
 variable _text
 
305
 variable _count
 
306
 variable _images
 
307
 variable rmargin
 
308
 
 
309
 if {[$w.text get "end -2c"]!="\n"} {
 
310
  $w.text insert end "\n" [gettags]
 
311
 }
 
312
 set p_type [lindex $attr(ul_type) 0]
 
313
 foreach {param value} $params {
 
314
  set p_$param $value
 
315
 }
 
316
 if {![info exists _images($p_type)]} {
 
317
  if {[info exists data($p_type,image)]} {
 
318
   set im $data($p_type,image)
 
319
  } else {
 
320
   set im $_images(disc)
 
321
  }
 
322
 } else {
 
323
  set im $_images($p_type)
 
324
 }
 
325
 catch {set imind [$w.text image create end -image $im -align center -padx 3]}
 
326
 catch {$w.text tag add [gettags] $imind}
 
327
 catch {$w.text tag configure tag[incr _count] -lmargin1 [expr $attr(margin) - 22] -rmargin $rmargin}
 
328
 catch {$w.text tag add tag$_count $imind}
 
329
 set _text [string trimleft $_text " \t\n"]
 
330
}
 
331
 
 
332
proc help::tag_p {params} {
 
333
 variable w
 
334
 variable attr
 
335
 
 
336
 if {[$w.text get "end -3c"]!="\n"} {
 
337
  $w.text insert end "\n" [gettags]
 
338
 }
 
339
 if {[$w.text get "end -3c"]!="\n"} {
 
340
  $w.text insert end "\n" [gettags]
 
341
 }
 
342
 set p_align ""
 
343
 foreach {param value} $params {
 
344
  set p_$param $value
 
345
 }
 
346
 
 
347
 if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
 
348
 set attr(justify) $p_align
 
349
}
 
350
 
 
351
proc help::tag_/p {params} {
 
352
 variable attr
 
353
 
 
354
 set attr(justify) ""
 
355
}
 
356
 
 
357
proc help::tag_a {params} {
 
358
 variable w
 
359
 variable attr
 
360
 upvar mark mark
 
361
 
 
362
 set p_name ""
 
363
 set p_href ""
 
364
 set p_title ""
 
365
 foreach {param value} $params {
 
366
  set p_$param $value
 
367
 }
 
368
#sch p_href bearbeiten
 
369
# if p_href is a external reference (http: file: mailto: usw.), then ignore
 
370
 if {[string first ":" $p_href]>=0} {
 
371
  switch -glob -- [string tolower $p_href] {
 
372
   file://* {set p_href [string range $p_href 7 end]}
 
373
   tcl:* {set p_href "tcl:[string range $p_href 4 end]"}
 
374
   tclscript:* {set p_href "tclscript:[string range $p_href 10 end]"}
 
375
   default {set p_title $p_href
 
376
            set p_href "tcl:help::showurl {$p_href}"
 
377
           }
 
378
  }
 
379
 }
 
380
 if {$p_href!="" && ![regexp "^tcl(script)?:" $p_href]} {
 
381
  set p_href_neu [string tolower $p_href]
 
382
  variable curtopic
 
383
  set filename ""
 
384
  if {[set pos [string first "?" $curtopic]]!=-1} {
 
385
   set filename [string tolower [string range $curtopic 0 [expr $pos - 1]]]
 
386
   if {[string first "#" $p_href_neu]==0} {
 
387
    set p_href_neu $filename?[string range $p_href_neu 1 end]
 
388
   } elseif {[set pos [string first "#" $p_href_neu]]>0} {
 
389
    set p_href_neu [string replace $p_href_neu $pos $pos "?"]
 
390
   } 
 
391
  }
 
392
  variable index
 
393
  if {[lsearch $index $p_href_neu]>=0} {
 
394
   set p_href $p_href_neu
 
395
  } else {
 
396
   if {[string first "#" $p_href]==0} {
 
397
    set p_href $curtopic$p_href
 
398
   } else {
 
399
   }
 
400
  }
 
401
 }
 
402
#/sch
 
403
 set attr(links) [linsert $attr(links) 0 $p_href]
 
404
 
 
405
 if {$p_name!=""} {
 
406
  set p_name [string tolower $p_name]
 
407
  $w.text mark set "mark_$p_name" [$w.text index end-1c]
 
408
  $w.text mark gravity "mark_$p_name" left
 
409
  if {$p_name==$mark} {
 
410
   after 200 "catch {$w.text yview \"mark_$p_name\"}; catch {$w.text see \"mark_$p_name\"}"
 
411
  }
 
412
 }
 
413
 
 
414
 set attr(link_titles) [linsert $attr(link_titles) 0 $p_title]
 
415
}
 
416
 
 
417
proc help::tag_/a {params} {
 
418
 variable attr
 
419
 
 
420
 catch {set attr(links) [lreplace $attr(links) 0 0]}
 
421
 catch {set attr(link_titles) [lreplace $attr(link_titles) 0 0]}
 
422
}
 
423
 
 
424
proc help::tag_font {params} {
 
425
 variable attr
 
426
 variable fontsize
 
427
 
 
428
 set tag_font ""
 
429
 set p_color ""
 
430
 set p_bgcolor ""
 
431
 set p_size ""
 
432
 set p_face ""
 
433
 set {p_point-size} ""
 
434
 foreach {param value} $params {
 
435
  set p_$param $value
 
436
 }
 
437
 if {$p_color!=""} {
 
438
  set attr(colors) [linsert $attr(colors) 0 [correctcolor [string tolower $p_color]]]
 
439
  lappend tag_font "colors"
 
440
 }
 
441
 if {$p_bgcolor!=""} {
 
442
  set attr(bgcolors) [linsert $attr(bgcolors) 0 [correctcolor [string tolower $p_bgcolor]]]
 
443
  lappend tag_font "bgcolors"
 
444
 }
 
445
 if {$p_size!=""} {
 
446
  if {[set sign [string index $p_size 0]]=="+" || $sign=="-" || ($p_size=="0" && [set sign "+"]=="+")} {
 
447
   set attr(sizes) [linsert $attr(sizes) 0 "$sign[expr {abs($p_size) * 2}]"]
 
448
  } else {
 
449
   set attr(sizes) [linsert $attr(sizes) 0 [expr {$p_size * 2 + $fontsize - 6}]]
 
450
  }
 
451
  lappend tag_font "sizes"
 
452
 }
 
453
 if {${p_point-size}!=""} {
 
454
  set attr(sizes) [linsert $attr(sizes) 0 ${p_point-size}]
 
455
  lappend tag_font "sizes"
 
456
 }
 
457
 if {$p_face!=""} {
 
458
  set attr(face) [linsert $attr(face) 0 $p_face]
 
459
  lappend tag_font "face"
 
460
 }
 
461
 set attr(tag_fonts) [linsert $attr(tag_fonts) 0 $tag_font]
 
462
}
 
463
 
 
464
proc help::tag_/font {params} {
 
465
 variable attr
 
466
 
 
467
 foreach t [lindex $attr(tag_fonts) 0] {
 
468
  catch {set attr($t) [lreplace $attr($t) 0 0]}
 
469
 }
 
470
 catch {set attr(tag_fonts) [lreplace $attr(tag_fonts) 0 0]}
 
471
}
 
472
 
 
473
proc help::tag_img {params} {
 
474
 variable w
 
475
 variable attr
 
476
 variable data
 
477
 variable curfilename
 
478
 variable _images
 
479
 
 
480
 set p_src ""
 
481
 set p_align ""
 
482
 set p_border ""
 
483
 set p_id ""
 
484
 foreach {param value} $params {
 
485
  set p_$param $value
 
486
 }
 
487
 if {[info exists data($p_src,image)]} {
 
488
  catch {set imind [$w.text image create end -image $data($p_src,image)]}
 
489
 } else {
 
490
#sch i think you mean [catch {...}] == 0
 
491
#angra No, i mean that i mean: if i can't load image, the default image is drawing
 
492
 if {[catch {set data($p_src,image) [image create photo -file [file join [file dirname $curfilename] $p_src]]}]} {
 
493
#/sch
 
494
   catch {set imind [$w.text image create end -image $_images(broken)]}
 
495
 } else {
 
496
   catch {set imind [$w.text image create end -image $data($p_src,image)]}
 
497
  }
 
498
 }
 
499
 if {[set p_align [string tolower $p_align]]=="middle"} {
 
500
  set p_align "center"
 
501
 }
 
502
 catch {$w.text image configure $imind -align [string tolower $p_align]}
 
503
 catch {$w.text image configure $imind -padx $p_border -pady $p_border}
 
504
 catch {$w.text tag add [gettags] $imind}
 
505
 if {$p_id!=""} {
 
506
  set data($p_id,image,id) $imind
 
507
  set data($p_id,image,widget) $w
 
508
 }
 
509
}
 
510
 
 
511
proc help::tag_tt {params} {
 
512
 variable attr
 
513
 
 
514
 set attr(style) [linsert $attr(style) 0 "t"]
 
515
}
 
516
 
 
517
proc help::tag_/tt {params} {
 
518
 variable attr
 
519
 
 
520
 if {[set pos [lsearch $attr(style) "t"]]!=-1} {
 
521
  set attr(style) [lreplace $attr(style) $pos $pos]
 
522
 }
 
523
}
 
524
 
 
525
proc help::tag_ol {params} {
 
526
 tag_ul $params
 
527
}
 
528
 
 
529
proc help::tag_/ol {params} {
 
530
 tag_/ul $params
 
531
}
 
532
 
 
533
proc help::tag_em {params} {
 
534
 tag_i $params
 
535
}
 
536
 
 
537
proc help::tag_/em {params} {
 
538
 tag_/i $params
 
539
}
 
540
 
 
541
proc help::tag_strong {params} {
 
542
 tag_b $params
 
543
}
 
544
 
 
545
proc help::tag_/strong {params} {
 
546
 tag_/b $params
 
547
}
 
548
 
 
549
proc help::tag_code {params} {
 
550
 tag_tt {}
 
551
 tag_font {size +0}
 
552
}
 
553
 
 
554
proc help::tag_/code {params} {
 
555
 tag_/font {}
 
556
 tag_/tt {}
 
557
}
 
558
 
 
559
proc help::tag_samp {params} {
 
560
 tag_code {}
 
561
}
 
562
 
 
563
proc help::tag_/samp {params} {
 
564
 tag_/code {}
 
565
}
 
566
 
 
567
proc help::tag_kbd {params} {
 
568
 variable attr
 
569
 
 
570
 set attr(style) [linsert $attr(style) 0 "k"]
 
571
}
 
572
 
 
573
proc help::tag_/kbd {params} {
 
574
 variable attr
 
575
 
 
576
 if {[set pos [lsearch $attr(style) "k"]]!=-1} {
 
577
  set attr(style) [lreplace $attr(style) $pos $pos]
 
578
 }
 
579
}
 
580
 
 
581
proc help::tag_cite {params} {
 
582
 tag_i $params
 
583
}
 
584
 
 
585
proc help::tag_/cite {params} {
 
586
 tag_/i $params
 
587
}
 
588
 
 
589
proc help::tag_var {params} {
 
590
 tag_i $params
 
591
}
 
592
 
 
593
proc help::tag_/var {params} {
 
594
 tag_/i $params
 
595
}
 
596
 
 
597
proc help::tag_address {params} {
 
598
 tag_i $params
 
599
}
 
600
 
 
601
proc help::tag_/address {params} {
 
602
 tag_/i $params
 
603
}
 
604
 
 
605
proc help::tag_h1 {params} {
 
606
 variable w
 
607
 variable attr
 
608
 variable fontsize
 
609
 
 
610
 set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize + 10}]]    ;#22
 
611
 set attr(style) [linsert $attr(style) 0 "b"]
 
612
#sch
 
613
 if {[$w.text get "end -3c"]!="\n"} {
 
614
  $w.text insert end "\n" [gettags]
 
615
 }
 
616
 if {[$w.text get "end -3c"]!="\n"} {
 
617
  $w.text insert end "\n" [gettags]
 
618
 }
 
619
 set p_align ""
 
620
 foreach {param value} $params {
 
621
  set p_$param $value
 
622
 }
 
623
 
 
624
 if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
 
625
 set attr(justify) $p_align
 
626
#/sch
 
627
}
 
628
 
 
629
proc help::tag_/h1 {params} {
 
630
 variable w
 
631
 variable attr
 
632
 
 
633
 if {[set pos [lsearch $attr(style) "b"]]!=-1} {
 
634
  set attr(style) [lreplace $attr(style) $pos $pos]
 
635
 }
 
636
 catch {set attr(sizes) [lreplace $attr(sizes) 0 0]}
 
637
 if {[$w.text get "end -2c"]!="\n"} {
 
638
  $w.text insert end "\n" [gettags]
 
639
 }
 
640
#sch
 
641
 set attr(justify) ""
 
642
#/sch
 
643
}
 
644
 
 
645
proc help::tag_h2 {params} {
 
646
 variable w
 
647
 variable attr
 
648
 variable fontsize
 
649
 
 
650
 set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize + 6}]]  ;#18
 
651
 set attr(style) [linsert $attr(style) 0 "b"]
 
652
#sch
 
653
 if {[$w.text get "end -3c"]!="\n"} {
 
654
  $w.text insert end "\n" [gettags]
 
655
 }
 
656
 if {[$w.text get "end -3c"]!="\n"} {
 
657
  $w.text insert end "\n" [gettags]
 
658
 }
 
659
 set p_align ""
 
660
 foreach {param value} $params {
 
661
  set p_$param $value
 
662
 }
 
663
 
 
664
 if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
 
665
 set attr(justify) $p_align
 
666
#/sch
 
667
}
 
668
 
 
669
proc help::tag_/h2 {params} {
 
670
 tag_/h1 $params
 
671
}
 
672
 
 
673
proc help::tag_h3 {params} {
 
674
 variable w
 
675
 variable attr
 
676
 variable fontsize
 
677
 
 
678
 set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize + 2}]]  ;#14
 
679
 set attr(style) [linsert $attr(style) 0 "b"]
 
680
#sch
 
681
 if {[$w.text get "end -3c"]!="\n"} {
 
682
  $w.text insert end "\n" [gettags]
 
683
 }
 
684
 if {[$w.text get "end -3c"]!="\n"} {
 
685
  $w.text insert end "\n" [gettags]
 
686
 }
 
687
 set p_align ""
 
688
 foreach {param value} $params {
 
689
  set p_$param $value
 
690
 }
 
691
 
 
692
 if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
 
693
 set attr(justify) $p_align
 
694
#/sch
 
695
}
 
696
 
 
697
proc help::tag_/h3 {params} {
 
698
 tag_/h1 $params
 
699
}
 
700
 
 
701
proc help::tag_h4 {params} {
 
702
 variable w
 
703
 variable attr
 
704
 variable fontsize
 
705
 
 
706
 set attr(sizes) [linsert $attr(sizes) 0 $fontsize]  ;#12
 
707
 set attr(style) [linsert $attr(style) 0 "b"]
 
708
#sch
 
709
 if {[$w.text get "end -3c"]!="\n"} {
 
710
  $w.text insert end "\n" [gettags]
 
711
 }
 
712
 if {[$w.text get "end -3c"]!="\n"} {
 
713
  $w.text insert end "\n" [gettags]
 
714
 }
 
715
 set p_align ""
 
716
 foreach {param value} $params {
 
717
  set p_$param $value
 
718
 }
 
719
 
 
720
 if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
 
721
 set attr(justify) $p_align
 
722
#/sch
 
723
}
 
724
 
 
725
proc help::tag_/h4 {params} {
 
726
 tag_/h1 $params
 
727
}
 
728
 
 
729
proc help::tag_h5 {params} {
 
730
 variable w
 
731
 variable attr
 
732
 variable fontsize
 
733
 
 
734
 set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize - 2}]]  ;#10
 
735
 set attr(style) [linsert $attr(style) 0 "b"]
 
736
#sch
 
737
 if {[$w.text get "end -3c"]!="\n"} {
 
738
  $w.text insert end "\n" [gettags]
 
739
 }
 
740
 if {[$w.text get "end -3c"]!="\n"} {
 
741
  $w.text insert end "\n" [gettags]
 
742
 }
 
743
 set p_align ""
 
744
 foreach {param value} $params {
 
745
  set p_$param $value
 
746
 }
 
747
 
 
748
 if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
 
749
 set attr(justify) $p_align
 
750
#/sch
 
751
}
 
752
 
 
753
proc help::tag_/h5 {params} {
 
754
 tag_/h1 $params
 
755
}
 
756
 
 
757
proc help::tag_h6 {params} {
 
758
 variable w
 
759
 variable attr
 
760
 variable fontsize
 
761
 
 
762
 set attr(sizes) [linsert $attr(sizes) 0 [expr {$fontsize - 4}]]  ;#8
 
763
 set attr(style) [linsert $attr(style) 0 "b"]
 
764
#sch
 
765
 if {[$w.text get "end -3c"]!="\n"} {
 
766
  $w.text insert end "\n" [gettags]
 
767
 }
 
768
 if {[$w.text get "end -3c"]!="\n"} {
 
769
  $w.text insert end "\n" [gettags]
 
770
 }
 
771
 set p_align ""
 
772
 foreach {param value} $params {
 
773
  set p_$param $value
 
774
 }
 
775
 
 
776
 if {[set p_align [string tolower $p_align]]!="left" && $p_align!="center" && $p_align!="right"} {set p_align ""}
 
777
 set attr(justify) $p_align
 
778
#/sch
 
779
}
 
780
 
 
781
proc help::tag_/h6 {params} {
 
782
 tag_/h1 $params
 
783
}
 
784
 
 
785
proc help::tag_blockquote {params} {
 
786
 tag_ul {}
 
787
}
 
788
 
 
789
proc help::tag_/blockquote {params} {
 
790
 tag_/ul {}
 
791
}
 
792
 
 
793
proc help::tag_menu {params} {
 
794
 tag_ul {}
 
795
}
 
796
 
 
797
proc help::tag_/menu {params} {
 
798
 tag_/ul {}
 
799
}
 
800
 
 
801
proc help::tag_dir {params} {
 
802
 tag_ul {}
 
803
}
 
804
 
 
805
proc help::tag_/dir {params} {
 
806
 tag_/ul {}
 
807
}
 
808
 
 
809
proc help::tag_div {params} {
 
810
 tag_p $params
 
811
}
 
812
 
 
813
proc help::tag_/div {params} {
 
814
 tag_/p $params
 
815
}
 
816
 
 
817
proc help::tag_body {params} {
 
818
 variable w
 
819
 variable settings
 
820
 variable _t_title
 
821
 
 
822
 tag_/head {}
 
823
 foreach {v1 v2} {text fore bgcolor back link link alink alink} {
 
824
  set p_$v1 $settings($v2)
 
825
 }
 
826
 foreach {param value} $params {
 
827
  set p_$param $value
 
828
 }
 
829
 foreach {v1 v2} {text fore bgcolor back link link alink alink} {
 
830
  set settings($v2) [correctcolor [string tolower [set p_$v1]]]
 
831
 }
 
832
 catch {$w.text configure -foreground $settings(fore)}
 
833
 catch {$w.text configure -background $settings(back)}
 
834
 catch {$w.title configure -foreground $settings(fore)}
 
835
 catch {$w.title configure -background $settings(back)}
 
836
 foreach {name} {title line __index contents __next __prev __Next __Prev __up1level 
 
837
                 __dec __find __inc __open __refresh __reload __stop __search} {
 
838
  catch {
 
839
   if {[$w.title bind $_t_title($name) <1>]==""} {
 
840
    catch {$w.title itemconfigure $_t_title($name) -fill $settings(fore)}
 
841
   } else {
 
842
    catch {$w.title itemconfigure $_t_title($name) -fill $settings(link)}
 
843
   }
 
844
  }
 
845
 }
 
846
}
 
847
 
 
848
proc help::tag_title {params} {
 
849
 variable _istitle 1
 
850
}
 
851
 
 
852
proc help::tag_/title {params} {
 
853
 variable w
 
854
 variable _istitle 0
 
855
 variable _t_title
 
856
 variable data
 
857
 
 
858
 if {[info exists data(title)] && $data(title)!=""} {
 
859
  regsub -all -- "\[\r\n \]+" $data(title) " " data(title)
 
860
 } else {
 
861
  set data(title) "Untitled"
 
862
 }
 
863
 
 
864
 if {[string match {.tophelpwindow*} $w]} {
 
865
  wm title .tophelpwindow "Help - [specialentities $data(title)]"
 
866
 }
 
867
 $w.title itemconfigure $_t_title(title) -text [specialentities $data(title)]
 
868
}
 
869
 
 
870
proc help::tag_/head {params} {
 
871
 variable _istitle
 
872
 
 
873
 if {$_istitle} {
 
874
  tag_/title {}
 
875
 }
 
876
}
 
877
 
 
878
proc help::tag_/tr {params} {
 
879
 variable w
 
880
 
 
881
 if {[$w.text get "end -2c"]!="\n"} {
 
882
  $w.text insert end "\n" [gettags]
 
883
 }
 
884
}
 
885
 
 
886
proc help::tag_/td {params} {
 
887
 variable w
 
888
 
 
889
 if {[$w.text get "end -2c"]!=" "} {
 
890
  $w.text insert end " " [gettags]
 
891
 }
 
892
}
 
893
 
 
894
proc help::tag_table {params} {
 
895
 variable w
 
896
 variable attr
 
897
 
 
898
 if {[$w.text get "end -2c"]!="\n"} {
 
899
  $w.text insert end "\n" [gettags]
 
900
 }
 
901
 
 
902
 set p_bgcolor ""
 
903
 foreach {param value} $params {
 
904
  set p_$param $value
 
905
 }
 
906
 if {$p_bgcolor!=""} {
 
907
  set attr(bgcolors) [linsert $attr(bgcolors) 0 [correctcolor [string tolower $p_bgcolor]]]
 
908
  set attr(tables) [linsert $attr(tables) 0 "bg"]
 
909
 }
 
910
}
 
911
 
 
912
proc help::tag_/table {params} {
 
913
 variable w
 
914
 variable attr
 
915
 
 
916
 if {[$w.text get "end -2c"]!="\n"} {
 
917
  $w.text insert end "\n" [gettags]
 
918
 }
 
919
 if {[set pos [lsearch $attr(tables) "bg"]]!=-1} {
 
920
  set attr(tables) [lreplace $attr(tables) $pos $pos]
 
921
  catch {set attr(bgcolors) [lreplace $attr(bgcolors) 0 0]}
 
922
 }
 
923
}
 
924
 
 
925
proc help::tag_dd {params} {
 
926
 variable w
 
927
 variable _need_tag
 
928
 
 
929
 if {[set pos [lsearch $_need_tag "/dt"]]!=-1} {
 
930
  tag_/dt {}
 
931
 }
 
932
 if {[$w.text get "end -2c"]!="\n"} {
 
933
  $w.text insert "end -1c" "\n" [gettags]
 
934
 }
 
935
 set _need_tag [linsert $_need_tag 0 "/dd"]
 
936
}
 
937
 
 
938
proc help::tag_/dd {params} {
 
939
 variable _need_tag
 
940
 
 
941
 if {[set pos [lsearch $_need_tag "/dd"]]!=-1} {
 
942
  set _need_tag [lreplace $_need_tag $pos $pos]
 
943
 }
 
944
}
 
945
 
 
946
proc help::tag_dl {params} {
 
947
 tag_ul {}
 
948
}
 
949
 
 
950
proc help::tag_/dl {params} {
 
951
 tag_/ul {}
 
952
}
 
953
 
 
954
proc help::tag_dt {params} {
 
955
 variable w
 
956
 variable _need_tag
 
957
 
 
958
 if {[set pos [lsearch $_need_tag "/dt"]]!=0} {
 
959
  set _need_tag [linsert $_need_tag 0 "/dt"]
 
960
  tag_/ul {}
 
961
 } else {
 
962
  if {[$w.text get "end -2c"]!="\n"} {
 
963
   $w.text insert "end -1c" "\n" [gettags]
 
964
  }
 
965
 }
 
966
}
 
967
 
 
968
proc help::tag_/dt {params} {
 
969
 variable _need_tag
 
970
 
 
971
 if {[set pos [lsearch $_need_tag "/dt"]]!=-1} {
 
972
  set _need_tag [lreplace $_need_tag $pos $pos]
 
973
 }
 
974
 tag_ul {}
 
975
}
 
976
 
 
977
proc help::tag_frame {params} {
 
978
 variable w
 
979
 
 
980
 set p_name ""
 
981
 set p_src ""
 
982
 foreach {param value} $params {
 
983
  set p_$param $value
 
984
 }
 
985
 if {$p_name==""} {
 
986
  set p_name $p_src
 
987
 }
 
988
 if {$p_src!=""} {
 
989
  if {[$w.text get "end -2c"]!="\n"} {
 
990
   $w.text insert end "\n" [gettags]
 
991
  }
 
992
  $w.text insert end "Frame " [gettags]
 
993
  tag_a [list href $p_src]
 
994
  $w.text insert end "$p_name" [gettags]
 
995
  tag_/a {}
 
996
  tag_br {}
 
997
 }
 
998
}
 
999
 
 
1000
proc help::tag_script {params} {
 
1001
 variable _isscript
 
1002
 variable _istext
 
1003
 variable data
 
1004
 
 
1005
 set p_language ""
 
1006
 foreach {param value} $params {
 
1007
  set p_$param $value
 
1008
 }
 
1009
 if {[string tolower $p_language]=="tclscript"} {
 
1010
  set _isscript 1
 
1011
  set data(script) ""
 
1012
 } else {
 
1013
  set _istext 0
 
1014
 }
 
1015
}
 
1016
 
 
1017
proc help::tag_/script {params} {
 
1018
 variable data
 
1019
 variable interp
 
1020
 variable _isscript
 
1021
 variable _istext
 
1022
 
 
1023
 if {$_isscript && $data(script)!=""} {
 
1024
  if {[catch {$interp eval $data(script)}]} {
 
1025
   set data(__@Error@__,title) "Error in loaded script"
 
1026
   set data(__@Error@__,text) "<font color=red><pre>[string map {{&} {&amp;} {>} {&gt;} {<} {&lt;}} $::errorInfo]</pre></font>"
 
1027
   set _isscript 0
 
1028
   show __@Error@__  
 
1029
  }
 
1030
 } elseif {!$_istext} {
 
1031
  set _istext 1
 
1032
 }
 
1033
 set _isscript 0
 
1034
}
 
1035
 
 
1036
proc help::tag_style {params} {
 
1037
 variable _istext 0
 
1038
}
 
1039
 
 
1040
proc help::tag_/style {params} {
 
1041
 variable _istext 1
 
1042
}
 
1043
 
 
1044
proc help::tag_span {params} {
 
1045
 variable w
 
1046
 variable attr
 
1047
 variable data
 
1048
 variable _count
 
1049
 
 
1050
 set p_id ""
 
1051
 set p_hidden 0
 
1052
 foreach {param value} $params {
 
1053
  set p_$param $value
 
1054
 }
 
1055
 if {$p_id!=""} {
 
1056
  incr _count
 
1057
  set data($p_id,names,id) "tag$_count"
 
1058
  set data($p_id,names,widget) $w
 
1059
  set data($p_id,names,pos) [$w.text index "end-1c"]
 
1060
  if {$p_hidden==""} {set p_hidden 1}
 
1061
  catch {$w.text tag configure "tag$_count" -elide $p_hidden}
 
1062
 }
 
1063
 set attr(span) [linsert $attr(span) 0 $p_id]
 
1064
}
 
1065
 
 
1066
proc help::tag_/span {params} {
 
1067
 variable attr
 
1068
 variable data
 
1069
 
 
1070
 if {[set p_id [lindex $attr(span) 0]]!=""} {
 
1071
  catch {$data($p_id,names,widget).text tag add $data($p_id,names,id) $data($p_id,names,pos) "end-1c"}
 
1072
 }
 
1073
 set attr(span) [lreplace $attr(span) 0 0]
 
1074
}
 
1075
 
 
1076
#===============================================================================
 
1077
 
 
1078
#-------------------------------------------------------------------------------
 
1079
# Function       :  help::correctcolor
 
1080
# Description    :  Converts color names to color values
 
1081
# Parameters     :  color       - name of color
 
1082
# Return         :  Color value
 
1083
#-------------------------------------------------------------------------------
 
1084
proc help::correctcolor {color} {
 
1085
 return [string map {\
 
1086
   green   "#008000" silver "#c0c0c0" lime   "#00ff00" gray "#808080" \
 
1087
   olive   "#808000" navy   "#000080" purple "#800080" teal "#008080" \
 
1088
   fuchsia "#ff00ff" aqua   "#00ffff" maroon "#800000"
 
1089
 } $color]
 
1090
}
 
1091
 
 
1092
#-------------------------------------------------------------------------------
 
1093
# Function       :  help::_load
 
1094
# Description    :  Load helpfile with includes
 
1095
# Parameters     :  filename    - name of file with help
 
1096
# Return         :  True or false
 
1097
#-------------------------------------------------------------------------------
 
1098
proc help::_load {filename} {
 
1099
 variable stat
 
1100
 variable data
 
1101
 variable index 
 
1102
 variable font 
 
1103
 variable fontfixed 
 
1104
 variable fontsize 
 
1105
 variable backcolor 
 
1106
 variable forecolor 
 
1107
 variable linkcolor 
 
1108
 variable alinkcolor
 
1109
 variable lmargin
 
1110
 variable rmargin
 
1111
 variable curfilename
 
1112
#sch
 
1113
 variable hcontents
 
1114
 variable h2ignore 
 
1115
 variable h4topics
 
1116
 variable h4contents
 
1117
 set schAnkerNr 0
 
1118
 set headerstr ""
 
1119
 set headerlevel ""
 
1120
 set headertxt ""
 
1121
 set topicname ""
 
1122
 set topictitle ""
 
1123
#/sch
 
1124
 variable h_appendlist
 
1125
 variable searchedtext ""
 
1126
 variable controls
 
1127
 variable buttons
 
1128
 
 
1129
 set stat "Loading $filename..."
 
1130
 update
 
1131
 if {[catch {set fname [::open $filename r]}]!=0} {
 
1132
  append data(__file_error,text)  "<p><font color=#c00000>Error while opening file:</font> <b>\"$filename\"</b><font color=#c00000>!</font></p>"
 
1133
  set data(__file_error,title) "Error!"
 
1134
  if {![info exists index] || [lsearch $index "__file_error"]==-1} {
 
1135
   lappend index __file_error
 
1136
  }
 
1137
  return 0
 
1138
 }
 
1139
 set curtopic ""
 
1140
 set filedata ""
 
1141
 while {![eof $fname]} {
 
1142
  append filedata [read $fname 100000]
 
1143
 }
 
1144
 ::close $fname
 
1145
 if {$h4topics!="" || $h4contents!=""} {
 
1146
  regsub -all -- {<!--.*?-->} $filedata "" filedata
 
1147
 }
 
1148
 set filedata [split $filedata "\n"]
 
1149
 foreach str $filedata {
 
1150
#sch test section headings and create topics, fill hcontents
 
1151
  append headerstr $str
 
1152
  if {![regexp -nocase {<h[1-6][^>]*>} $headerstr]} {
 
1153
   set headerstr ""
 
1154
  } elseif {[regexp -nocase \
 
1155
  {<h([1-6])[^>]*>(.*?)</h[1-6]>} $headerstr Dummy headerlevel headertxt]} {
 
1156
 
 
1157
   if {$h2ignore!="" && [regexp -nocase $h2ignore $headerstr]} {
 
1158
    set str $headerstr
 
1159
    set headerstr ""
 
1160
#    continue
 
1161
   } else {
 
1162
    if {$h4topics!="" && [regexp -nocase -- $h4topics $headerstr]} {
 
1163
     regsub -all -nocase -- {<br>} $headertxt { } headertxt
 
1164
     regsub -all -- {<[^>]*>} $headertxt {} topictitle
 
1165
     if {![regexp -nocase {^.*<a +.*? *name *= *(" *([^\"]+) *"|([^\"]([^ >]*)))} \
 
1166
     $headertxt Dummy topicname]} {
 
1167
      set topicname internal_[incr schAnkerNr]
 
1168
     }
 
1169
     set curtopic [string tolower [file tail $filename]?[string trim $topicname "\t\" "]]
 
1170
     lappend index $curtopic
 
1171
     set data($curtopic,text) ""
 
1172
     set data($curtopic,title) [string trim [specialentities $topictitle] "\t\" "]
 
1173
    } else {
 
1174
     set topicname ""
 
1175
    }
 
1176
  
 
1177
    if {$h4contents!="" && [regexp -nocase -- $h4contents $headerstr]} {
 
1178
     regsub -all -nocase -- {<br>} $headertxt { } headertxt
 
1179
     regsub -all -- {<[^>]*>} $headertxt {} topictitle
 
1180
     if {$topicname!=""} {
 
1181
      lappend hcontents [list $headertxt $headerlevel [string trim $topictitle] $curtopic]
 
1182
     } else {
 
1183
      lappend hcontents [list $headertxt $headerlevel [string trim $topictitle] ""]
 
1184
     }
 
1185
    }
 
1186
    set str $headerstr 
 
1187
    set headerstr ""
 
1188
   }
 
1189
  } else {
 
1190
   continue
 
1191
  }
 
1192
#/sch
 
1193
 
 
1194
#sch new control directives .h2ignore* .h4topics* .h4contents* added in switch
 
1195
#/sch
 
1196
  switch -glob -- $str {
 
1197
   .h_ignore*   {set h2ignore [string trim [string range $str 9 end] "\t\" "]}
 
1198
   .h_topics*   {set h4topics [string trim [string range $str 9 end] "\t\" "]}
 
1199
   .h_contents* {set h4contents [string trim [string range $str 11 end] "\t\" "]}
 
1200
   .h_appendlist* {set h_appendlist [regexp -- "(yes)|(1)|(true)" [string tolower [string trim [string range $str 11 end] "\t\" "]]]}
 
1201
   .fontsize*   {catch {set fontsize [expr [string trim [string range $str 9 end] "\t\" "]]}}
 
1202
   .fontfixed*  {set fontfixed [string trim [string range $str 10 end] "\t\" "]}
 
1203
   .font*       {set font [string trim [string range $str 5 end] "\t\" "]}
 
1204
   .forecolor*  {set forecolor [correctcolor [string tolower [string trim [string range $str 10 end] "\t\" "]]]}
 
1205
   .backcolor*  {set backcolor [correctcolor [string tolower [string trim [string range $str 10 end] "\t\" "]]]}
 
1206
   .linkcolor*  {set linkcolor [correctcolor [string tolower [string trim [string range $str 10 end] "\t\" "]]]}
 
1207
   .alinkcolor* {set alinkcolor [correctcolor [string tolower [string trim [string range $str 11 end] "\t\" "]]]}
 
1208
   .lmargin*    {catch {set lmargin [expr [string trim [string range $str 8 end] "\t\" "]]}}
 
1209
   .rmargin*    {catch {set rmargin [expr [string trim [string range $str 8 end] "\t\" "]]}}
 
1210
   .topic*      {set curtopic [string trim [string range $str 6 end] "\t\" "]
 
1211
                 if {$curtopic!=""} {
 
1212
                  lappend index $curtopic
 
1213
                  set data($curtopic,title) "$curtopic"
 
1214
                  set data($curtopic,text) ""
 
1215
                 }
 
1216
                }
 
1217
   .title*      {if {$curtopic!=""} {
 
1218
                  set data($curtopic,title) [string trim [string range $str 6 end] "\t\" "]
 
1219
                 }
 
1220
                }
 
1221
   .image*      {set str [split $str]
 
1222
                 set imname ""
 
1223
                 set imtype ""
 
1224
                 set imdata ""
 
1225
                 set i 1
 
1226
                 for {} {$i<[llength $str]} {incr i} {
 
1227
                  if {[lindex $str $i]!=""} {
 
1228
                   set imname [string trim [lindex $str $i]]
 
1229
                   incr i
 
1230
                   break
 
1231
                  }
 
1232
                 }
 
1233
                 for {} {$i<[llength $str]} {incr i} {
 
1234
                  if {[lindex $str $i]!=""} {
 
1235
                   set imtype [string trim [lindex $str $i]]
 
1236
                   incr i
 
1237
                   break
 
1238
                  }
 
1239
                 }
 
1240
                 set imdata [string trim [join [lrange $str $i end]]]
 
1241
                 switch -- $imtype {
 
1242
                  file {catch {set data($imname,image) [image create photo -file [file join [file dirname $filename] $imdata]]}}
 
1243
                  data {catch {set data($imname,image) [image create photo -data $imdata]}}
 
1244
                 }
 
1245
                }
 
1246
   .include*    {variable inclstr
 
1247
                 set inclstr [string trim [join [lrange [split $str] 1 end]] "\t\" "]
 
1248
                 catch "namespace eval :: {set [namespace current]::inclstr \"$inclstr\"}"
 
1249
                 _load [file join [file dirname $filename] $inclstr]
 
1250
                }
 
1251
   .$*          {set str [split $str]
 
1252
                 set substname ""
 
1253
                 set substbegin ""
 
1254
                 set substend ""
 
1255
                 set i 1
 
1256
                 for {} {$i<[llength $str]} {incr i} {
 
1257
                  if {[lindex $str $i]!=""} {
 
1258
                   set substname [string tolower [string trim [lindex $str $i]]]
 
1259
                   incr i
 
1260
                   break
 
1261
                  }
 
1262
                 }
 
1263
                 set subst [string trim [join [lrange $str $i end]]]
 
1264
                 catch {set substbegin [lindex $subst 0]}
 
1265
                 catch {set substend   [lindex $subst 1]}
 
1266
                 if {$substname!="" && ($substbegin!="" || $substend!="")} {
 
1267
                  set data(subst,$substname,begin) $substbegin
 
1268
                  set data(subst,$substname,end)   $substend
 
1269
                 }
 
1270
                }
 
1271
    .controls*  {
 
1272
                 set controls [string tolower [string trim [string range $str 9 end] "\t\" "]]
 
1273
                } 
 
1274
    .buttons*   {
 
1275
                 set buttons [string tolower [string trim [string range $str 8 end] "\t\" "]]
 
1276
                } 
 
1277
    default     {if {$curtopic!=""} {
 
1278
                  if {[string index $str 0]!={;}} {
 
1279
                   append data($curtopic,text) "$str\n"
 
1280
                  }
 
1281
                 } else {
 
1282
                  append data(text) "$str\n"
 
1283
                 }
 
1284
                }
 
1285
  }
 
1286
 }
 
1287
 return 1
 
1288
}
 
1289
 
 
1290
 
 
1291
#-------------------------------------------------------------------------------
 
1292
# Function       :  help::load
 
1293
# Description    :  Load helpfile and make index
 
1294
# Parameters     :  filename    - name of file with help
 
1295
# Return         :  True or false
 
1296
#-------------------------------------------------------------------------------
 
1297
proc help::load {filename} {
 
1298
 variable w
 
1299
 variable stat
 
1300
 variable data
 
1301
 variable curfilename
 
1302
 
 
1303
 if {$filename==$curfilename} {
 
1304
  return 1
 
1305
 }
 
1306
 
 
1307
 variable settings
 
1308
 variable history 
 
1309
 variable index 
 
1310
 variable hpos
 
1311
 
 
1312
 if {$index!=""} {
 
1313
  set index ""
 
1314
  set history ""
 
1315
  set hpos 0
 
1316
 }
 
1317
 
 
1318
 variable font "Helvetica"
 
1319
 variable fontfixed "Courier"
 
1320
 variable fontsize 12
 
1321
 variable backcolor ""
 
1322
 variable forecolor black
 
1323
 variable linkcolor "#006800"
 
1324
 variable alinkcolor "#c00000"
 
1325
 variable lmargin 6
 
1326
 variable rmargin 6
 
1327
 variable curtopic ""
 
1328
 variable attr
 
1329
#sch declare vars
 
1330
 variable up1level 
 
1331
 variable sequence ""
 
1332
 variable hcontents ""
 
1333
 variable h2ignore ""
 
1334
 variable h4topics ""
 
1335
 variable h4contents ""
 
1336
#/sch
 
1337
 variable h_appendlist 1
 
1338
 # CHANGED BY JAIME URZUA
 
1339
 #variable controls "back forw cont index search prev up next"
 
1340
 variable controls ""
 
1341
 # CHANGED BY JAIME URZUA
 
1342
 #variable buttons "back forw prev up next sep stop sep cont ind"
 
1343
 variable buttons "back forw prev up next sep stop sep"
 
1344
 array set settings "back {$backcolor} fore {$forecolor} link {$linkcolor} alink {$alinkcolor}"
 
1345
 
 
1346
 foreach imn [array names data *,image] {
 
1347
  catch {image delete $data($imn)}
 
1348
 }
 
1349
 catch {unset data}
 
1350
 foreach btn "back cont dec find forward inc index next open prev refresh reload search stop up" {
 
1351
  catch {grid forget $w.b$btn}
 
1352
 }
 
1353
 for {set i 0} {$i<50} {incr i} {grid columnconfig $w $i -minsize 0}
 
1354
 if {![_load $filename]} {
 
1355
  set curfilename ""
 
1356
  set stat "Error while loading $filename!"
 
1357
  buttons
 
1358
  return 0
 
1359
 }
 
1360
 buttons
 
1361
 set stat "Done."
 
1362
 update
 
1363
 
 
1364
#sch create Topic Contents from hcontents and up1level for __up1level
 
1365
 if {$hcontents!=""} {
 
1366
  set data(contents,title) "Contents"
 
1367
  set data(contents,text) "<ul>"
 
1368
  set links(contents) ""
 
1369
  # set topicname_prev ""
 
1370
  set level(0) [list Contents 0 Contents contents]
 
1371
  for {set i 1} {$i<=6} {incr i} {  
 
1372
   set level($i) ""
 
1373
  }
 
1374
  foreach str $hcontents {
 
1375
   #set headertxt [lindex $str 0]
 
1376
   set headerlevel  [lindex $str 1]
 
1377
   set topictitle  [lindex $str 2]
 
1378
   set topicname  [lindex $str 3]
 
1379
   set prefix [string repeat "&nbsp;&nbsp;&nbsp;&nbsp;" [expr $headerlevel - 1]]
 
1380
   set level($headerlevel) $str
 
1381
   for {set i [expr $headerlevel + 1]} {$i<=6} {incr i} {   
 
1382
    set level($i) ""
 
1383
   }
 
1384
   set links($topicname) ""
 
1385
   if {$topicname!=""} {
 
1386
    append data(contents,text) "$prefix<a href=\"$topicname\">$topictitle</a><br>"
 
1387
   } else {
 
1388
    append data(contents,text) "$prefix$topictitle<br>"
 
1389
   }
 
1390
   for {set i [expr $headerlevel - 1]} {$i>0&&$level($i)==""} {incr i -1} { 
 
1391
   }
 
1392
   set str_i $level($i)
 
1393
   if {$str_i!=""} {
 
1394
    #set headertxt_i [lindex $str_i 0]
 
1395
    set headerlevel_i  [lindex $str_i 1]
 
1396
    set topictitle_i  [lindex $str_i 2]
 
1397
    set topicname_i [lindex $str_i 3]
 
1398
    if {$topicname_i != ""} {
 
1399
     set up1level($topicname) $topicname_i
 
1400
     if {$topicname!=""} {
 
1401
      append links($topicname_i) "<a href=\"$topicname\">$topictitle</a><br>"
 
1402
     }
 
1403
    }
 
1404
   }
 
1405
  }
 
1406
  append data(contents,text) "</ul>"
 
1407
  lappend index contents
 
1408
  if {$h_appendlist} {
 
1409
   set links(contents) ""
 
1410
   foreach topicname_i [array names links] {
 
1411
    if {$links($topicname_i)!=""} {
 
1412
     append data($topicname_i,text) "<ul>" $links($topicname_i) "</ul>"
 
1413
    }
 
1414
   }
 
1415
  }
 
1416
 }
 
1417
#/sch
 
1418
 
 
1419
#sch_05 create sequence for __Next, __up1level and __Prev
 
1420
 if {[lsearch $index contents]>=0} {
 
1421
  lappend sequence contents
 
1422
 }
 
1423
 foreach topicname $index {
 
1424
  if {$topicname!="contents"} {
 
1425
   lappend sequence $topicname
 
1426
  }
 
1427
 }
 
1428
 lappend sequence __index
 
1429
#/sch
 
1430
 
 
1431
 set data(title) ""
 
1432
 if {$index!=""} {
 
1433
  set iind ""
 
1434
  foreach i $index {
 
1435
   lappend iind [list $i $data($i,title)]
 
1436
  }
 
1437
  set iind [lsort -index 1 -dictionary $iind]
 
1438
  set data(__index,title) "Index"
 
1439
  set data(__index,text) "<br><ul>"
 
1440
  foreach i $iind {
 
1441
   set outtext [lindex $i 1]
 
1442
   append data(__index,text) "<li><a href=\"[lindex $i 0]\">[string map {{&} {&amp;} {>} {&gt;} {<} {&lt;}} $outtext]</a> <br>"
 
1443
  }
 
1444
  append data(__index,text) "</ul>"
 
1445
  lappend index __index
 
1446
 }
 
1447
 catch {$w.text configure -font "-family $font -size $fontsize"}
 
1448
 catch {$w.text configure -foreground $forecolor}
 
1449
 catch {$w.text configure -background $backcolor}
 
1450
 catch {$w.title configure -background [$w.text cget -background]}
 
1451
 set curfilename $filename
 
1452
 array set settings "back {$backcolor} fore {$forecolor} link {$linkcolor} alink {$alinkcolor}"
 
1453
 return 1
 
1454
}
 
1455
 
 
1456
#-------------------------------------------------------------------------------
 
1457
# Function       :  help::init
 
1458
# Description    :  Create window, load file and show topic
 
1459
# Parameters     :  filename    - name of file with help
 
1460
#                :  topic       - topic name
 
1461
#                :  parent      - parent widget
 
1462
#                :  width       - initial width of help window
 
1463
#                :  height      - initial height of help window
 
1464
# Return         :  Nothing
 
1465
#-------------------------------------------------------------------------------
 
1466
#sch new parameters  {width 450} {height 400}
 
1467
proc help::init {filename {topic contents} {parent {}} {width 450} {height 400} } {
 
1468
#/sch
 
1469
 variable w
 
1470
 variable gw
 
1471
 variable settings
 
1472
 variable font
 
1473
 variable fontsize
 
1474
 variable history
 
1475
 variable _images
 
1476
 variable _dnum
 
1477
 variable btninfo
 
1478
 global   tcl_platform
 
1479
 
 
1480
 if {![info exists w] || ![winfo exists $w]} {
 
1481
  set w $parent
 
1482
  if {$parent==""} {
 
1483
   set w ".tophelpwindow"
 
1484
#sch 
 
1485
   if {$width<450} {set width 450}
 
1486
   if {$height<400} {set height 400}
 
1487
   toplevel $w -width $width -height $height
 
1488
#/sch
 
1489
   wm title .tophelpwindow "Help"
 
1490
   wm minsize .tophelpwindow 170 120
 
1491
   raise .tophelpwindow
 
1492
   focus -force .tophelpwindow
 
1493
  }
 
1494
 
 
1495
  if {[wm protocol [winfo toplevel $w] WM_DELETE_WINDOW]==""} {
 
1496
   wm protocol [winfo toplevel $w] WM_DELETE_WINDOW "help::destroy 1"
 
1497
  }
 
1498
 
 
1499
  if {$w!="."} {append w "."}
 
1500
#sch
 
1501
  frame ${w}f -width $width -height $height -bd 2 -relief sunken
 
1502
#/sch1
 
1503
  pack ${w}f -fill both -expand 1
 
1504
  append w "f"
 
1505
  set gw $w
 
1506
 
 
1507
  canvas $w.title -bd 0 -highlightthickness 0 -cursor arrow -height 0
 
1508
  # CHANGED BY JAIME URZUA
 
1509
  # ---------------->    <----
 
1510
  text $w.text -wrap word -cursor arrow -state disabled -bd 0 \
 
1511
               -insertwidth 0 -insertontime 0 -exportselection 1\
 
1512
               -highlightthickness 0 -takefocus 1 -insertborderwidth 0 \
 
1513
               -yscrollcommand "$w.vs set" -xscrollcommand "$w.hs set"
 
1514
  foreach elem {text title} {
 
1515
   catch {$w.$elem configure -font "-family $font"}
 
1516
   catch {$w.$elem configure -font "-size $fontsize"}
 
1517
   catch {$w.$elem configure -foreground $settings(fore)}
 
1518
   catch {$w.$elem configure -background $settings(back)}
 
1519
  }
 
1520
  scrollbar $w.vs -command "$w.text yview"
 
1521
  scrollbar $w.hs -command "$w.text xview" -orient horizontal
 
1522
 
 
1523
  button $w.bback    -image $_images(back)    -width 15 -height 13 -command "help::show __prev" -state disabled
 
1524
  button $w.bforward -image $_images(forward) -width 15 -height 13 -command "help::show __next" -state disabled
 
1525
  button $w.bstop    -image $_images(stop)    -width 15 -height 13 -command "set help::abort 1" -state disabled
 
1526
  button $w.brefresh -image $_images(refresh) -width 15 -height 13 -command "event generate $w.text <Control-r>"
 
1527
 
 
1528
  button $w.bdec     -image $_images(dec)    -width 15 -height 13 -command "event generate $w.text <Control-bracketleft>"
 
1529
  button $w.binc     -image $_images(inc)    -width 15 -height 13 -command "event generate $w.text <Control-bracketright>"
 
1530
  button $w.bcont    -image $_images(cont)   -width 15 -height 13 -command "help::show contents"
 
1531
  button $w.bindex   -image $_images(index)  -width 15 -height 13 -command "help::show __index"
 
1532
  button $w.bfind    -image $_images(find)   -width 15 -height 13 -command "help::dlgfind:init"
 
1533
  button $w.bsearch  -image $_images(search) -width 15 -height 13 -command "help::dlgfind:init 0"
 
1534
  button $w.breload  -image $_images(reload) -width 15 -height 13 -command "event generate $w.text <Control-l>"
 
1535
  button $w.bopen    -image $_images(open)   -width 15 -height 13 -command "event generate $w.text <Control-o>"
 
1536
  button $w.bprev    -image $_images(prev)   -width 15 -height 13 -command "help::show __Prev"
 
1537
  button $w.bup      -image $_images(up)     -width 15 -height 13 -command "help::show __up1level"
 
1538
  button $w.bnext    -image $_images(next)   -width 15 -height 13 -command "help::show __Next"
 
1539
 
 
1540
  foreach {name} {__index contents __next __prev __Next __Prev __up1level
 
1541
                 __dec __find __inc __open __refresh __reload __stop __search} {
 
1542
   foreach {txt vis expr btn} $btninfo($name) {
 
1543
    bind $w.$btn <Enter> "set help::stat \{$txt\}"
 
1544
    bind $w.$btn <Leave> "set help::stat \{Done.\}"
 
1545
   }
 
1546
  }
 
1547
  
 
1548
  label $w.stat -relief sunken -bd 1 -textvariable help::stat -justify left -anchor w
 
1549
  label $w.d -image $_images(d[set _dnum]) -bd 0 -anchor se
 
1550
  label $w.ugol -image $_images(ugol) -bd 0 -anchor se
 
1551
 
 
1552
  grid rowconfig    $w 0 -weight 1    -minsize 0
 
1553
  grid rowconfig    $w 1 -weight 1000 -minsize 50
 
1554
#  grid rowconfig    $w 3 -minsize 20
 
1555
  grid columnconfig $w 50 -weight 1000 -minsize 50
 
1556
 
 
1557
  grid $w.title -padx 0 -pady 0 \
 
1558
               -row 0 -column 0 -rowspan 1 -columnspan 52 -sticky new
 
1559
  grid $w.text -padx 0 -pady 0 \
 
1560
               -row 1 -column 0 -rowspan 1 -columnspan 51 -sticky news
 
1561
  grid $w.vs   -padx 1 -pady 0 \
 
1562
               -row 1 -column 51 -rowspan 1 -columnspan 1 -sticky news
 
1563
  grid $w.hs   -padx 0 -pady 1 \
 
1564
               -row 2 -column 0 -rowspan 1 -columnspan 51 -sticky news
 
1565
  grid $w.d    -padx 0 -pady 0 \
 
1566
               -row 2 -column 51 -rowspan 1 -columnspan 1 -sticky news
 
1567
  grid $w.stat -padx 0 -pady 0 \
 
1568
               -row 3 -column 50 -rowspan 1 -columnspan 1 -sticky nwes
 
1569
  grid $w.ugol -padx 0 -pady 0 \
 
1570
               -row 3 -column 51 -rowspan 1 -columnspan 1 -sticky es
 
1571
 
 
1572
  grid propagate $w 0
 
1573
 
 
1574
  focus $w.text
 
1575
  $w.text tag configure h -font "-size 1" -spacing3 0
 
1576
 
 
1577
  bind $w.text <Key> "break"
 
1578
  bind $w.text <KeyPress> "break"
 
1579
  bind $w.text <KeyRelease> "break"
 
1580
  bind $w.text <BackSpace> "help::show __prev;break"
 
1581
  bind $w.text <Alt-F5> "help::show __prev;break"
 
1582
  bind $w.text <Alt-Left> "help::show __prev;break"
 
1583
  bind $w.text <Alt-Right> "help::show __next;break"
 
1584
  bind $w.text <Double-1> "break"
 
1585
  bind $w.text <1> "focus $w.text; $w.text tag remove fnd 1.0 end"
 
1586
  bind $w.text <Escape> "set help::abort 1"
 
1587
  bind $w.text <Control-R> "event generate $w.text <Control-r>"
 
1588
  bind $w.text <Control-L> "event generate $w.text <Control-l>"
 
1589
  bind $w.text <Control-bracketleft>  "if {\$help::fontsize>6} {incr help::fontsize -2; event generate $w.text <Control-r>}"
 
1590
  bind $w.text <Control-bracketright> "if {\$help::fontsize<30} {incr help::fontsize 2; event generate $w.text <Control-r>}"
 
1591
  bind $w.text <Control-c> "event generate $w.text <<Copy>>"
 
1592
  bind $w.text <Control-C> "event generate $w.text <Control-c>"
 
1593
  bind $w.text <Control-Insert> "event generate $w.text <Control-c>"
 
1594
  bind $w.text <Control-o> "help::open"
 
1595
  bind $w.text <Control-O> "event generate $w.text <Control-o>"
 
1596
  bind $w.text <Right> "$w.text xview scroll +1 units; break"
 
1597
  bind $w.text <Left>  "$w.text xview scroll -1 units; break"
 
1598
  bind $w.text <Down>  "$w.text yview scroll +1 units; break"
 
1599
  bind $w.text <Up>    "$w.text yview scroll -1 units; break"
 
1600
  bind $w.text <Next>  "$w.text yview scroll +1 pages; break"
 
1601
  bind $w.text <Prior> "$w.text yview scroll -1 pages; break"
 
1602
  bind $w.text <Home>  "$w.text yview moveto 0; break"
 
1603
  bind $w.text <End>   "$w.text yview moveto 1; break"
 
1604
  bind $w.d    <Double-1> "help::show_about"
 
1605
  bind $w.text <Control-f> "help::dlgfind:init; break"
 
1606
  bind $w.text <Control-F> "event generate $w.text <Control-f>"
 
1607
  bind $w.text <Control-s> "help::dlgfind:init 0; break"
 
1608
  bind $w.text <Control-S> "event generate $w.text <Control-s>"
 
1609
  bind $w.text <Control-Shift-f> "event generate $w.text <Control-s>"
 
1610
  bind $w.text <Control-Shift-F> "event generate $w.text <Control-s>"
 
1611
  if {$parent==""} {
 
1612
   bind .tophelpwindow <FocusIn>  "help::focusin %W %m"
 
1613
   bind .tophelpwindow <FocusOut> "help::focusout %W %m"
 
1614
   bind .tophelpwindow <Configure> "help::focusin %W %m"
 
1615
   bind .tophelpwindow <Destroy> "help::focusout %W %m"
 
1616
   bind .tophelpwindow <Expose> "help::focusin %W %m"
 
1617
  }
 
1618
 
 
1619
  menu $w.menu  -tearoff 0
 
1620
  $w.menu add command -label "Back" -command "help::show __prev" -accelerator "<--"
 
1621
  $w.menu add command -label "Forward" -command "help::show __next"
 
1622
  $w.menu add command -label "Stop" -command "set help::abort 1" -accelerator "Esc"
 
1623
  $w.menu add sep
 
1624
  $w.menu add command -label "Copy" -command "event generate $w.text <Control-c>" -accelerator "Ctrl+Ins"
 
1625
  $w.menu add sep
 
1626
  $w.menu add command -label "Find..." -command "event generate $w.text <Control-f>" -accelerator "Ctrl+F"
 
1627
  $w.menu add command -label "Search in topics..." -command "event generate $w.text <Control-Shift-f>" -accelerator "Ctrl+S"
 
1628
  $w.menu add sep
 
1629
  $w.menu add command -label "Open file..." -command "event generate $w.text <Control-o>" -accelerator "Ctrl+O"
 
1630
  $w.menu add sep
 
1631
  $w.menu add command -label "Increase font size" -command "event generate $w.text <Control-bracketright>" -accelerator "Ctrl+\]"
 
1632
  $w.menu add command -label "Decrease font size" -command "event generate $w.text <Control-bracketleft>" -accelerator "Ctrl+\["
 
1633
  $w.menu add sep
 
1634
  $w.menu add command -label "Refresh" -command "event generate $w.text <Control-r>" -accelerator "Ctrl+R"
 
1635
  $w.menu add command -label "Reload" -command "event generate $w.text <Control-l>" -accelerator "Ctrl+L"
 
1636
  bind $w.text <3> "help::rightclick %X %Y"
 
1637
 
 
1638
  menu $w.menuX  -tearoff 0
 
1639
  $w.menuX add command -label "About" -command "help::show_about"
 
1640
  bind $w.d <3> "help::rightclickX %X %Y"
 
1641
  help::userinit $w
 
1642
 }
 
1643
 
 
1644
 if {[info exists w] && [winfo exists $w]} {
 
1645
  raise [winfo toplevel $w]
 
1646
  focus -force [winfo toplevel $w]
 
1647
  focus -force $w.text
 
1648
 }
 
1649
 
 
1650
 bind $w.text <Control-l> "set help::curtopic {}; set help::curfilename {}; help::init \{$filename\} \[lindex \[lindex \$help::history \$help::hpos\] 0\]"
 
1651
 
 
1652
 if {$filename==""} {
 
1653
  help::open
 
1654
  return
 
1655
 }
 
1656
 
 
1657
 if {[load $filename]} {
 
1658
  show $topic
 
1659
 } else {
 
1660
  show __file_error
 
1661
 }
 
1662
}
 
1663
 
 
1664
proc help::userinit {w} {
 
1665
}
 
1666
 
 
1667
#-------------------------------------------------------------------------------
 
1668
# Function       :  help::buttons
 
1669
# Description    :  Place buttons 
 
1670
# Parameters     :  None
 
1671
# Return         :  Tagname
 
1672
#-------------------------------------------------------------------------------
 
1673
proc help::buttons {} {
 
1674
 variable gw
 
1675
 variable buttons
 
1676
 variable h4contents
 
1677
 
 
1678
 set bcount -1
 
1679
 foreach btn $buttons {
 
1680
  switch -glob -- $btn {
 
1681
   b*   {set btn "back"}
 
1682
   c*   {set btn "cont"}
 
1683
   d*   {set btn "dec"}
 
1684
   fi*  {set btn "find"}
 
1685
   fo*  {set btn "forward"}
 
1686
   inc* {set btn "inc"}
 
1687
   ind* {set btn "index"}
 
1688
   n*   {if {$h4contents==""} {continue}; set btn "next"}
 
1689
   o*   {set btn "open"}
 
1690
   p*   {if {$h4contents==""} {continue}; set btn "prev"}
 
1691
   ref* {set btn "refresh"}
 
1692
   rel* {set btn "reload"}
 
1693
   sea* {set btn "search"}
 
1694
   sep* {grid columnconfig $gw [incr bcount] -minsize 5; continue}
 
1695
   st*  {set btn "stop"}
 
1696
   u*   {if {$h4contents==""} {continue}; set btn "up"}
 
1697
   default {continue}
 
1698
  }
 
1699
  grid $gw.b$btn  -padx 0 -pady 0 -row 3 -column [incr bcount] \
 
1700
                 -rowspan 1 -columnspan 1 -sticky news
 
1701
 }
 
1702
 updatehead
 
1703
}
 
1704
 
 
1705
#-------------------------------------------------------------------------------
 
1706
# Function       :  help::gettags
 
1707
# Description    :  Configure and get tag for current text with attr
 
1708
# Parameters     :  None
 
1709
# Return         :  Tagname
 
1710
#-------------------------------------------------------------------------------
 
1711
proc help::gettags {} {
 
1712
 variable _count
 
1713
 variable _tags
 
1714
 variable w
 
1715
 variable settings
 
1716
 variable font 
 
1717
 variable fontfixed
 
1718
 variable fontsize 
 
1719
 variable curtopic
 
1720
 variable data
 
1721
 variable attr
 
1722
 variable rmargin
 
1723
 variable index
 
1724
 variable interp
 
1725
 
 
1726
 if {[set justify [lindex $attr(justify) 0]]==""} {
 
1727
  set justify [lindex $attr(justify,global) 0]
 
1728
 }
 
1729
 
 
1730
 if {[info exists _tags($w,$attr(style),$attr(links),$attr(bgcolors),$attr(colors),$attr(sizes),$justify,$attr(margin))]} {
 
1731
  return $_tags($w,$attr(style),$attr(links),$attr(bgcolors),$attr(colors),$attr(sizes),$justify,$attr(margin))
 
1732
 }
 
1733
 
 
1734
 incr _count
 
1735
 set color ""
 
1736
 if {[lsearch $attr(style) "p"]==-1 && [lsearch $attr(style) "t"]==-1 && [lsearch $attr(style) "k"]==-1} {
 
1737
  if {$attr(face)!=""} {
 
1738
   append ffont "-family \{[lindex $attr(face) 0]\} "
 
1739
  } else {
 
1740
   append ffont "-family \{$font\} "
 
1741
  }
 
1742
 } else {
 
1743
  append ffont "-family \{$fontfixed\} "
 
1744
 }
 
1745
 if {[lsearch $attr(style) "b"]!=-1} {
 
1746
  append ffont "-weight bold "
 
1747
 }
 
1748
 if {[lsearch $attr(style) "i"]!=-1} {
 
1749
  append ffont "-slant italic "
 
1750
 }
 
1751
 if {[lsearch $attr(style) "u"]!=-1} {
 
1752
  append ffont "-underline 1 "
 
1753
 }
 
1754
 if {[lsearch $attr(style) "n"]==-1 && [lsearch $attr(style) "t"]==-1 && [lsearch $attr(style) "p"]==-1} {
 
1755
  $w.text tag configure tag$_count -wrap word
 
1756
 }
 
1757
 if {$attr(sizes)!=""} {
 
1758
  if {[set ind [string index [set size [lindex $attr(sizes) 0]] 0]]=="+" || $ind=="-"} {
 
1759
   catch {append ffont "-size [expr $fontsize $size]"}
 
1760
  } else {
 
1761
   catch {append ffont "-size [expr $size]"}
 
1762
  }
 
1763
 } else {
 
1764
  append ffont "-size $fontsize"
 
1765
 }
 
1766
 if {$attr(colors)!=""} {
 
1767
  set color "[lindex $attr(colors) 0]"
 
1768
 }
 
1769
 if {$attr(bgcolors)!=""} {
 
1770
  catch {$w.text tag configure tag$_count -background [lindex $attr(bgcolors) 0]}
 
1771
 }
 
1772
 catch {$w.text tag configure tag$_count -font $ffont}
 
1773
 catch {$w.text tag configure tag$_count -foreground $color}
 
1774
 catch {$w.text tag configure tag$_count -justify $justify}
 
1775
 catch {$w.text tag configure tag$_count -lmargin1 $attr(margin) -lmargin2 $attr(margin) -rmargin $rmargin}
 
1776
 if {[set lnk [lindex $attr(links) 0]]!=""} {
 
1777
  $w.text tag configure tag$_count -underline 1
 
1778
  catch {$w.text tag configure tag$_count -foreground $settings(link)}
 
1779
  $w.text tag bind tag$_count <Enter> "$w.text configure -cursor hand2; catch {$w.text tag configure tag$_count -foreground \$help::settings(alink)}"
 
1780
  if {![regexp "^tcl(script)?:(.*)" $lnk x lnk_type lnk]} {
 
1781
   $w.text tag bind tag$_count <1> "help::show \{$lnk\}"
 
1782
   if {[lindex $attr(link_titles) 0]!=""} {
 
1783
    $w.text tag bind tag$_count <Enter> "+ set help::stat \{[lindex $attr(link_titles) 0]\}"
 
1784
   } elseif {[info exists data([set ltopic [lindex [split $lnk "#"] 0]],title)]} {
 
1785
    $w.text tag bind tag$_count <Enter> "+ set help::stat \{$data($ltopic,title)\}"
 
1786
   } elseif {$ltopic=="" && [info exists data($curtopic,title)]} {
 
1787
    $w.text tag bind tag$_count <Enter> "+ set help::stat \{$data($curtopic,title)\}"
 
1788
   } elseif {$index==""} {
 
1789
    $w.text tag bind tag$_count <Enter> "+ set help::stat \{$lnk\}"
 
1790
   }
 
1791
  } else {
 
1792
   if {$lnk_type==""} {
 
1793
    $w.text tag bind tag$_count <1> "if {\[catch \{namespace eval :: \{$lnk\}\}\]} {set help::data(__@Error@__,title) Error; set help::data(__@Error@__,text) \"<font color=red><pre>\$::errorInfo</pre></font>\"; help::show __@Error@__}"
 
1794
   } else {
 
1795
    $w.text tag bind tag$_count <1> "if {\[catch \{$interp eval \{$lnk\}\}\]} {set help::data(__@Error@__,title) Error; set help::data(__@Error@__,text) \"<font color=red><pre>\$::errorInfo</pre></font>\"; help::show __@Error@__}"
 
1796
   }
 
1797
   if {[lindex $attr(link_titles) 0]!=""} {
 
1798
    $w.text tag bind tag$_count <Enter> "+ set help::stat \{[lindex $attr(link_titles) 0]\}"
 
1799
   }
 
1800
  }
 
1801
  $w.text tag bind tag$_count <Leave> "$w.text configure -cursor arrow; catch {$w.text tag configure tag$_count -foreground \$help::settings(link)}; set help::stat \{Done.\}"
 
1802
 }
 
1803
 set _tags($w,$attr(style),$attr(links),$attr(bgcolors),$attr(colors),$attr(sizes),$justify,$attr(margin)) tag$_count
 
1804
 return tag$_count
 
1805
}
 
1806
 
 
1807
#-------------------------------------------------------------------------------
 
1808
# Function       :  help::gethr
 
1809
# Description    :  Configure and get tag for horizontal line
 
1810
# Parameters     :  width       - line width
 
1811
# Return         :  Text with tags
 
1812
#-------------------------------------------------------------------------------
 
1813
proc help::gethr {height color} {
 
1814
 variable _count
 
1815
 variable w
 
1816
 variable settings
 
1817
 
 
1818
 if {$color==""} {set color $settings(fore)}
 
1819
 if {$height==""} {set height 1}
 
1820
 incr _count
 
1821
 $w.text tag configure tagh$_count -font "-size 1"
 
1822
 catch {$w.text tag configure tagh$_count -background $settings(fore)}
 
1823
 catch {$w.text tag configure tagh$_count -background $color}
 
1824
 catch {$w.text tag configure tagh$_count -font "-size $height" -spacing3 0}
 
1825
 return "\"\n\" h \"\n\" tagh$_count \"\n\" h"
 
1826
}
 
1827
 
 
1828
#-------------------------------------------------------------------------------
 
1829
# Function       :  help::show
 
1830
# Description    :  Show topic
 
1831
# Parameters     :  topic       - topic name
 
1832
#                :  modhist     - modify or not history
 
1833
# Return         :  Nothing
 
1834
#-------------------------------------------------------------------------------
 
1835
proc help::show {{topic contents} {modhist 1} {textpos {}}} {
 
1836
 variable w
 
1837
 variable gw
 
1838
 variable attr
 
1839
 variable abort 
 
1840
 variable showing 
 
1841
 variable stat
 
1842
 variable data
 
1843
 variable index
 
1844
 variable linkcolor
 
1845
 variable alinkcolor
 
1846
 variable history
 
1847
 variable hpos
 
1848
 variable backcolor
 
1849
 variable forecolor
 
1850
 variable settings
 
1851
 variable lmargin
 
1852
 variable font
 
1853
 variable fontsize
 
1854
 variable curtopic
 
1855
 variable curfilename
 
1856
 variable _count
 
1857
 variable _tags
 
1858
# variable _images
 
1859
 variable _text
 
1860
 variable perc
 
1861
 variable _istitle 0
 
1862
 variable _isscript 0
 
1863
 variable _istext 1
 
1864
 variable _t_title
 
1865
#sch vars for __Prev, __up1level, __Next 
 
1866
 variable sequence 
 
1867
 variable up1level 
 
1868
 variable h4topics
 
1869
 variable h4contents
 
1870
#/sch
 
1871
 variable _need_tag ""
 
1872
 variable controls
 
1873
 variable insearch
 
1874
 variable btninfo
 
1875
 variable interp
 
1876
 variable tables
 
1877
 
 
1878
 switch -exact -- $topic {
 
1879
  __dec     {event generate $w.text <Control-bracketleft>; return}
 
1880
  __find    {dlgfind:init; return}
 
1881
  __inc     {event generate $w.text <Control-bracketright>; return}
 
1882
  __open    {event generate $w.text <Control-o>; return}
 
1883
  __refresh {event generate $w.text <Control-r>; return}
 
1884
  __reload  {event generate $w.text <Control-l>; return}
 
1885
  __stop    {set abort 1; return}
 
1886
  __search  {dlgfind:init 0; return}
 
1887
 }
 
1888
 
 
1889
 set mark ""
 
1890
 if {[set pos [string first "#" $topic]]!=-1} {
 
1891
  set mark  [string tolower [string range $topic [expr $pos + 1] end]]
 
1892
  set topic [string range $topic 0 [expr $pos - 1]]
 
1893
 }
 
1894
 
 
1895
 if {$topic==""} {
 
1896
  set topic $curtopic
 
1897
  if {$topic==""} {
 
1898
   set topic "contents"
 
1899
  }
 
1900
 }
 
1901
 
 
1902
 if {$curtopic==$topic || ($index=="" && $curtopic==[file join [file dirname $curfilename] $topic])} {
 
1903
  if {$mark!=""} {
 
1904
   if {$modhist} {
 
1905
    if {[llength $history] && $hpos==[expr [llength $history]-1]} {
 
1906
     set history [lreplace $history $hpos $hpos [lreplace [lindex $history $hpos] 1 1 [$w.text index @0,0]]]
 
1907
    }
 
1908
    catch {set history [lrange $history 0 $hpos]}
 
1909
    if {[lindex [lindex $history end] 0]!="$curtopic#$mark"} {
 
1910
     lappend history [list "$curtopic#$mark" 0]
 
1911
    }
 
1912
    set hpos [expr [llength $history] - 1]
 
1913
   }
 
1914
   showmark "mark_$mark"
 
1915
  } else {
 
1916
   if {$textpos!=""} {
 
1917
    showpos $textpos
 
1918
   }
 
1919
  }
 
1920
  return
 
1921
 }
 
1922
 
 
1923
 if {$showing} {
 
1924
  set abort 1
 
1925
  catch {after cancel "help::show $topic $modhist"}
 
1926
  after 200 "help::show $topic $modhist"
 
1927
  return
 
1928
 }
 
1929
 set abort 0
 
1930
 set showing 1
 
1931
 bind $w.text <Control-r> ""
 
1932
 
 
1933
#sch find topic for __up1level, __Prev and __Next
 
1934
 if {$topic=="__up1level"} {
 
1935
  set topic $up1level($curtopic)
 
1936
 }
 
1937
 if {$topic=="__Prev" || $topic=="__Next"} {
 
1938
  set i [lsearch $sequence $curtopic]
 
1939
  if {$topic=="__Prev"} {
 
1940
   incr i -1
 
1941
  } else {
 
1942
   incr i +1
 
1943
  }
 
1944
  set topic [lindex $sequence $i]
 
1945
 }
 
1946
#/sch
 
1947
 
 
1948
 if {$topic=="__prev" || $topic=="__next"} {
 
1949
  set showing 0
 
1950
  if {[llength $history]} {
 
1951
   set history [lreplace $history $hpos $hpos [lreplace [lindex $history $hpos] 1 1 [$w.text index @0,0]]]
 
1952
  }
 
1953
  [string range $topic 2 end]
 
1954
  return
 
1955
 }
 
1956
 
 
1957
 if {$modhist && [llength $history] && $hpos==[expr [llength $history]-1]} {
 
1958
  set history [lreplace $history $hpos $hpos [lreplace [lindex $history $hpos] 1 1 [$w.text index @0,0]]]
 
1959
 }
 
1960
 
 
1961
 set curtopic $topic
 
1962
 
 
1963
 if {$topic!="" && $index!=""} {
 
1964
  if {[lsearch $index $topic]==-1} {
 
1965
   if {$topic=="contents"} {
 
1966
    set showing 0
 
1967
    show __index
 
1968
    return
 
1969
   } else {
 
1970
    if {[string match "__@*@__" $topic]} {
 
1971
     if {[catch {set _text $data($topic,text); set title $data($topic,title)}]} {
 
1972
      set showing 0
 
1973
      show contents
 
1974
      return
 
1975
     }
 
1976
    } else {
 
1977
     set _text "<font color=#c00000>Topic</font> <b>\"$topic\"</b> <font color=#c00000>not found in</font> <b>\"[file join [pwd] $curfilename]\"</b><font color=#c00000>!</font>"
 
1978
     set title "Topic not found!"
 
1979
    }
 
1980
   }
 
1981
  } else {
 
1982
   set _text  $data($topic,text)
 
1983
   set title $data($topic,title)
 
1984
   if {$index=="__file_error"} {
 
1985
    set index ""
 
1986
   }
 
1987
  }
 
1988
 } else {
 
1989
   if {[string match "__@*@__" $topic]} {
 
1990
    if {[catch {set _text $data($topic,text); set title $data($topic,title)}]} {
 
1991
     set showing 0
 
1992
     show contents
 
1993
     return
 
1994
    }
 
1995
   } else {
 
1996
    if {$topic=="contents"} {
 
1997
     set topic $curfilename
 
1998
    }
 
1999
    set topic [file join [file dirname $curfilename] $topic]
 
2000
    # make it an absolute path
 
2001
    if {[file exists [file dirname $topic]]} {
 
2002
     set oldpath [pwd]
 
2003
     cd  [file dirname $topic]
 
2004
     set absdir [pwd]
 
2005
     cd  $oldpath
 
2006
     unset oldpath
 
2007
     set topic [file join $absdir [file tail $topic]]
 
2008
    }
 
2009
    if {![load $topic]} {
 
2010
     set showing 0
 
2011
     catch {set history [lrange $history 0 $hpos]}
 
2012
     if {[lindex [lindex $history end] 0]!="$topic#$mark"} {
 
2013
      lappend history [list "$topic#$mark" 0]
 
2014
     }
 
2015
     set hpos [expr [llength $history] - 1]
 
2016
     show __file_error 0
 
2017
     return
 
2018
    }
 
2019
    set _text  $data(text)
 
2020
    regsub -all -- "\[\r\n \]+" $data(title) " " data(title)
 
2021
    set title $data(title)
 
2022
    set curtopic $topic
 
2023
#    set curtopic $curfilename
 
2024
#    set topic $curfilename
 
2025
   }
 
2026
 }
 
2027
 
 
2028
 if {$modhist} {
 
2029
  catch {set history [lrange $history 0 $hpos]}
 
2030
  if {[lindex [lindex $history end] 0]!="$topic#$mark"} {
 
2031
   lappend history [list "$topic#$mark" 0]
 
2032
  }
 
2033
  set hpos [expr [llength $history] - 1]
 
2034
 }
 
2035
 
 
2036
#sch get position for __Prev and __Next 
 
2037
 set spos [lsearch $sequence $curtopic]
 
2038
#/sch
 
2039
 catch {unset _tags}
 
2040
 catch {unset tables}
 
2041
 array set tables "level 0 stack {} count 0 tables {}"
 
2042
 catch {interp delete $interp}
 
2043
 catch {set interp [interp create]}
 
2044
 catch {$interp alias g_eval ::eval}
 
2045
 catch {$interp alias img_change ::help::img_change}
 
2046
 catch {$interp alias id_change  ::help::id_change }
 
2047
 catch {$interp alias id_visible ::help::id_visible}
 
2048
 catch {$interp eval [list set script_dir [file dirname $curfilename]]}
 
2049
 
 
2050
 
 
2051
 bind $w.text <Control-r> "set help::curtopic {}; help::show $topic"
 
2052
 
 
2053
 set stat "Creating title..."
 
2054
 update
 
2055
 if {$title==""} {set title "Untitled"}
 
2056
 $w.title delete all
 
2057
 array set settings "back {$backcolor} fore {$forecolor} link {$linkcolor} alink {$alinkcolor}"
 
2058
 catch {$w.title configure -foreground $settings(fore)}
 
2059
 catch {$w.title configure -background $settings(back)}
 
2060
 catch {$w.text configure -foreground $settings(fore)}
 
2061
 catch {$w.text configure -background $settings(back)}
 
2062
 set _t_title(title) [$w.title create text 4 4 -anchor nw -fill $settings(fore) -text $title \
 
2063
                     -font "-family $font -size [expr $fontsize + 12] -weight bold"]
 
2064
 
 
2065
 set inc [font metrics "-family $font -size [expr $fontsize + 12] -weight bold" -displayof $w -ascent]
 
2066
 set spc [font measure "-family $font -size [expr $fontsize - 2]" -displayof $w.title "    "]
 
2067
 
 
2068
 set x 4
 
2069
 foreach control $controls {
 
2070
  switch -glob -- $control {
 
2071
   b*   {set link "__prev"}
 
2072
   c*   {set link "contents"}
 
2073
   d*   {set link "__dec"}
 
2074
   fi*  {set link "__find"}
 
2075
   fo*  {set link "__next"}
 
2076
   inc* {set link "__inc"}
 
2077
   ind* {set link "__index"}
 
2078
   n*   {set link "__Next"}
 
2079
   o*   {set link "__open"}
 
2080
   p*   {set link "__Prev"}
 
2081
   ref* {set link "__refresh"}
 
2082
   rel* {set link "__reload"}
 
2083
   sea* {set link "__search"}
 
2084
   sep* {incr x $spc; continue}
 
2085
   st*  {set link "__stop"}
 
2086
   u*   {set link "__up1level"}
 
2087
   default {continue}
 
2088
  }
 
2089
  foreach {txt vis expr btn} $btninfo($link) {
 
2090
   if {[expr $vis]} {
 
2091
    if {[expr $expr]} {
 
2092
     set _t_title($link) [$w.title create text $x [expr $fontsize + $inc] -anchor nw -fill $settings(fore) \
 
2093
                         -text $txt -font "-family $font -size [expr $fontsize - 2] -underline 1"]
 
2094
     catch {$w.title itemconfigure $_t_title($link) -fill $settings(link)}
 
2095
     $w.title bind $_t_title($link) <1> "help::show \{$link\}"
 
2096
     $w.title bind $_t_title($link) <Enter> "$w.title configure -cursor hand2; catch {$w.title itemconfigure $_t_title($link) -fill \$help::settings(alink)}; set help::stat \{$txt\}"
 
2097
     $w.title bind $_t_title($link) <Leave> "$w.title configure -cursor arrow; catch {$w.title itemconfigure $_t_title($link) -fill \$help::settings(link)}; set help::stat \{Done.\}"
 
2098
    } else {
 
2099
     set _t_title($link) [$w.title create text $x [expr $fontsize + $inc] -anchor nw -fill $settings(fore) \
 
2100
                         -text $txt -font "-family $font -size [expr $fontsize - 2]"]
 
2101
    }
 
2102
    set x [expr [lindex [$w.title bbox $_t_title($link)] 2] + $spc]
 
2103
   }
 
2104
  }
 
2105
 }
 
2106
#/sch
 
2107
 updatehead "__prev __next __stop __Prev __Next __up1level contents __index __search"
 
2108
 
 
2109
 if {$controls!=""} {
 
2110
  incr inc [expr 4 + [font metrics "-family $font -size [expr $fontsize - 2]" -displayof $w -linespace]]
 
2111
 }
 
2112
 incr inc [font metrics "-family $font -size [expr $fontsize - 2]" -displayof $w -ascent]
 
2113
 set _t_title(line) [$w.title create line 0 $inc 5000 $inc -width 2 -fill $settings(fore)]
 
2114
 
 
2115
 foreach {x1 y1 x2 y2} [$w.title bbox all] {break}
 
2116
 $w.title configure -scrollregion "$x1 $y1 $x2 $y2" -height [expr $y2 - $y1]
 
2117
 $w.title xview moveto 0 ; $w.title yview moveto 0
 
2118
 
 
2119
 if {[string match {.tophelpwindow*} $w]} {
 
2120
  wm title .tophelpwindow "Help - $title"
 
2121
 }
 
2122
 
 
2123
 set stat "Displaying..."
 
2124
 set perc 0
 
2125
 catch {after cancel "help::updatestate"}
 
2126
 after 250 "help::updatestate"
 
2127
 catch {after cancel "help::update_d"}
 
2128
 after 100 "help::update_d"
 
2129
 update
 
2130
 $w.text configure -state normal
 
2131
 $w.text delete 1.0 end
 
2132
 eval "$w.text mark unset [$w.text mark names]"
 
2133
 if {$textpos!=""} {
 
2134
  showpos $textpos
 
2135
 }
 
2136
 set attr(span) ""
 
2137
 set attr(style) ""
 
2138
 set attr(ul_type) ""
 
2139
 set attr(indent) ""
 
2140
 set attr(tag_fonts) ""
 
2141
 set attr(face) ""
 
2142
 set attr(links) ""
 
2143
 set attr(link_titles) ""
 
2144
 set attr(colors) ""
 
2145
 set attr(bgcolors) ""
 
2146
 set attr(tables) ""
 
2147
 set attr(sizes) ""
 
2148
 set attr(justify) ""
 
2149
 set attr(justify,global) ""
 
2150
 set attr(margin) $lmargin
 
2151
 set _count 0
 
2152
 set data(title) ""
 
2153
 set deltags [lrange [$w.text tag names] 2 end]
 
2154
 catch {eval "$w.text tag delete $deltags"}
 
2155
 catch {$w.text tag configure fnd -foreground [$w.text tag cget sel -foreground] \
 
2156
                                  -background [$w.text tag cget sel -background]}
 
2157
 if {$h4topics=="" && $h4contents==""} {
 
2158
  regsub -all -- {<!--.*?-->} $_text "" _all_text
 
2159
 } else {
 
2160
  set _all_text $_text
 
2161
 }
 
2162
 set totallen [string length $_all_text]
 
2163
 set _text_pos 0
 
2164
#main cycle
 
2165
 while {!$abort && $_text_pos!=$totallen} {
 
2166
  set pos [string first "<" [string range $_all_text [expr {$_text_pos + 1024}] end]]
 
2167
  if {$pos==-1} {
 
2168
   set _text [string range $_all_text $_text_pos end]
 
2169
   set _text_pos $totallen
 
2170
  } else {
 
2171
   set _text [string range $_all_text $_text_pos [expr {$_text_pos + 1024 + $pos - 1}]]
 
2172
   set _text_pos [expr {$_text_pos + 1024 + $pos}]
 
2173
  }
 
2174
  set perc [format %2.1f [expr ($_text_pos - [string length $_text]) * 100 / $totallen.0]]
 
2175
  update
 
2176
  while {!$abort && [set pos [string first "<" $_text]]!=-1} {
 
2177
   set outtext [string range $_text 0 [expr {$pos - 1}]]
 
2178
   set _text [string range $_text $pos end]
 
2179
   if {$_istitle} {
 
2180
    append data(title) $outtext
 
2181
   } elseif {$_isscript} {
 
2182
    append data(script) $outtext
 
2183
    if {![regexp -nocase "^\<\[\r\t\n \]*\/script" $_text]} {
 
2184
     append data(script) "<"
 
2185
     set _text [string range $_text 1 end]
 
2186
     continue
 
2187
    }
 
2188
   } elseif {$_istext} {
 
2189
    if {[lsearch $attr(style) "p"]==-1} {
 
2190
     if {[$w.text get "end -2c"]=="\n"} {
 
2191
      set outtext [string trimleft $outtext " \t\n"]
 
2192
     }
 
2193
     regsub -all -- "\[\r\t\n \]+" $outtext " " outtext
 
2194
    }
 
2195
#sch
 
2196
    $w.text insert end [specialentities $outtext] [gettags]
 
2197
#/sch
 
2198
   }
 
2199
   if {[set pos [string first ">" $_text]]!=-1} {
 
2200
    set tag [string trim [string range $_text 0 $pos] "< >\t\n"]
 
2201
    set _text [string range $_text [incr pos] end]
 
2202
   } else {
 
2203
    set tag [string trim $_text "< >\t\n"]
 
2204
    set _text ""
 
2205
   }
 
2206
   regsub -all -- "\[\r\t\n \]+" $tag " " tag
 
2207
   if {[set pos [string first " " $tag]]!=-1} {
 
2208
    set tagparams [parsetag [string range $tag $pos end]]
 
2209
    set tag [string range $tag 0 [expr $pos - 1]]
 
2210
   } else {
 
2211
    set tagparams ""
 
2212
   }
 
2213
   set tag [string tolower $tag]
 
2214
   catch {tag_$tag $tagparams}
 
2215
  }
 
2216
  if {!$abort} {
 
2217
   if {!$_istitle && !$_isscript && $_istext} {
 
2218
    if {[lsearch $attr(style) "p"]==-1} {
 
2219
     if {[$w.text get "end -2c"]=="\n"} {
 
2220
      set _text [string trimleft $_text " \t\n"]
 
2221
      if {$_text_pos==$totallen} {
 
2222
       set _text [string trimright $_text " \t\n"]
 
2223
      }
 
2224
     }
 
2225
     regsub -all -- "\[\r\t\n \]+" $_text " " _text
 
2226
    }
 
2227
#sch
 
2228
    $w.text insert end [specialentities $_text] [gettags]
 
2229
#/sch
 
2230
   } elseif {$_isscript} {
 
2231
    append data(script) "$_text"
 
2232
   }
 
2233
  }
 
2234
 } 
 
2235
 
 
2236
 if {!$abort && $_isscript} {
 
2237
  append data(script) "$_text"
 
2238
  catch {tag_/script ""}
 
2239
 }
 
2240
 set abort 0
 
2241
 set showing 0
 
2242
 while {$tables(stack)!=""} {
 
2243
  tag_/td {}
 
2244
 }
 
2245
 updatehead 
 
2246
 $w.text configure -cursor arrow
 
2247
 $w.text configure -state disabled
 
2248
 $w.text tag raise fnd
 
2249
 $w.text tag raise sel
 
2250
 set stat "Done."
 
2251
}
 
2252
 
 
2253
#-------------------------------------------------------------------------------
 
2254
# Function       :  help::updatehead
 
2255
# Description    :  
 
2256
# Parameters     :  None
 
2257
# Return         :  Nothing
 
2258
#-------------------------------------------------------------------------------
 
2259
proc help::updatehead {{what "__prev __next __inc __dec __stop __Prev __Next __up1level"}} {
 
2260
 variable w
 
2261
 variable history
 
2262
 variable hpos
 
2263
 variable _t_title
 
2264
 variable settings
 
2265
 variable font
 
2266
 variable fontsize
 
2267
 variable showing
 
2268
 variable insearch
 
2269
 variable sequence
 
2270
 variable curtopic
 
2271
 variable up1level
 
2272
 variable btninfo
 
2273
 
 
2274
 foreach link $what {
 
2275
  foreach {txt vis expr btn } $btninfo($link) {
 
2276
   if {[expr $expr]} {
 
2277
    catch {$w.[set btn] configure -state normal} 
 
2278
    catch {
 
2279
     $w.title itemconfigure $_t_title($link) -font "-family $font -size [expr $fontsize - 2] -underline 1"
 
2280
     catch {$w.title itemconfigure $_t_title($link) -fill $settings(link)}
 
2281
     $w.title bind $_t_title($link) <1> "help::show \{$link\}"
 
2282
     $w.title bind $_t_title($link) <Enter> "$w.title configure -cursor hand2; catch {$w.title itemconfigure $_t_title($link) -fill \$help::settings(alink)}; set help::stat \{$txt\}"
 
2283
     $w.title bind $_t_title($link) <Leave> "$w.title configure -cursor arrow; catch {$w.title itemconfigure $_t_title($link) -fill \$help::settings(link)}; set help::stat \{Done.\}"
 
2284
    }
 
2285
   } else {
 
2286
    catch {$w.[set btn] configure -state disabled}
 
2287
    catch {
 
2288
     $w.title itemconfigure $_t_title($link) -font "-family $font -size [expr $fontsize - 2] -underline 0"
 
2289
     catch {$w.title itemconfigure $_t_title($link) -fill $settings(fore)}
 
2290
     $w.title bind $_t_title($link) <1> ""
 
2291
     $w.title bind $_t_title($link) <Enter> ""
 
2292
     $w.title bind $_t_title($link) <Leave> ""
 
2293
     $w.title configure -cursor arrow
 
2294
    }
 
2295
   }
 
2296
  }
 
2297
 }
 
2298
}
 
2299
 
 
2300
#-------------------------------------------------------------------------------
 
2301
# Function       :  help::prev
 
2302
# Description    :  Show previous topic
 
2303
# Parameters     :  None
 
2304
# Return         :  Nothing
 
2305
#-------------------------------------------------------------------------------
 
2306
proc help::prev {} {
 
2307
 variable w
 
2308
 variable history
 
2309
 variable hpos
 
2310
 
 
2311
 if {$hpos>0} {
 
2312
  set tpos [lindex [lindex $history [incr hpos -1]] 1] 
 
2313
  if {[set pos [string first "#" [set topic [lindex [lindex $history $hpos] 0]]]]!=-1} {
 
2314
   set topic [string range $topic 0 [expr $pos - 1]]
 
2315
  }
 
2316
  show $topic 0 $tpos
 
2317
 }
 
2318
}
 
2319
 
 
2320
#-------------------------------------------------------------------------------
 
2321
# Function       :  help::next
 
2322
# Description    :  Show next topic
 
2323
# Parameters     :  None
 
2324
# Return         :  Nothing
 
2325
#-------------------------------------------------------------------------------
 
2326
proc help::next {} {
 
2327
 variable w
 
2328
 variable history
 
2329
 variable hpos
 
2330
 
 
2331
 if {$hpos<[expr [llength $history] - 1]} {
 
2332
  set tpos [lindex [lindex $history [incr hpos]] 1]
 
2333
  if {[set pos [string first "#" [set topic [lindex [lindex $history $hpos] 0]]]]!=-1} {
 
2334
   set topic [string range $topic 0 [expr $pos - 1]]
 
2335
  }
 
2336
  show $topic 0 $tpos
 
2337
 }
 
2338
}
 
2339
 
 
2340
#-------------------------------------------------------------------------------
 
2341
# Function       :  help::reg                                        
 
2342
# Description    :  Assign help topic to widget
 
2343
# Parameters     :  widget      - widget path
 
2344
#                :  filename    - name of file with help
 
2345
#                :  topic       - topic name
 
2346
# Return         :  Nothing
 
2347
#-------------------------------------------------------------------------------
 
2348
proc help::reg {widget filename topic {parent {}} {event {<F1>}} {width 450} {height 400}} {
 
2349
 variable regs
 
2350
 
 
2351
 if {$filename=="" || $topic==""} {
 
2352
  if {[info exists $regs($widget)]} {
 
2353
   bind $widget $event ""
 
2354
   unset regs($widget)
 
2355
  }
 
2356
 } else {
 
2357
  bind $widget $event "help::init \{$filename\} \{$topic\} \{$parent\} $width $height; break"
 
2358
  set regs($widget) 1
 
2359
 }
 
2360
}
 
2361
 
 
2362
#-------------------------------------------------------------------------------
 
2363
# Function       :  help::updatestate                                          
 
2364
# Description    :  Update statusbar every 1/4 of seconds
 
2365
# Parameters     :  None
 
2366
# Return         :  Nothing
 
2367
#-------------------------------------------------------------------------------
 
2368
proc help::updatestate {} {
 
2369
 variable perc
 
2370
 variable stat
 
2371
 variable showing
 
2372
 
 
2373
 if {$showing} {
 
2374
  set stat "Displaying... $perc%."
 
2375
  after 250 "help::updatestate"
 
2376
 }
 
2377
}
 
2378
 
 
2379
#-------------------------------------------------------------------------------
 
2380
# Function       :  help::update_d                                              
 
2381
# Description    :  Update animated image
 
2382
# Parameters     :  None
 
2383
# Return         :  Nothing
 
2384
#-------------------------------------------------------------------------------
 
2385
proc help::update_d {} {
 
2386
 variable gw
 
2387
 variable _images
 
2388
 variable _dnum
 
2389
 variable showing
 
2390
 
 
2391
 if {$showing} {
 
2392
  incr _dnum
 
2393
  if {$_dnum>3} {set _dnum 1}
 
2394
  $gw.d configure -image $_images(d[set _dnum])
 
2395
  after 200 "help::update_d"
 
2396
 }
 
2397
}
 
2398
 
 
2399
#-------------------------------------------------------------------------------
 
2400
# Function       :  help::show_about                                           
 
2401
# Description    :  Show about text
 
2402
# Parameters     :  None
 
2403
# Return         :  Nothing
 
2404
#-------------------------------------------------------------------------------
 
2405
proc help::show_about {} {
 
2406
 variable data
 
2407
 
 
2408
 set data(__@AbOuT@__,text) "<body text=black bgcolor=#ffffd2 link=navy>
 
2409
     <p><img src=\"__@LoGo@__\"></p>
 
2410
     <p>(c) Copyright by <b><font color=navy>Andrei A. Gratchev</font></b>,
 
2411
     <font color=navy>Russia</font>, <font color=navy>Moscow</font>,
 
2412
     <font color=navy>2000</font> - <font color=navy>2003</font><br>
 
2413
     E-Mail: <font color=navy><u><tt><a href=mailto:grand@deversys.com>grand@deversys.com</a></tt></u></font>
 
2414
     </p><br><p><font size=-1>Special thanks to:<ul><li><kbd>J.W.Schmitz-H&uuml;bsch
 
2415
     </kbd><br> for implementations of additional features<li><kbd>Dave Clews</kbd><br>
 
2416
     for help in translation of in-line documentation</ul></font></p>"
 
2417
 set data(__@AbOuT@__,title) "About"
 
2418
 if {![info exists data(__@LoGo@__,image)]} {
 
2419
  set data(__@LoGo@__,image) [image create photo -data \
 
2420
    "R0lGODlhowBFAPf/AAMDCQUFCgMDBgsLDfDw8efn6MnJyjM1ai8xYTc8eCksVzA3bz9IjiMoTB4hOQkKEUhWpgUHET1Nm0BQnzZEhBwjRCIuYik3cx4oUBMZMiczZSgyWzA5YhUZKnmFum10kRElbBEjZBUmYhkraRQiUhEdRhkpYQ0VMx0vbQcLGhwrXxsoWRomVCQ0bSc4dBolTC0/fgUHDhcgPzZKkiAsVxYdNiEoQRASGT5E
 
2421
     WxUXHo2UrMrP4g4ndBYvexUrcxcrbhcrahovchktbhcpZRYoYBQkVxEfSxktaxUmWw0XOBAcQg8aPQsTLAkPIx4zdCA1eRssZQgNHh4vZyAyayQ3dhYiRyg8fgwSJSs9dSg4aklYijM7VlZhhE1TZmZrfA8rexgzfwMGDhw1fh04ghIhTiU+hQYKFS1FjCw9bT5VlDtPh0hemzVFclRooEJPc2Bzp0dVe1lolEFLaG19rC40RVNc
 
2422
     dIyZvV1jdIaNol5haY6SnQMFCg0PFH2NtXeEppikwjo+SKewx5qhssXK1lNZZ6Sru6WorykrL7nAzq+0vjQ1N+rr7d/g4pWdq4OKlh0eH2ZoatTW2Li5un+FiG1xc8/S0wIDA3R4d56iob7Av2tubJWYlU9QT7Kzsn2Aetzd2tHVxMnNusfKtLCypGtsZc7QvcfJsGRlWWhpXdrcwuvs3PDx5Pf5z/X3zfP1y/X3z7m6nru8o7y9
 
2423
     pvX24u/wxtvct8PEpP//0fr6zv//0/390fX1yvPzycnJpvf3zeXlvtDQrbe3mP//1f390/Pzy+rqw9TUscDAoLq6m/f3z/X1zczMq///1/391fr60vHxy7GxlaOjifX1z///2f391/Pzzvv71qurkpeXgYqKdm1tXf//2/392XJyYv//3f3928fHrGFhVPv72v//3/393fT01erqzXl5arKynf//4v394PX121RUS/j43sDArP//
 
2424
     5vr64v//6vv76HFxaVlZU0pKRUFBPfb26mRkYV5eXP////39/fr6+vX19SQkJAgICCwAAAAAowBFAAAI/wBz5WI2bZu3ceO8edvGTJjAWxAjSrwlMJcwYcwITtvIMWNDhxUnihxJsqTJkyhTqlwp0eI0b+liyvQ2rWGukgIvEjSIsGdPhdu21bT5kKXRo0iTKsUI8927ePGcpmMoTBcuXRNz7oQZ06lXqTIRLhwKUqnZs2iTCps2
 
2425
     Ll2BHTsGDUKEKJIzZbx24Wppkdm2tl6hCh78NSZCoUTTKl7MOKKwv+92BPpjp8+cOYVS1fpFay/EnC/TORW8ilGkuXTpVorESB7YhDUdNp5NG6nftoMoe3izZo0Od7aA/dr1eSBb0VDvRZpMuXKf59D72PmD6NMsdeOo5sJau7t3krfhIf/qszvNGTV+rkE7VosXxYF/kcurNLnynDdv2ujXj//yHD/PJfKJONY448tV3yWYoF/k
 
2426
     tIPIfWuM8QQMH2CDDTTG0KKLS4DFU0B9u60xQxlWlFhiGWWckcYa/LWBnw6p/FIMLb4oaGNtj33TTiC8zdBD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
2458
 append data(__@AbOuT@__,text) "<br><br><font size=-1 color=#303030><p>System info:<ul>
 
2459
     <li>Tcl/Tk version: $::tcl_version/$::tk_version<li>OS: $::tcl_platform(os), 
 
2460
     $::tcl_platform(osVersion) on $::tcl_platform(machine)</ul></p></font>"
 
2461
 show "__@AbOuT@__"
 
2462
}
 
2463
 
 
2464
#-------------------------------------------------------------------------------
 
2465
# Function       :  help::destroy
 
2466
# Description    :  Destroy handler
 
2467
# Parameters     :  None
 
2468
# Return         :  Nothing
 
2469
#-------------------------------------------------------------------------------
 
2470
proc help::destroy {{top 0}} {
 
2471
 variable gw
 
2472
 variable abort
 
2473
 variable showing
 
2474
 variable data
 
2475
 variable curfilename
 
2476
 variable curtopic
 
2477
 
 
2478
 if {$showing} {
 
2479
  set abort 1
 
2480
  after 200 "help::destroy $top"
 
2481
 } else {
 
2482
  catch {::destroy .dlgfind}
 
2483
  foreach imn [array names data *,image] {
 
2484
   catch {image delete $data($imn)}
 
2485
  }
 
2486
  catch {unset data}
 
2487
  set curfilename ""
 
2488
  set curtopic ""
 
2489
  if {[info exists gw] && [winfo exists $gw]} {
 
2490
   if {[string match {.tophelpwindow*} $gw]} {
 
2491
    ::destroy [winfo toplevel $gw]
 
2492
   } else {
 
2493
    if {[wm protocol [winfo toplevel $gw] WM_DELETE_WINDOW]=="help::destroy 1"} {
 
2494
     wm protocol [winfo toplevel $gw] WM_DELETE_WINDOW ""
 
2495
    }
 
2496
    if {$top} {
 
2497
     ::destroy [winfo toplevel $gw]
 
2498
    } else {
 
2499
     pack forget $gw
 
2500
     ::destroy $gw
 
2501
    }
 
2502
   }
 
2503
  }
 
2504
 }
 
2505
}
 
2506
 
 
2507
#-------------------------------------------------------------------------------
 
2508
# Function       :  help::parsetag
 
2509
# Description    :  Parsing string to list
 
2510
# Parameters     :  tagparams   -
 
2511
# Return         :  List of parsed params {name value name value ...}
 
2512
#-------------------------------------------------------------------------------
 
2513
proc help::parsetag {tagparams} {
 
2514
 set res ""
 
2515
 set tagparams [string trim $tagparams]
 
2516
 while {$tagparams!=""} {
 
2517
  if {[set sp [string first " " $tagparams]]==-1} {
 
2518
   set sp 99999999
 
2519
  }
 
2520
  if {[set i [string first "=" $tagparams]]!=-1 && $i<$sp} {
 
2521
   set param [string tolower [string trim [string range $tagparams 0 [expr $i-1]]]]
 
2522
   incr i
 
2523
   set tagparams [string trim [string range $tagparams $i end]]
 
2524
   set lastC [string index $tagparams 0]
 
2525
   if {$lastC!="\"" && $lastC!="\'"} {
 
2526
    set lastC " "
 
2527
   } else {
 
2528
    set tagparams [string range $tagparams 1 end]
 
2529
   }
 
2530
   if {[set i [string first $lastC $tagparams]]==-1} {
 
2531
    set value $tagparams
 
2532
    set tagparams ""
 
2533
   } else {
 
2534
    set value [string range $tagparams 0 [expr $i-1]]
 
2535
    incr i
 
2536
    set tagparams [string trim [string range $tagparams $i end]]
 
2537
   }
 
2538
  } else {
 
2539
   set param [string tolower [string trim [string range $tagparams 0 [expr $sp-1]]]]
 
2540
   set tagparams [string trim [string range $tagparams $sp end]]
 
2541
   set value ""
 
2542
  }
 
2543
  lappend res $param $value
 
2544
 }
 
2545
 return $res
 
2546
}
 
2547
 
 
2548
#-------------------------------------------------------------------------------
 
2549
# Function       :  help::showmark
 
2550
# Description    :  Goto mark anisochronously
 
2551
# Parameters     :  mark        - name of mark
 
2552
# Return         :  Nothing
 
2553
#-------------------------------------------------------------------------------
 
2554
proc help::showmark {mark} {
 
2555
 variable w
 
2556
 variable showing
 
2557
 
 
2558
 if {[catch {$w.text yview $mark}] && $showing} {
 
2559
  after 200 "help::showmark \{$mark\}"
 
2560
 } else {
 
2561
  updatehead "__prev __next"
 
2562
 }
 
2563
 catch {$w.text see $mark}
 
2564
}
 
2565
 
 
2566
#-------------------------------------------------------------------------------
 
2567
# Function       :  help::showpos
 
2568
# Description    :  Goto mark anisochronously
 
2569
# Parameters     :  mark        - name of mark
 
2570
# Return         :  Nothing
 
2571
#-------------------------------------------------------------------------------
 
2572
proc help::showpos {pos} {
 
2573
 variable gw
 
2574
 variable showing
 
2575
 
 
2576
 if {$showing && [$gw.text get $pos]==""} {
 
2577
  after 200 "help::showpos \{$pos\}"
 
2578
 } else {
 
2579
  catch {$gw.text yview $pos}
 
2580
  catch {$gw.text see $pos}
 
2581
  updatehead "__prev __next"
 
2582
 }
 
2583
}
 
2584
 
 
2585
#-------------------------------------------------------------------------------
 
2586
# Function       :  help::open
 
2587
# Description    :  Show "Open" dialog and open help
 
2588
# Parameters     :  None
 
2589
# Return         :  Nothing
 
2590
#-------------------------------------------------------------------------------
 
2591
proc help::open {} {
 
2592
 variable gw
 
2593
 variable curfilename
 
2594
 
 
2595
 set tk_strictMotif 0
 
2596
 set filetypes {
 
2597
          {"Help files"   {.help}         TEXT}
 
2598
          {"HTML files"   {.htm .html}    TEXT}
 
2599
          {"All files"    {*}                 }
 
2600
          }
 
2601
 set res [tk_getOpenFile -filetypes $filetypes -parent $gw \
 
2602
         -initialdir [file dirname $curfilename]]
 
2603
 if {$res!=""} {
 
2604
  help::init $res
 
2605
 } else {
 
2606
  if {$curfilename==""} {
 
2607
   destroy
 
2608
  }
 
2609
 }
 
2610
}
 
2611
 
 
2612
#-------------------------------------------------------------------------------
 
2613
# Function       :  help::rightclick
 
2614
# Description    :  Show popup menu
 
2615
# Parameters     :  x & y   - position
 
2616
# Return         :  Nothing
 
2617
#-------------------------------------------------------------------------------
 
2618
proc help::rightclick {x y} {
 
2619
 variable gw
 
2620
 variable fontsize
 
2621
 variable index
 
2622
 variable hpos
 
2623
 variable history
 
2624
 variable showing
 
2625
 variable insearch
 
2626
 
 
2627
 $gw.menu entryconfigure "Back" -state [expr {($hpos>0)?"normal":"disabled"}]
 
2628
 $gw.menu entryconfigure "Forward" -state [expr {($hpos<([llength $history] - 1))?"normal":"disabled"}]
 
2629
 $gw.menu entryconfigure "Stop" -state [expr {($showing || $insearch)?"normal":"disabled"}]
 
2630
 $gw.menu entryconfigure "Copy" -state [expr {([catch {selection get}])?"disabled":"normal"}]
 
2631
 $gw.menu entryconfigure "Increase font size" -state [expr {($fontsize<30)?"normal":"disabled"}]
 
2632
 $gw.menu entryconfigure "Decrease font size" -state [expr {($fontsize>6)?"normal":"disabled"}]
 
2633
 $gw.menu entryconfigure "Search in topics..." -state [expr {([llength $index])?"normal":"disabled"}]
 
2634
 tk_popup $gw.menu $x $y
 
2635
}
 
2636
 
 
2637
#-------------------------------------------------------------------------------
 
2638
# Function       :  help::rightclickX
 
2639
# Description    :  Show popup menu
 
2640
# Parameters     :  x & y   - position
 
2641
# Return         :  Nothing
 
2642
#-------------------------------------------------------------------------------
 
2643
proc help::rightclickX {x y} {
 
2644
 variable gw
 
2645
 
 
2646
 tk_popup $gw.menuX $x $y
 
2647
}
 
2648
 
 
2649
#sch replace specialentities by characters
 
2650
#-------------------------------------------------------------------------------
 
2651
# Function       :  help::specialentities
 
2652
# Description    :  replace specialentities by characters
 
2653
# Parameters     :  text
 
2654
# Return         :  text
 
2655
#-------------------------------------------------------------------------------
 
2656
proc help::specialentities {text} {
 
2657
 set text [string map {\
 
2658
   &nbsp;  { } &gt;     >  &lt;     <  &amp;   {&} "&#38;" {&}            \
 
2659
   &iexcl;  �  &cent;   �  &pound;  �  &curren; �  &yen;    �  &brvbar; � \
 
2660
   &sect;   �  &uml;    �  &copy;   �  &ordf;   �  &laquo;  �  &not;    � \
 
2661
   &shy;    �  &reg;    �  &macr;   �  &deg;    �  &plusmn; �  &sup2;   � \
 
2662
   &sup3;   �  &acute;  �  &micro;  �  &para;   �  &middot; �  &cedil;  � \
 
2663
   &sup1;   �  &ordm;   �  &raquo;  �  &frac14; �  &frac12; �  &frac34; � \
 
2664
   &iquest; �  &Agrave; �  &Aacute; �  &Acirc;  �  &Atilde; �  &Auml;   � \
 
2665
   &Aring;  �  &AElig;  �  &Ccedil; �  &Egrave; �  &Eacute; �  &Ecirc;  � \
 
2666
   &Euml;   �  &Igrave; �  &Iacute; �  &Icirc;  �  &Iuml;   �  &ETH;    � \
 
2667
   &Ntilde; �  &Ograve; �  &Oacute; �  &Ocirc;  �  &Otilde; �  &Ouml;   � \
 
2668
   &times;  �  &Oslash; �  &Ugrave; �  &Uacute; �  &Ucirc;  �  &Uuml;   � \
 
2669
   &Yacute; �  &THORN;  �  &szlig;  �  &agrave; �  &aacute; �  &acirc;  � \
 
2670
   &atilde; �  &auml;   �  &aring;  �  &aelig;  �  &ccedil; �  &egrave; � \
 
2671
   &eacute; �  &ecirc;  �  &euml;   �  &igrave; �  &iacute; �  &icirc;  � \
 
2672
   &iuml;   �  &eth;    �  &ntilde; �  &ograve; �  &oacute; �  &ocirc;  � \
 
2673
   &otilde; �  &ouml;   �  &divide; �  &oslash; �  &ugrave; �  &uacute; � \
 
2674
   &ucirc;  �  &uuml;   �  &yacute; �  &thorn;  �  &yuml;   �  &quot;  \" \
 
2675
 } $text]
 
2676
 while {[regexp -- {&#([0-9]+);} $text x num]} {
 
2677
  regsub -all -- $x $text [binary format c $num] text
 
2678
 }
 
2679
 return $text
 
2680
}
 
2681
#/sch
 
2682
 
 
2683
#-------------------------------------------------------------------------------
 
2684
# Function       :  help::focusin
 
2685
# Description    :  FocusIn handler (it necessary to correct behavior if
 
2686
#                :  any modal window exists)
 
2687
# Parameters     :  None
 
2688
# Return         :  Nothing
 
2689
#-------------------------------------------------------------------------------
 
2690
proc help::focusin {rw m} {
 
2691
 variable _focus_w
 
2692
 
 
2693
 if {$rw==[winfo toplevel $rw]} {
 
2694
 
 
2695
  if {[grab current .]!="" && $_focus_w==""} {
 
2696
   set _focus_w [grab current .]
 
2697
   catch {grab release $_focus_w}
 
2698
  }
 
2699
 }
 
2700
}
 
2701
 
 
2702
#-------------------------------------------------------------------------------
 
2703
# Function       :  help::focusout
 
2704
# Description    :  FocusOut handler (it necessary to correct behavior if
 
2705
#                :  any modal window exists)
 
2706
# Parameters     :  None
 
2707
# Return         :  Nothing
 
2708
#-------------------------------------------------------------------------------
 
2709
proc help::focusout {rw m} {
 
2710
 variable _focus_w
 
2711
 
 
2712
 if {$rw==[winfo toplevel $rw]} {
 
2713
 
 
2714
  if {$_focus_w!=""} {
 
2715
   catch {grab $_focus_w}
 
2716
   set _focus_w ""
 
2717
  }
 
2718
 }
 
2719
}
 
2720
 
 
2721
proc help::img_change {name p_src} {
 
2722
 variable data
 
2723
 variable curfilename
 
2724
 variable _images
 
2725
 
 
2726
 if {[info exists data($name,image,id)]} {
 
2727
  if {[info exists data($p_src,image)]} {
 
2728
   catch {$data($name,image,widget).text image configure $data($name,image,id) -image $data($p_src,image)}
 
2729
  } else {
 
2730
   if {[catch {set data($p_src,image) [image create photo -file [file join [file dirname $curfilename] $p_src]]}]} {
 
2731
    catch {set imind [$data($name,image,widget).text image configure $data($name,image,id) -image $_images(broken)]}
 
2732
   } else {
 
2733
    catch {set imind [$data($name,image,widget).text image configure $data($name,image,id) -image $data($p_src,image)]}
 
2734
   }
 
2735
  }
 
2736
 }
 
2737
}
 
2738
 
 
2739
proc help::id_visible {name {vis 1}} {
 
2740
 variable data
 
2741
 
 
2742
 catch {$data($name,names,widget).text tag configure $data($name,names,id) -elide [expr {! $vis}]}
 
2743
}
 
2744
 
 
2745
proc help::id_change {name text} {
 
2746
 variable data
 
2747
 
 
2748
 catch {
 
2749
  set range [$data($name,names,widget).text tag ranges $data($name,names,id)]
 
2750
  set names [$data($name,names,widget).text tag names [lindex $range 0]]
 
2751
  $data($name,names,widget).text configure -state normal
 
2752
  eval "\$data(\$name,names,widget).text delete $range"
 
2753
  $data($name,names,widget).text insert [lindex $range 0] $text $names
 
2754
  $data($name,names,widget).text configure -state disabled
 
2755
 }
 
2756
}
 
2757
 
 
2758
#-------------------------------------------------------------------------------
 
2759
# Function       :  help::dlgfind:init
 
2760
# Description    :  Create and show find dialog
 
2761
# Parameters     :  mode_local  - make local(true) or global(false) find dialog
 
2762
# Return         :  Nothing
 
2763
#-------------------------------------------------------------------------------
 
2764
proc help::dlgfind:init {{mode_local 1}} {
 
2765
 variable gw
 
2766
 variable index
 
2767
 
 
2768
 if {!$mode_local && $index==""} {return}
 
2769
 
 
2770
 catch {::destroy .dlgfind}
 
2771
 
 
2772
 toplevel .dlgfind
 
2773
 wm overrideredirect .dlgfind 1
 
2774
 wm transient .dlgfind $gw
 
2775
 wm withdraw .dlgfind
 
2776
 
 
2777
 variable fnd_len 1
 
2778
 
 
2779
 wm resizable .dlgfind 0 0
 
2780
 frame .dlgfind.f
 
2781
 frame .dlgfind.btn
 
2782
 pack .dlgfind.f .dlgfind.btn -side left -expand 1 -fill y -padx 3
 
2783
 if {$mode_local} {
 
2784
  wm title .dlgfind "Find"
 
2785
  button .dlgfind.btn.f -text "Find" -width 8 -default active -command "help::dlgfind:find"
 
2786
 } else {
 
2787
  wm title .dlgfind "Search in all topics"
 
2788
  button .dlgfind.btn.f -text "Find" -width 8 -default active -command "help::dlgfind:search"
 
2789
 }
 
2790
 button .dlgfind.btn.c -text "Cancel" -width 8 -command "help::dlgfind:destroy"
 
2791
 pack .dlgfind.btn.f .dlgfind.btn.c -side top -expand 0 -fill x -pady 3
 
2792
 
 
2793
 frame .dlgfind.f.text
 
2794
 frame .dlgfind.f.b
 
2795
 pack .dlgfind.f.text .dlgfind.f.b -side top -fill x -expand 1 -anchor w -pady 3
 
2796
 label .dlgfind.f.text.l -text "Find what: "
 
2797
 entry .dlgfind.f.text.e -textvariable help::fnd_str -width 30
 
2798
 pack .dlgfind.f.text.l .dlgfind.f.text.e -side left -fill y -expand 1
 
2799
 .dlgfind.f.text.e selection range 0 end
 
2800
 frame .dlgfind.f.b.l
 
2801
 frame .dlgfind.f.b.dir
 
2802
 pack .dlgfind.f.b.l .dlgfind.f.b.dir -side left -anchor s
 
2803
 
 
2804
 if {$mode_local} {
 
2805
  frame .dlgfind.f.b.dir.p -relief flat -borderwidth 0
 
2806
  frame .dlgfind.f.b.dir.b -highlightthickness 0 -relief groove -borderwidth 2
 
2807
  label .dlgfind.f.b.dir.l -highlightthickness 0 -text "Direction" \
 
2808
                          -relief flat -bd 0 -padx 2 -pady 0
 
2809
  frame .dlgfind.f.b.dir.b.p -relief flat -bd 0 -highlightthickness 0
 
2810
  frame .dlgfind.f.b.dir.f -relief flat -bd 0 -highlightthickness 0
 
2811
  set height [winfo reqheight .dlgfind.f.b.dir.l]
 
2812
  .dlgfind.f.b.dir.p configure -height [expr {$height/2}]
 
2813
  .dlgfind.f.b.dir.b.p configure -height [expr {$height/2+$height%2+1}]
 
2814
  pack .dlgfind.f.b.dir.b.p -side top -fill x
 
2815
  pack .dlgfind.f.b.dir.f -in .dlgfind.f.b.dir.b -fill both -expand yes -padx 4 -pady 4
 
2816
  pack .dlgfind.f.b.dir.p -side top -fill x
 
2817
  pack .dlgfind.f.b.dir.b -fill both -expand yes
 
2818
  place .dlgfind.f.b.dir.l -x 5 -anchor nw -y 0
 
2819
 
 
2820
  set f .dlgfind.f.b.dir.f
 
2821
  radiobutton $f.up -text "Up" -value "-backwards" -variable help::fnd_direction
 
2822
  radiobutton $f.down -text "Down" -value "-forwards" -variable help::fnd_direction
 
2823
  pack $f.up $f.down -side left -fill y -expand 1
 
2824
 }
 
2825
 checkbutton .dlgfind.f.b.l.case -text "Match case" -onvalue "" -offvalue "-nocase" -variable help::fnd_case
 
2826
 checkbutton .dlgfind.f.b.l.regexp -text "Regexp expression" -onvalue "-regexp" -offvalue "" -variable help::fnd_regexp
 
2827
 pack .dlgfind.f.b.l.regexp .dlgfind.f.b.l.case -side bottom -expand 1 -anchor sw
 
2828
 bind .dlgfind <Return>  ".dlgfind.btn.f configure -relief sunken; update idletasks; .dlgfind.btn.f configure -relief raised; .dlgfind.btn.f invoke"
 
2829
 bind .dlgfind <Escape> "help::dlgfind:destroy"
 
2830
 bind .dlgfind.f.text.e <KeyRelease> help::dlgfind:checkstate
 
2831
 bind .dlgfind <FocusIn>  "help::focusin %W %m"
 
2832
 bind .dlgfind <FocusOut> "help::focusout %W %m"
 
2833
 bind .dlgfind <Configure> "help::focusin %W %m"
 
2834
 bind .dlgfind <Destroy> "help::focusout %W %m"
 
2835
 bind .dlgfind <Expose> "help::focusin %W %m"
 
2836
 dlgfind:checkstate
 
2837
 
 
2838
 update idletasks
 
2839
 set w [winfo reqwidth .dlgfind]
 
2840
 set h [winfo reqheight .dlgfind]
 
2841
 set x [expr [winfo rootx $gw] + ([winfo width  $gw] - $w)/2]
 
2842
 set y [expr [winfo rooty $gw] + ([winfo height $gw] - $h)/2]
 
2843
 wm geometry .dlgfind "${w}x${h}+${x}+${y}"
 
2844
 
 
2845
 wm overrideredirect .dlgfind 0
 
2846
 wm deiconify .dlgfind
 
2847
 
 
2848
 tkwait visibility .dlgfind
 
2849
 catch {focus -force .dlgfind.f.text.e}
 
2850
}
 
2851
 
 
2852
#-------------------------------------------------------------------------------
 
2853
# Function       :  help::dlgfind:destroy
 
2854
# Description    :  Destroy find dialog
 
2855
# Parameters     :  None
 
2856
# Return         :  Nothing
 
2857
#-------------------------------------------------------------------------------
 
2858
proc help::dlgfind:destroy {} {
 
2859
 variable gw
 
2860
 
 
2861
 catch {::destroy .dlgfind}
 
2862
 catch {focus -force $gw.text}
 
2863
}
 
2864
 
 
2865
#-------------------------------------------------------------------------------
 
2866
# Function       :  help::dlgfind:checkstate
 
2867
# Description    :  Modify state of "Find" button
 
2868
# Parameters     :  None
 
2869
# Return         :  Nothing
 
2870
#-------------------------------------------------------------------------------
 
2871
proc help::dlgfind:checkstate {} {
 
2872
 variable fnd_str
 
2873
 
 
2874
 if {$fnd_str==""} {
 
2875
  .dlgfind.btn.f configure -state disabled
 
2876
 } else {
 
2877
  .dlgfind.btn.f configure -state normal
 
2878
 }
 
2879
}
 
2880
 
 
2881
#-------------------------------------------------------------------------------
 
2882
# Function       :  help::dlgfind:find
 
2883
# Description    :  Find function
 
2884
# Parameters     :  None
 
2885
# Return         :  Nothing
 
2886
#-------------------------------------------------------------------------------
 
2887
proc help::dlgfind:find {} {
 
2888
 variable gw
 
2889
 variable fnd_str
 
2890
 variable fnd_len
 
2891
 variable fnd_case 
 
2892
 variable fnd_regexp
 
2893
 variable fnd_direction
 
2894
 
 
2895
 if {![dlgfind:checkregexp $fnd_regexp $fnd_str]} {return}
 
2896
 if {$fnd_direction=="-forwards"} {set offset "+${fnd_len}chars"; set stop "end"} else {set offset "-${fnd_len}chars"; set stop "1.0"}
 
2897
 set pos [$gw.text index "insert$offset"]
 
2898
 if {[set findpos [eval $gw.text search $fnd_case $fnd_regexp $fnd_direction -count "help::fnd_len" -- {$fnd_str} $pos $stop]]!=""} {
 
2899
  $gw.text mark set insert $findpos
 
2900
  $gw.text see $findpos
 
2901
  $gw.text tag remove fnd 1.0 end
 
2902
  $gw.text tag remove sel 1.0 end
 
2903
  $gw.text tag add sel $findpos "$findpos +${fnd_len}chars"
 
2904
  $gw.text tag add fnd $findpos "$findpos +${fnd_len}chars"
 
2905
 }
 
2906
}
 
2907
 
 
2908
#-------------------------------------------------------------------------------
 
2909
# Function       :  help::dlgfind:search
 
2910
# Description    :  Find function (at all topics)
 
2911
# Parameters     :  None
 
2912
# Return         :  Nothing
 
2913
#-------------------------------------------------------------------------------
 
2914
proc help::dlgfind:search {} {
 
2915
 variable gw
 
2916
 variable fnd_str
 
2917
 variable fnd_len [string length $fnd_str]
 
2918
 variable fnd_case 
 
2919
 variable fnd_regexp
 
2920
 variable searchedtext
 
2921
 variable index
 
2922
 variable data
 
2923
 variable abort 0
 
2924
 variable stat
 
2925
 variable insearch
 
2926
 
 
2927
 if {$insearch} {
 
2928
  set abort 1
 
2929
  after 250 help::dlgfind:search
 
2930
  return
 
2931
 }
 
2932
 
 
2933
 if {![dlgfind:checkregexp $fnd_regexp $fnd_str]} {return}
 
2934
 dlgfind:destroy
 
2935
 
 
2936
 if {$searchedtext==[list $fnd_str $fnd_case $fnd_regexp]} {
 
2937
  set help::curtopic ""
 
2938
  show "__@SearchResult@__"
 
2939
  return
 
2940
 }
 
2941
 set insearch 1
 
2942
 set searchedtext [list $fnd_str $fnd_case $fnd_regexp]
 
2943
 
 
2944
 set found 0
 
2945
 set data(__@SearchResult@__,title) "Search results"
 
2946
 set data(__@SearchResult@__,text) "<body text=black bgcolor=#ffffd2 link=#006800><ul>"
 
2947
 updatehead "__stop"
 
2948
 if {$index!=""} {
 
2949
  if {$fnd_case==""} {
 
2950
   set fstr $fnd_str
 
2951
  } else {
 
2952
   set fstr [string tolower $fnd_str]
 
2953
  }
 
2954
  if {[set pos [lsearch -exact $index "__index"]]!=-1} {
 
2955
   set topics [lreplace $index $pos $pos]
 
2956
  } else {
 
2957
   set topics $index
 
2958
  }
 
2959
  foreach topic $topics {
 
2960
   set _all_text $data($topic,text)
 
2961
   set totallen [string length $_all_text]
 
2962
   set _text_pos 0
 
2963
   set stat "Searching in $data($topic,title)..."
 
2964
   update
 
2965
   set outtext ""
 
2966
   while {!$abort && $_text_pos!=$totallen} {
 
2967
    set pos [string first "<" [string range $_all_text [expr {$_text_pos + 1024}] end]]
 
2968
    if {$pos==-1} {
 
2969
     set _text [string range $_all_text $_text_pos end]
 
2970
     set _text_pos $totallen
 
2971
    } else {
 
2972
     set _text [string range $_all_text $_text_pos [expr {$_text_pos + 1024 + $pos - 1}]]
 
2973
     set _text_pos [expr {$_text_pos + 1024 + $pos}]
 
2974
    } 
 
2975
    while {!$abort && [set pos [string first "<" $_text]]!=-1} {
 
2976
     append outtext [string range $_text 0 [expr {$pos - 1}]]
 
2977
     set _text [string range $_text $pos end]
 
2978
     if {[set pos [string first ">" $_text]]!=-1} {
 
2979
      set _text [string range $_text [incr pos] end]
 
2980
     } else {
 
2981
      set _text ""
 
2982
     }
 
2983
    }
 
2984
    if {!$abort} {
 
2985
     append outtext $_text
 
2986
    }
 
2987
   }
 
2988
   if {$abort} {
 
2989
    break
 
2990
   } else {
 
2991
    set outtext [specialentities $outtext]
 
2992
    if {$fnd_regexp!=""} {
 
2993
     if {[eval regexp -indices $fnd_case -- \$fnd_str \$outtext rpos]} {
 
2994
      set pos [lindex $rpos 0]
 
2995
      set fnd_len [expr {[lindex $rpos 1] - [lindex $rpos 0] + 1}]
 
2996
     } else {
 
2997
      set pos -1
 
2998
     }
 
2999
    } else {
 
3000
     if {$fnd_case==""} {
 
3001
      set _text $outtext
 
3002
     } else {
 
3003
      set _text [string tolower $outtext]
 
3004
     }
 
3005
     set pos [string first $fstr $_text]
 
3006
    }  
 
3007
    if {$pos!=-1} {
 
3008
     set str1 [string map {{&} {&amp;} {>} {&gt;} {<} {&lt;}} [string range $outtext [expr {$pos - 50}] [expr {$pos - 1}]]]
 
3009
     set str2 [string map {{&} {&amp;} {>} {&gt;} {<} {&lt;}} [string range $outtext $pos [expr {$pos + $fnd_len - 1}]]]
 
3010
     set str3 [string map {{&} {&amp;} {>} {&gt;} {<} {&lt;}} [string range $outtext [expr {$pos + $fnd_len}] [expr {$pos + $fnd_len + 70}]]]
 
3011
     incr found
 
3012
     append data(__@SearchResult@__,text) "<li><a href=\"$topic\">[string map {{&} {&amp;} {>} {&gt;} {<} {&lt;}} $data($topic,title)]</a><br>"
 
3013
     append data(__@SearchResult@__,text) "<font size=-1>...$str1<font color=#000080><b>$str2</b></font>$str3...</font><br><br>"
 
3014
    }
 
3015
   }
 
3016
  }
 
3017
 }
 
3018
 if {$abort} {
 
3019
  append data(__@SearchResult@__,text) "</ul><font color=#c00000>Search aborted.</font></body>"
 
3020
  set searchedtext ""
 
3021
 } elseif {!$found} {
 
3022
  append data(__@SearchResult@__,text) "</ul><font color=#c00000>No topics found for request</font> <b>\"[string map {{&} {&amp;} {>} {&gt;} {<} {&lt;}} $fnd_str]\"</b> <font color=#c00000>!</font></body>"
 
3023
 } else {
 
3024
  append data(__@SearchResult@__,text) "</ul></body>"
 
3025
 }
 
3026
 set data(__@SearchResult@__,title) "Search results ($found found)"
 
3027
 set abort 0
 
3028
 $gw.text configure -cursor arrow
 
3029
 set stat "Done."
 
3030
 set insearch 0
 
3031
# updatehead "__stop"
 
3032
 set help::curtopic ""
 
3033
 show "__@SearchResult@__"
 
3034
}
 
3035
 
 
3036
#-------------------------------------------------------------------------------
 
3037
# Function       :  help::dlgfind:checkregexp
 
3038
# Description    :  Check function
 
3039
# Parameters     :  
 
3040
# Return         :  Nothing
 
3041
#-------------------------------------------------------------------------------
 
3042
proc help::dlgfind:checkregexp {regexp val} {
 
3043
 if {$regexp=="-regexp"} {
 
3044
  if {[catch {regexp -- "$val" {}}]} {
 
3045
   tk_dialog .help_error_in_regexp_dialog "Error in regexp" "Error in regular expression:\n\"$val\"" "" 0 "Ok"
 
3046
   return 0
 
3047
  } else {
 
3048
   return 1
 
3049
  }
 
3050
 } else {
 
3051
  return 1
 
3052
 }
 
3053
}
 
3054
 
 
3055
#-------------------------------------------------------------------------------
 
3056
# Function       :  help::add_ext
 
3057
# Description    :  Loads extensions for help package
 
3058
# Parameters     :  filename    - name of file to load
 
3059
# Return         :  Nothing
 
3060
#-------------------------------------------------------------------------------
 
3061
proc help::add_ext {filename} {
 
3062
 variable gw
 
3063
 variable ext_loaded
 
3064
 
 
3065
 set name [file tail $filename]
 
3066
 if {[lsearch $ext_loaded $name]==-1} {
 
3067
  if {![catch {source $filename}]} {
 
3068
   lappend ext_loaded $name           
 
3069
  }
 
3070
 }
 
3071
}
 
3072
 
 
3073
#===============================================================================
 
3074
# Initialization section
 
3075
#===============================================================================
 
3076
if {[catch {package require Tcl 8.1}] || [catch {package require Tk 8.1}]} {
 
3077
 error "Incompatible version of Tcl/Tk. Please update your Tcl/Tk."
 
3078
 exit
 
3079
}
 
3080
switch -- $tcl_platform(platform) {
 
3081
 "windows" {
 
3082
    proc help::showurl {url} {
 
3083
     eval exec [auto_execok start] [list $url] &
 
3084
    }
 
3085
  }
 
3086
 
 
3087
 "unix" {
 
3088
    proc help::showurl {url} {
 
3089
     exec netscape [list $url] &
 
3090
    }
 
3091
  }
 
3092
 
 
3093
 "macintosh" {
 
3094
    proc help::showurl {url} {
 
3095
     global env
 
3096
 
 
3097
     if {![info exists env(BROWSER)]} {
 
3098
      set env(BROWSER) "Browse the Internet"
 
3099
     }
 
3100
     if {[catch {
 
3101
      AppleScript execute "tell application \"$env(BROWSER)\"
 
3102
                           open url \"$url\"
 
3103
                           end tell"} emsg] 
 
3104
        } {
 
3105
      error "Error displaying $url in browser\n$emsg"
 
3106
     } 
 
3107
    }
 
3108
  }
 
3109
}
 
3110
 
 
3111
help::add_ext [file join [file dirname [info script]] "help_chk.tcl"]
 
3112
help::add_ext [file join [file dirname [info script]] "help_2htm.tcl"]
 
3113
### ADD BY JAIME URZUA GREZ
 
3114
help::add_ext [file join [file dirname [info script]] "help_tbl.tcl"]