Tk Library Source Code

Artifact [86ef49f596]
Login

Artifact 86ef49f5967bbab51a8fb13357cd7fedacea3cd6:

Attachment "bwidget-tree-lsearch.patch" to ticket [628041ffff] added by jenglish 2003-01-29 06:34:19.
Index: tree.tcl
===================================================================
RCS file: /cvsroot/tcllib/bwidget/tree.tcl,v
retrieving revision 1.39
diff -u -r1.39 tree.tcl
--- tree.tcl	26 Jan 2003 10:55:31 -0000	1.39
+++ tree.tcl	28 Jan 2003 23:27:44 -0000
@@ -346,7 +346,7 @@
             }
         } 
 	if { $data(upd,level) < 3 && $flag } {
-            if { [set idx [lsearch $data(upd,nodes) $node]] == -1 } {
+            if { [set idx [lsearch -exact $data(upd,nodes) $node]] == -1 } {
                 lappend data(upd,nodes) $node $flag
             } else {
                 incr idx
@@ -412,7 +412,7 @@
 	foreach node $lnodes {
 	    if { [string compare $node "root"] && [info exists data($node)] } {
 		set parent [lindex $data($node) 0]
-		set idx	   [lsearch $data($parent) $node]
+		set idx	   [lsearch -exact $data($parent) $node]
 		set data($parent) [lreplace $data($parent) $idx $idx]
 		_subdelete $path [list $node]
 	    }
@@ -445,7 +445,7 @@
     }
 
     set oldp        [lindex $data($node) 0]
-    set idx         [lsearch $data($oldp) $node]
+    set idx         [lsearch -exact $data($oldp) $node]
     set data($oldp) [lreplace $data($oldp) $idx $idx]
     set data($node) [concat [list $parent] [lrange $data($node) 1 end]]
     if { ![string compare $index "end"] } {
@@ -517,7 +517,7 @@
             set data(selnodes) {}
             foreach node $args {
 		if { [Widget::getoption $path.$node -selectable] } {
-		    if { [lsearch $data(selnodes) $node] == -1 } {
+		    if { [lsearch -exact $data(selnodes) $node] == -1 } {
 			lappend data(selnodes) $node
 		    }
 		}
@@ -533,7 +533,7 @@
 	    }
             foreach node $args {
 		if { [Widget::getoption $path.$node -selectable] } {
-		    if { [lsearch $data(selnodes) $node] == -1 } {
+		    if { [lsearch -exact $data(selnodes) $node] == -1 } {
 			lappend data(selnodes) $node
 		    }
 		}
@@ -602,7 +602,7 @@
 	}
         remove {
             foreach node $args {
-                if { [set idx [lsearch $data(selnodes) $node]] != -1 } {
+                if { [set idx [lsearch -exact $data(selnodes) $node]] != -1 } {
                     set data(selnodes) [lreplace $data(selnodes) $idx $idx]
                 }
             }
@@ -629,7 +629,7 @@
 			"wrong#args: Expected $path selection includes node"
 	    }
 	    set node [lindex $args 0]
-            return [expr {[lsearch $data(selnodes) $node] != -1}]
+            return [expr {[lsearch -exact $data(selnodes) $node] != -1}]
         }
         default {
             return
@@ -696,7 +696,7 @@
         return -code error "node \"$node\" does not exist"
     }
     set parent [lindex $data($node) 0]
-    return [expr {[lsearch $data($parent) $node] - 1}]
+    return [expr {[lsearch -exact $data($parent) $node] - 1}]
 }
 
 
@@ -1089,7 +1089,7 @@
                 lappend lsubnodes $subnode
             }
             unset data($node)
-	    set idx [lsearch $sel $node]
+	    set idx [lsearch -exact $sel $node]
 	    if { $idx >= 0 } {
 		set sel [lreplace $sel $idx $idx]
 	    }
@@ -1184,7 +1184,7 @@
         -fill   [Widget::getoption $path.$node -fill] \
         -font   [Widget::getoption $path.$node -font] \
         -anchor w \
-        -tags   "TreeItemSentinal node n:$node"
+        -tags   [list TreeItemSentinal node n:$node]
     set len [expr {[llength $data($node)] > 1}]
     set dc  [Widget::getoption $path.$node -drawcross]
     set exp [Widget::getoption $path.$node -open]
@@ -1204,15 +1204,15 @@
             -bitmap     @$bmp \
             -background [$path.c cget -background] \
             -foreground [Widget::getoption $path -crossfill] \
-            -tags       "cross c:$node" -anchor c
+            -tags       [list cross c:$node] -anchor c
     }
 
     if { [set win [Widget::getoption $path.$node -window]] != "" } {
         $path.c create window $x1 $y0 -window $win -anchor w \
-		-tags "TreeItemSentinal win i:$node"
+		-tags [list TreeItemSentinal win i:$node]
     } elseif { [set img [Widget::getoption $path.$node -image]] != "" } {
         $path.c create image $x1 $y0 -image $img -anchor w \
-		-tags "TreeItemSentinal img i:$node"
+		-tags [list TreeItemSentinal img i:$node]
     }
     return $y1
 }
@@ -1269,7 +1269,7 @@
                 } else {
                     $path.c delete $idi
                     $path.c create window $x0 $y0 -window $win -anchor w \
-			    -tags "TreeItemSentinal win i:$node"
+			    -tags [list TreeItemSentinal win i:$node]
                 }
             } elseif { [string length $img] } {
                 if { ![string compare $type "img"] } {
@@ -1277,7 +1277,7 @@
                 } else {
                     $path.c delete $idi
                     $path.c create image $x0 $y0 -image $img -anchor w \
-			    -tags "TreeItemSentinal img i:$node"
+			    -tags [list TreeItemSentinal img i:$node]
                 }
             } else {
                 $path.c delete $idi
@@ -1302,7 +1302,7 @@
                         -bitmap     @$bmp \
                         -background [$path.c cget -background] \
                         -foreground [Widget::getoption $path -crossfill] \
-                        -tags       "cross c:$node" -anchor c
+                        -tags       [list cross c:$node] -anchor c
                 } else {
                     $path.c itemconfigure $idc -bitmap @$bmp
                 }
