Check-in [767fb31256]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix another problem with the switching tabs logic. (CVS 1237)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:767fb31256b031c366ace59058275831d799f674
User & Date: danielk1977 2008-01-20 05:59:13
Context
2008-01-20
06:17
Fix tiling of pixmap images. Ticket #271. (CVS 1238) check-in: a11500ac34 user: danielk1977 tags: trunk
05:59
Fix another problem with the switching tabs logic. (CVS 1237) check-in: 767fb31256 user: danielk1977 tags: trunk
2008-01-19
06:08
Correctly handle selectors with adjacent commas i.e. "p,,a" as a syntax error, instead of crashing. Ticket #266. (CVS 1236) check-in: 1e21a8dbe3 user: danielk1977 tags: trunk
Changes

Changes to hv/hv3_http.tcl.

1
2
3
4
5
6
7
8
...
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
...
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
namespace eval hv3 { set {version($Id: hv3_http.tcl,v 1.61 2008/01/19 05:59:31 danielk1977 Exp $)} 1 }

#
# This file contains implementations of the -requestcmd script used with 
# the hv3 widget for the browser. Supported functions are:
#
#     * http:// (including cookies)
#     * file:// (code for this is now in hv3_file.tcl)
................................................................................
    # Nothing to do. We used to destroy the $myCookieManager object here,
    # but that object is now global and exists for the lifetime of the
    # application.
    array unset $me
    rename $me {}
  }

  proc configure {me args} {
    upvar $me O
    foreach {option value} $args {
      set O($option) $value
      if {$option eq "-statusvar"} {ConfigureStatusvar $me}
    }
  }

  proc cget {me option} {
    upvar $me O
    return $O($option)
  }

  # Register a custom scheme handler command (like "home:").
  proc schemehandler {me scheme handler} {
    upvar $me O
    set O(scheme.$scheme) $handler
  }

  # This method is invoked as the -requestcmd script of an hv3 widget
................................................................................
  
  proc busy {me} {
    upvar $me O
    return [expr [llength $O(myWaitingHandles)] + [llength $O(myInProgressHandles)]]
  }

  # Invoked to set the value of the -statusvar option
  proc ConfigureStatusvar {me} {
    Updatestatusvar $me
  }

  # Invoked when data is available from an http request. Pass the data
  # along to hv3 via the downloadHandle.
  #
  proc _AppendCallback {me downloadHandle socket token} {
................................................................................
  }
  proc inprogress_handles {me} {
    upvar $me O
    return $O(myInProgressHandles)
  }
}

::hv3::namespace_to_constructor ::hv3::protocol

snit::widget ::hv3::protocol_gui {
  
  variable myProtocol ""
  variable myTimerId ""

  variable myDoneList [list]
|







 







<
<
<
<
<
<
<
<
<
<
<
<
<







 







|







 







|







1
2
3
4
5
6
7
8
...
103
104
105
106
107
108
109













110
111
112
113
114
115
116
...
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
...
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
namespace eval hv3 { set {version($Id: hv3_http.tcl,v 1.62 2008/01/20 05:59:13 danielk1977 Exp $)} 1 }

#
# This file contains implementations of the -requestcmd script used with 
# the hv3 widget for the browser. Supported functions are:
#
#     * http:// (including cookies)
#     * file:// (code for this is now in hv3_file.tcl)
................................................................................
    # Nothing to do. We used to destroy the $myCookieManager object here,
    # but that object is now global and exists for the lifetime of the
    # application.
    array unset $me
    rename $me {}
  }














  # Register a custom scheme handler command (like "home:").
  proc schemehandler {me scheme handler} {
    upvar $me O
    set O(scheme.$scheme) $handler
  }

  # This method is invoked as the -requestcmd script of an hv3 widget
