From a6d60ba430fef31022994d5f0f4113ffaac567bd Mon Sep 17 00:00:00 2001 From: treectrl Date: Sun, 19 Nov 2006 00:49:36 +0000 Subject: Defined TreeCtrl::lassign if ::lassign doesn't exist and use it instead of the classic foreach hack. --- library/filelist-bindings.tcl | 6 +++--- library/treectrl.tcl | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/library/filelist-bindings.tcl b/library/filelist-bindings.tcl index a15f5c4..4062b6e 100644 --- a/library/filelist-bindings.tcl +++ b/library/filelist-bindings.tcl @@ -1,4 +1,4 @@ -# RCS: @(#) $Id: filelist-bindings.tcl,v 1.25 2006/11/05 06:43:28 treectrl Exp $ +# RCS: @(#) $Id: filelist-bindings.tcl,v 1.26 2006/11/19 00:49:36 treectrl Exp $ bind TreeCtrlFileList { TreeCtrl::FileListEditCancel %W @@ -88,7 +88,7 @@ proc ::TreeCtrl::IsSensitive {T x y} { if {[lindex $id 0] ne "item" || [llength $id] != 6} { return 0 } - foreach {where item arg1 arg2 arg3 arg4} $id {} + lassign $id where item arg1 arg2 arg3 arg4 if {![$T item enabled $item]} { return 0 } @@ -126,7 +126,7 @@ proc ::TreeCtrl::FileListButton1 {T x y} { # Click in item } else { - foreach {where item arg1 arg2 arg3 arg4} $id {} + lassign $id where item arg1 arg2 arg3 arg4 switch $arg1 { button - line { diff --git a/library/treectrl.tcl b/library/treectrl.tcl index 11cdb97..c401871 100644 --- a/library/treectrl.tcl +++ b/library/treectrl.tcl @@ -1,4 +1,4 @@ -# RCS: @(#) $Id: treectrl.tcl,v 1.34 2006/11/18 04:37:49 treectrl Exp $ +# RCS: @(#) $Id: treectrl.tcl,v 1.35 2006/11/19 00:49:36 treectrl Exp $ bind TreeCtrl { TreeCtrl::CursorCheck %W %x %y @@ -196,6 +196,13 @@ namespace eval ::TreeCtrl { array set Priv { prev {} } + + if {[info procs ::lassign] eq ""} { + proc lassign {values args} { + uplevel 1 [list foreach $args [linsert $values end {}] break] + lrange $values [llength $args] end + } + } } # Retrieve filelist bindings from this dir @@ -433,7 +440,7 @@ proc ::TreeCtrl::ButtonPress1 {w x y} { } if {[lindex $id 0] eq "item"} { - foreach {where item arg1 arg2} $id {} + lassign $id where item arg1 arg2 if {$arg1 eq "button"} { $w item toggle $item return @@ -503,7 +510,7 @@ proc ::TreeCtrl::DoubleButton1 {w x y} { return } if {[lindex $id 0] eq "item"} { - foreach {where item arg1 arg2} $id {} + lassign $id where item arg1 arg2 if {$arg1 eq "button"} { $w item toggle $item return -- cgit v0.12