ListView.st
changeset 403 ee8f6d080077
parent 394 795f293f8520
child 407 998d3f5c4690
--- a/ListView.st	Mon Feb 26 20:06:17 1996 +0100
+++ b/ListView.st	Mon Feb 26 22:42:02 1996 +0100
@@ -2516,59 +2516,57 @@
      found evaluate block2.
      Sorry, but pattern is no regular expression pattern (yet)"
 
-    |lineString col cc found firstChar savedCursor patternSize 
+    |lineString col cc found firstChar patternSize 
      line1 "{Class: SmallInteger}"|
 
     patternSize := pattern size.
     (list notNil and:[patternSize ~~ 0]) ifTrue:[
-        savedCursor := cursor.
-        self cursor:(Cursor questionMark).
-"/        searchPattern := pattern.
-        col := startCol - 1.
-        firstChar := pattern at:1.
-        col > (list at:startLine) size ifTrue:[
-            col := nil
-        ].
-        line1 := startLine.
-        line1 to:1 by:-1 do:[:lnr |
-            lineString := list at:lnr.
-            lineString notNil ifTrue:[
-                col isNil ifTrue:[col := lineString size - patternSize + 1].
-                [(col > 0) and:[(lineString at:col) ~= firstChar]] whileTrue:[
-                    col := col - 1
-                ].
-                [col > 0] whileTrue:[
-                    cc := col.
-                    found := true.
-                    1 to:patternSize do:[:cnr |
-                        cc > lineString size ifTrue:[
-                            found := false
-                        ] ifFalse:[
-                            (pattern at:cnr) ~= (lineString at:cc) ifTrue:[
-                                found := false
-                            ]
-                        ].
-                        cc := cc + 1
-                    ].
-                    found ifTrue:[
-                        self cursor:savedCursor.
-                        ^ block1 value:lnr value:col.
-                    ].
-                    col := col - 1.
+        self withCursor:Cursor questionMark do:[
+"/            searchPattern := pattern.
+            col := startCol - 1.
+            firstChar := pattern at:1.
+            col > (list at:startLine) size ifTrue:[
+                col := nil
+            ].
+            line1 := startLine.
+            line1 to:1 by:-1 do:[:lnr |
+                lineString := list at:lnr.
+                lineString notNil ifTrue:[
+                    col isNil ifTrue:[col := lineString size - patternSize + 1].
                     [(col > 0) and:[(lineString at:col) ~= firstChar]] whileTrue:[
                         col := col - 1
+                    ].
+                    [col > 0] whileTrue:[
+                        cc := col.
+                        found := true.
+                        1 to:patternSize do:[:cnr |
+                            cc > lineString size ifTrue:[
+                                found := false
+                            ] ifFalse:[
+                                (pattern at:cnr) ~= (lineString at:cc) ifTrue:[
+                                    found := false
+                                ]
+                            ].
+                            cc := cc + 1
+                        ].
+                        found ifTrue:[
+                            ^ block1 value:lnr value:col.
+                        ].
+                        col := col - 1.
+                        [(col > 0) and:[(lineString at:col) ~= firstChar]] whileTrue:[
+                            col := col - 1
+                        ]
                     ]
-                ]
-            ].
-            col := nil
+                ].
+                col := nil
+            ]
         ]
     ].
     "not found"
 
-    self cursor:savedCursor.
     ^ block2 value
 
-    "Modified: 23.2.1996 / 19:12:40 / cg"
+    "Modified: 26.2.1996 / 22:40:29 / cg"
 !
 
 searchForwardFor:pattern startingAtLine:startLine col:startCol ifFound:block1 ifAbsent:block2
@@ -2576,66 +2574,65 @@
      found evaluate block2.
      Sorry, but pattern is no regular expression pattern (yet)"
 
-    |lineString col savedCursor patternSize 
+    |lineString col patternSize 
      line1 "{Class: SmallInteger}"
      line2 "{Class: SmallInteger}"
      p realPattern|
 
     patternSize := pattern size.
     (list notNil and:[patternSize ~~ 0]) ifTrue:[
-	savedCursor := cursor.
-	self cursor:(Cursor questionMark).
-
-	col := startCol + 1.
-	line1 := startLine.
-	line2 := list size.
-
-	pattern includesMatchCharacters ifTrue:[
-	    p := ''.
-	    (pattern startsWith:$*) ifFalse:[
-		p := p , '*'
-	    ].
-	    p := p , pattern.
-	    (pattern endsWith:$*) ifFalse:[
-		p := p , '*'
-	    ].
-	    realPattern := pattern.
-	    (realPattern startsWith:$*) ifTrue:[
-		realPattern := realPattern copyFrom:2
-	    ].
-	    line1 to:line2 do:[:lnr |
-		lineString := list at:lnr.
-		lineString notNil ifTrue:[
-		    "/ first a crude check ...
-		    (p match:lineString) ifTrue:[
-			"/ ok, there it is; look at which position
-			col := lineString findMatchString:realPattern startingAt:col ignoreCase:false ifAbsent:[0].
-			col ~~ 0 ifTrue:[
-			    self cursor:savedCursor.
-			    ^ block1 value:lnr value:col.
-			]
-		    ].
-		].
-		col := 1
-	    ]
-	] ifFalse:[
-	    line1 to:line2 do:[:lnr |
-		lineString := list at:lnr.
-		lineString isString ifTrue:[
-		    col := lineString findString:pattern startingAt:col ifAbsent:[0].
-		    col ~~ 0 ifTrue:[
-			self cursor:savedCursor.
-			^ block1 value:lnr value:col.
-		    ]
-		].
-		col := 1
-	    ]
-	]
+        self withCursor:Cursor questionMark do:[
+
+            col := startCol + 1.
+            line1 := startLine.
+            line2 := list size.
+
+            pattern includesMatchCharacters ifTrue:[
+                p := pattern species new:0.
+                (pattern startsWith:$*) ifFalse:[
+                    p := p , '*'
+                ].
+                p := p , pattern.
+                (pattern endsWith:$*) ifFalse:[
+                    p := p , '*'
+                ].
+                realPattern := pattern.
+                (realPattern startsWith:$*) ifTrue:[
+                    realPattern := realPattern copyFrom:2
+                ].
+                line1 to:line2 do:[:lnr |
+                    lineString := list at:lnr.
+                    lineString notNil ifTrue:[
+                        "/ first a crude check ...
+                        (p match:lineString) ifTrue:[
+                            "/ ok, there it is; look at which position
+                            col := lineString findMatchString:realPattern startingAt:col ignoreCase:false ifAbsent:[0].
+                            col ~~ 0 ifTrue:[
+                                ^ block1 value:lnr value:col.
+                            ]
+                        ].
+                    ].
+                    col := 1
+                ]
+            ] ifFalse:[
+                line1 to:line2 do:[:lnr |
+                    lineString := list at:lnr.
+                    lineString isString ifTrue:[
+                        col := lineString findString:pattern startingAt:col ifAbsent:[0].
+                        col ~~ 0 ifTrue:[
+                            ^ block1 value:lnr value:col.
+                        ]
+                    ].
+                    col := 1
+                ]
+            ].
+        ]
     ].
     "not found"
 
-    self cursor:savedCursor.
     ^ block2 value
+
+    "Modified: 26.2.1996 / 22:39:59 / cg"
 ! !
 
 !ListView methodsFor:'tabulators'!
@@ -2831,5 +2828,5 @@
 !ListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.67 1996-02-24 17:19:17 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.68 1996-02-26 21:42:02 cg Exp $'
 ! !