................................................................................
  
  proc busy {me} {
    upvar $me O
    return [expr [llength $O(myWaitingHandles)] + [llength $O(myInProgressHandles)]]
  }

  # Invoked to set the value of the -statusvar option
  proc configure-statusvar {me} {
    Updatestatusvar $me
  }

  # Invoked when data is available from an http request. Pass the data
  # along to hv3 via the downloadHandle.
  #
  proc _AppendCallback {me downloadHandle socket token} {
................................................................................
  }
  proc inprogress_handles {me} {
    upvar $me O
    return $O(myInProgressHandles)
  }
}

::hv3::make_constructor ::hv3::protocol

snit::widget ::hv3::protocol_gui {
  
  variable myProtocol ""
  variable myTimerId ""

  variable myDoneList [list]

Changes to hv/hv3_notebook.tcl.

1
2
3
4
5
6
7
8
...
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
namespace eval hv3 { set {version($Id: hv3_notebook.tcl,v 1.7 2008/01/19 05:59:31 danielk1977 Exp $)} 1 }

# This file contains the implementation of three snit widgets:
#
#     ::hv3::notebook_header
#     ::hv3::notebook
#     ::hv3::tabset
#
................................................................................

    grid forget $widget
    bind $widget <Destroy> ""

    set myWidgets [lreplace $myWidgets $idx $idx]
    $myHeader del_tab $widget

    if {$myCurrent == [llength $myWidgets]} {
      incr myCurrent -1
    }
    if {$myCurrent >= 0} {
      set w [lindex $myWidgets $myCurrent]
      raise $w
      $myHeader select $w
    }
|







 







|







1
2
3
4
5
6
7
8
...
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
namespace eval hv3 { set {version($Id: hv3_notebook.tcl,v 1.8 2008/01/20 05:59:13 danielk1977 Exp $)} 1 }

# This file contains the implementation of three snit widgets:
#
#     ::hv3::notebook_header
#     ::hv3::notebook
#     ::hv3::tabset
#
................................................................................

    grid forget $widget
    bind $widget <Destroy> ""

    set myWidgets [lreplace $myWidgets $idx $idx]
    $myHeader del_tab $widget

    if {$idx < $myCurrent || $myCurrent == [llength $myWidgets]} {
      incr myCurrent -1
    }
    if {$myCurrent >= 0} {
      set w [lindex $myWidgets $myCurrent]
      raise $w
      $myHeader select $w
    }

Changes to hv/hv3_request.tcl.

1
2
3
4
5
6
7
8
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
...
361
362
363
364
365
366
367
368
369
namespace eval hv3 { set {version($Id: hv3_request.tcl,v 1.23 2008/01/19 05:59:31 danielk1977 Exp $)} 1 }

#--------------------------------------------------------------------------
# This file contains the implementation of two types used by hv3:
#
#     ::hv3::request
#

................................................................................

    # The protocol implementation sets this option to contain the 
    # HTTP header (or it's equivalent). The format is a serialised array.
    # Example:
    # 
    #     {Set-Cookie safe-search=on Location http://www.google.com}
    #
    # The following http-header types are handled locally by the ConfigureHeader
    # method, as soon as the -header option is set:
    #
    #     Set-Cookie         (Call ::hv3::the_cookie_manager method)
    #     Content-Type       (Set the -mimetype option)
    #     Content-Length     (Set the -expectedsize option)
    #
    set O(-header) ""
  
................................................................................
  proc destroy {me} {
    upvar $me O
    foreach hook $O(myFinishHookList) { eval $hook }
    rename $me {}
    array unset $me
  }

  proc configure {me args} {
    upvar $me O
    foreach {option value} $args {
      set O($option) $value
      if {$option eq "-header"} {ConfigureHeader $me}
      if {$option eq "-encoding"} {ConfigureEncoding $me}
      if {$option eq "-mimetype"} {ConfigureMimetype $me}
    }
  }

  proc cget {me option} {
    upvar $me O
    return $O($option)
  }

  proc data {me} {
    upvar $me O
    set raw [string range $O(myRaw) 0 [expr {$O(myRawPos)-1}]]
    if {$O(myIsText)} {
      return [::encoding convertfrom [encoding $me] $raw]
    }
    return $raw
................................................................................
    lappend O(myFinishHookList) $script
  }

  # This method is called each time the -header option is set. This
  # is where the locally handled HTTP headers (see comments above the
  # -header option) are handled.
  #
  proc ConfigureHeader {me} {
    upvar $me O
    foreach {name value} $O(-header) {
      switch -- [string tolower $name] {
        set-cookie {
          catch {
            ::hv3::the_cookie_manager SetCookie $O(-uri) $value
          }
................................................................................
        content-length {
          set O(-expectedsize) $value
        }
      }
    }
  }

  proc ConfigureMimetype {me} {
    upvar $me O
    set O(myIsText) [string match text* $O(-mimetype)]
  }

  proc ConfigureEncoding {me} {
    upvar $me O
    set O(-encoding) [::hv3::encoding_resolve $O(-encoding)]
  }

  # Return the "authority" part of the URI configured as the -uri option.
  #
  proc authority {me} {
................................................................................
    upvar $me O
    set ret $O(-encoding)
    if {$ret eq ""} {set ret [::encoding system]}
    return $ret
  }
}

::hv3::namespace_to_constructor ::hv3::request

|







 







|
|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|







 







|




|







 







|

1
2
3
4
5
6
7
8
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
192
193
194
195
196
197
198















199
200
201
202
203
204
205
...
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
...
346
347
348
349
350
351
352
353
354
namespace eval hv3 { set {version($Id: hv3_request.tcl,v 1.24 2008/01/20 05:59:13 danielk1977 Exp $)} 1 }

#--------------------------------------------------------------------------
# This file contains the implementation of two types used by hv3:
#
#     ::hv3::request
#

................................................................................

    # The protocol implementation sets this option to contain the 
    # HTTP header (or it's equivalent). The format is a serialised array.
    # Example:
    # 
    #     {Set-Cookie safe-search=on Location http://www.google.com}
    #
    # The following http-header types are handled locally by the 
    # configure-header method, as soon as the -header option is set:
    #
    #     Set-Cookie         (Call ::hv3::the_cookie_manager method)
    #     Content-Type       (Set the -mimetype option)
    #     Content-Length     (Set the -expectedsize option)
    #
    set O(-header) ""
  
................................................................................
  proc destroy {me} {
    upvar $me O
    foreach hook $O(myFinishHookList) { eval $hook }
    rename $me {}
    array unset $me
  }
















  proc data {me} {
    upvar $me O
    set raw [string range $O(myRaw) 0 [expr {$O(myRawPos)-1}]]
    if {$O(myIsText)} {
      return [::encoding convertfrom [encoding $me] $raw]
    }
    return $raw
................................................................................
    lappend O(myFinishHookList) $script
  }

  # This method is called each time the -header option is set. This
  # is where the locally handled HTTP headers (see comments above the
  # -header option) are handled.
  #
  proc configure-header {me} {
    upvar $me O
    foreach {name value} $O(-header) {
      switch -- [string tolower $name] {
        set-cookie {
          catch {
            ::hv3::the_cookie_manager SetCookie $O(-uri) $value
          }
................................................................................
        content-length {
          set O(-expectedsize) $value
        }
      }
    }
  }

  proc configure-mimetype {me} {
    upvar $me O
    set O(myIsText) [string match text* $O(-mimetype)]
  }

  proc configure-encoding {me} {
    upvar $me O
    set O(-encoding) [::hv3::encoding_resolve $O(-encoding)]
  }

  # Return the "authority" part of the URI configured as the -uri option.
  #
  proc authority {me} {
................................................................................
    upvar $me O
    set ret $O(-encoding)
    if {$ret eq ""} {set ret [::encoding system]}
    return $ret
  }
}

::hv3::make_constructor ::hv3::request

Changes to hv/hv3_util.tcl.

1
2
3
4
5
6
7
8
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
...
418
419
420
421
422
423
424



















































namespace eval hv3 { set {version($Id: hv3_util.tcl,v 1.3 2008/01/19 05:59:31 danielk1977 Exp $)} 1 }


namespace eval hv3 {
  proc scrollbar {args} {
    set w [eval [linsert $args 0 ::scrollbar]]
    $w configure -highlightthickness 0
    $w configure -borderwidth 1
................................................................................
  #
  #     ::hv3::scrolled canvas .c -width 400 -height 400
  #
  proc scrolled {widget name args} {
    return [eval [concat ::hv3::scrolledwidget $name $widget $args]]
  }

  proc namespace_to_constructor {ns} {
    proc $ns {obj args} [string map [list %NS% $ns] {
      if {$obj eq "%AUTO%"} {
        set obj %NS%::inst[incr %NS%::_OBJ_COUNTER]
      }

      if {[info commands real_proc] ne ""} {
        real_proc $obj {m args} "namespace eval %NS% \$m $obj \$args"
      } else {
        proc $obj {m args} "namespace eval %NS% \$m $obj \$args"
      }

      eval %NS%::new $obj $args
      return $obj
    }]
  }

}

namespace eval ::hv3::string {

  # A generic tokeniser procedure for strings. This proc splits the
  # input string $input into a list of tokens, where each token is either:
................................................................................
    }
  }

  $html configure -defaultstyle $defstyle -mode $mode

  return $mode
}



















































