diff options
author | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
---|---|---|
committer | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
commit | 48c9fcb7281cc6aa076113db874c7ae0e105795d (patch) | |
tree | 7187940ff056462bfa41705a2ce04d0ed07d424e /library/listbox.tcl | |
parent | 41f5d19540b0b3f053da352e1569c9a4ed019dd5 (diff) | |
download | tk-contrib_patrick_fradin_code_cleanup.zip tk-contrib_patrick_fradin_code_cleanup.tar.gz tk-contrib_patrick_fradin_code_cleanup.tar.bz2 |
Contribution by Patrick Fradin <patrick.fradin@planar.com>contrib_patrick_fradin_code_cleanup
Quoting his mail:
<pre>
==========================================================
Hi Jeff,
I spent some of my time to contribute to the TclTk community ! I'm in
late for Christmas gift but like we said in French : "Mieux vaut tard
que jamais". ;-)
I've use TclDevKit 5.3.0 tclchecker to analyse TclTk code in Tcl and
Tk library directories (library, tools and tests) to correct a lot of
warnings and few errors. (encapsulate some expr, use 'chan xxx'
instead of fconfigure, fileevent...)
I've made some improvements too :
Examples :
- Use 'lassign' instead of many 'lindex' of 'foreach/break' loop.
- Use 'in' or 'ni' operators instead of 'lsearch -exact' or to
factorise some eq/ne && / || tests.
- Use 'eq' or 'ne' to tests strings instead of '==' or '!='.
- Use 'unset -nocomplain' to avoid 'catch {unset...}'.
- Remove some useless catch around 'destroy' calls.
- Use expand {*} instead of 'eval'. Don't touch a lot of code because
I don't know all structs and lists. I think it could be a greater
improvement to reduce 'eval' calls.
Due to previous experience, I dot not change any indentation ! ;-)
==========================================================
</pre>
Diffstat (limited to 'library/listbox.tcl')
-rw-r--r-- | library/listbox.tcl | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/library/listbox.tcl b/library/listbox.tcl index 01fb03d..fe446bf 100644 --- a/library/listbox.tcl +++ b/library/listbox.tcl @@ -250,12 +250,12 @@ proc ::tk::ListboxBeginSelect {w el {focus 1}} { $w selection clear 0 end $w selection set $el $w selection anchor $el - set Priv(listboxSelection) {} + set Priv(listboxSelection) "" set Priv(listboxPrev) $el } event generate $w <<ListboxSelect>> # check existence as ListboxSelect may destroy us - if {$focus && [winfo exists $w] && [$w cget -state] eq "normal"} { + if {$focus && [winfo exists $w] && ([$w cget -state] eq "normal")} { focus $w } } @@ -276,7 +276,7 @@ proc ::tk::ListboxMotion {w el} { return } set anchor [$w index anchor] - switch [$w cget -selectmode] { + switch -- [$w cget -selectmode] { browse { $w selection clear 0 end $w selection set $el @@ -314,6 +314,7 @@ proc ::tk::ListboxMotion {w el} { set Priv(listboxPrev) $el event generate $w <<ListboxSelect>> } + default {} } } @@ -411,7 +412,7 @@ proc ::tk::ListboxUpDown {w amount} { variable ::tk::Priv $w activate [expr {[$w index active] + $amount}] $w see active - switch [$w cget -selectmode] { + switch -- [$w cget -selectmode] { browse { $w selection clear 0 end $w selection set active @@ -422,9 +423,10 @@ proc ::tk::ListboxUpDown {w amount} { $w selection set active $w selection anchor active set Priv(listboxPrev) [$w index active] - set Priv(listboxSelection) {} + set Priv(listboxSelection) "" event generate $w <<ListboxSelect>> } + default {} } } @@ -488,7 +490,7 @@ proc ::tk::ListboxDataExtend {w el} { # Arguments: # w - The listbox widget. -proc ::tk::ListboxCancel w { +proc ::tk::ListboxCancel {w} { variable ::tk::Priv if {[$w cget -selectmode] ne "extended"} { return @@ -523,9 +525,9 @@ proc ::tk::ListboxCancel w { # Arguments: # w - The listbox widget. -proc ::tk::ListboxSelectAll w { +proc ::tk::ListboxSelectAll {w} { set mode [$w cget -selectmode] - if {$mode eq "single" || $mode eq "browse"} { + if {$mode in "single browse"} { $w selection clear 0 end $w selection set active } else { |