@@ -1394,7 +1394,7 @@
                 set bbox [list 0 [lindex $bbox 1] $xmax [lindex $bbox 3]]
             }
             set id [eval $path.c create rectangle $bbox \
-		    -fill $selbg -outline $selbg -tags [list "sel s:$node"]]
+		   -fill $selbg -outline $selbg -tags [list [list sel s:$node]]]
             $path.c itemconfigure "n:$node" -fill $selfg
             $path.c lower $id
         }
@@ -1576,7 +1576,7 @@
                             # $node is not open and doesn't have subnodes
                             # drop position is after $node in children of parent of $node
                             set parent [lindex $data($node) 0]
-                            set index  [lsearch $data($parent) $node]
+                            set index  [lsearch -exact $data($parent) $node]
                             set xli    [expr {$xi-[Widget::getoption $path -deltax]-5}]
                         }
                         set yl $ys
@@ -1584,7 +1584,7 @@
                         # position is before $node
                         # drop position is before $node in children of parent of $node
                         set parent [lindex $data($node) 0]
-                        set index  [expr {[lsearch $data($parent) $node] - 1}]
+                        set index  [expr {[lsearch -exact $data($parent) $node] - 1}]
                         set xli    [expr {$xi-[Widget::getoption $path -deltax]-5}]
                         set yl     $yi
                     }
@@ -1771,7 +1771,7 @@
 	    if { [string equal $node ""] } {
 		return
 	    }
-	    set index [lsearch $nodes $node]
+	    set index [lsearch -exact $nodes $node]
 	    incr index -1
 	    if { $index >= 0 } {
 		$win selection set [lindex $nodes $index]
@@ -1789,7 +1789,7 @@
 		return
 	    }
 
-	    set index [lsearch $nodes $node]
+	    set index [lsearch -exact $nodes $node]
 	    incr index
 	    if { $index < [llength $nodes] } {
 		$win selection set [lindex $nodes $index]
@@ -1807,7 +1807,7 @@
 	    set open [$win itemcget $node -open]
             if { $open } {
                 if { [llength [$win nodes $node]] } {
-		    set index [lsearch $nodes $node]
+		    set index [lsearch -exact $nodes $node]
 		    incr index
 		    if { $index < [llength $nodes] } {
 			$win selection set [lindex $nodes $index]