Tk Library Source Code

Artifact [998e727bf3]
Login

Artifact 998e727bf30d90757f1005c25ee628d55676edf4:

Attachment "bwidget-tree-lsearch-exact.patch" to ticket [722192ffff] added by jenglish 2003-04-16 07:24:09.
Index: tree.tcl
===================================================================
RCS file: /cvsroot/tcllib/bwidget/tree.tcl,v
retrieving revision 1.41
diff -u -r1.41 tree.tcl
--- tree.tcl	13 Mar 2003 06:59:59 -0000	1.41
+++ tree.tcl	15 Apr 2003 23:57:48 -0000
@@ -359,7 +359,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
@@ -425,7 +425,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]
 	    }
@@ -458,7 +458,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"] } {
@@ -530,7 +530,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
 		    }
 		}
@@ -546,7 +546,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
 		    }
 		}
@@ -615,7 +615,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]
                 }
             }
@@ -642,7 +642,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
@@ -709,7 +709,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}]
 }
 
 
@@ -1103,7 +1103,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]
 	    }
@@ -1218,7 +1218,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
     }
 
     if { [set win [Widget::getoption $path.$node -window]] != "" } {
@@ -1325,7 +1325,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
                 }
@@ -1417,7 +1417,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
         }
@@ -1601,7 +1601,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 - $deltax - 5}]
                         }
                         set yl $ys
@@ -1609,7 +1609,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 - $deltax - 5}]
                         set yl     $yi
                     }
@@ -1796,7 +1796,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]
@@ -1814,7 +1814,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]
@@ -1832,7 +1832,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]