|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
...
134
135
136
137
138
139
140
















141
142
143
144
145
146
147
...
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
namespace eval hv3 { set {version($Id: hv3_util.tcl,v 1.4 2008/01/20 05:59:13 danielk1977 Exp $)} 1 }


namespace eval hv3 {
  proc scrollbar {args} {
    set w [eval [linsert $args 0 ::scrollbar]]
    $w configure -highlightthickness 0
    $w configure -borderwidth 1
................................................................................
  #
  #     ::hv3::scrolled canvas .c -width 400 -height 400
  #
  proc scrolled {widget name args} {
    return [eval [concat ::hv3::scrolledwidget $name $widget $args]]
  }


















}

namespace eval ::hv3::string {

  # A generic tokeniser procedure for strings. This proc splits the
  # input string $input into a list of tokens, where each token is either:
................................................................................
    }
  }

  $html configure -defaultstyle $defstyle -mode $mode

  return $mode
}

namespace eval ::hv3 {
  proc construct_object {ns obj arglist} {
    if {$obj eq "%AUTO%"} {
      set obj ${ns}::inst[incr ${ns}::_OBJ_COUNTER]
    }

    if {[info commands real_proc] ne ""} {
      real_proc $obj {m args} "namespace eval $ns \$m $obj \$args"
    } else {
      proc $obj {m args} "namespace eval $ns \$m $obj \$args"
    }

    namespace eval $ns new $obj $arglist
    return $obj
  }

  proc make_constructor {ns} {

    # Create the constructor
    #
    proc $ns {obj args} "::hv3::construct_object $ns \$obj \$args"

    # Create the [cget] method.
    #
    namespace eval $ns "
      proc cget {me option} {
        upvar \$me O
        return \$O(\$option)
      }
    "
    # Create the [configure] method.
    #
    set cc ""
    foreach cmd [info commands ${ns}::configure*] {
      set key [string range $cmd [string length ${ns}::configure] end]
      append cc "if {\$option eq {$key}} {configure$key \$me}\n"
    }
    namespace eval $ns "
      proc configure {me args} {
        upvar \$me O
        foreach {option value} \$args {
          if {!\[info exists O(\$option)\]} {error \"unknown option: \$option\"}
          set O(\$option) \$value
          $cc
        }
      }
    "
  }
}