Tk Library Source Code

Artifact [914b59ec23]
Login

Artifact 914b59ec23e193669ea7c18f462ff67c4708d10e:

Attachment "patch.hilite_all" to ticket [627521ffff] added by pascalscheffers 2003-03-10 22:38:42.
--- tkchat.tcl	Mon Mar 10 16:21:50 2003
+++ tkchat.tcl.hilite-all	Mon Mar 10 16:23:11 2003
@@ -1823,7 +1823,41 @@
 	    set marks [.txt tag ranges found]
 	    for { set i 0 } { $i < [llength $marks] } { incr i 2 } {
 		.txt tag remove found [lindex $marks $i] [lindex $marks [expr $i+1]]
-	    }		    
+	    }
+
+	    set offset end
+	    set foundAt [.txt search -count foundLength \
+			 -regexp \
+			 -backwards \
+			 -nocase -- \
+			 $::tkchat::searchString \
+			 $offset 0.0]	    
+
+	    while { ![string equal $foundAt ""] } {
+		#puts "Found at $foundAt"
+		#yes, the expression was found
+
+		set foundLine [lindex [split $foundAt .] 0]
+		set foundChar [lindex [split $foundAt .] 1]
+
+		.txt tag add found $foundAt \
+		    "$foundLine.[expr $foundChar + $foundLength]"
+
+		if { $foundChar == 0 } {
+		    #decrement line no, not char pos.
+		    set offset "[expr $foundLine -1].99999"
+		} else {
+		    #decrement char pos:
+		    set offset "$foundLine.[expr $foundChar - 1]"
+		}
+
+		set foundAt [.txt search -count foundLength \
+				 -regexp \
+				 -backwards \
+				 -nocase -- \
+				 $::tkchat::searchString \
+				 $offset 0.0]	    
+	    }	    
 	    
 	}
     }
@@ -1843,10 +1877,7 @@
 
 	    set foundLine [lindex [split $foundAt .] 0]
 	    set foundChar [lindex [split $foundAt .] 1]
-
-	    .txt tag add found $foundAt \
-		"$foundLine.[expr $foundChar + $foundLength]"
-
+	    
 	    .txt see $foundAt
 	    
 	    #figure out the previous character: