EditTextView.st
changeset 3580 c9d10df2b8bc
parent 3578 9d43beca1e85
child 3583 fd5a924c8681
--- a/EditTextView.st	Fri Apr 04 17:31:31 2008 +0200
+++ b/EditTextView.st	Fri Apr 04 18:26:13 2008 +0200
@@ -6267,18 +6267,28 @@
     startLine := pos y.
     startCol := pos x.
 
+    self searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
+
+    "Modified: 9.10.1997 / 13:02:13 / cg"
+!
+
+searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
+    "do a backward search"
+
+    cursorLine isNil ifTrue:[^ self].
+
     self
-	searchBackwardFor:pattern
-	ignoreCase:ign
-	startingAtLine:startLine col:startCol
-	ifFound:[:line :col |
-	    self cursorMovementAllowed ifTrue:[
-		self cursorLine:line col:col.
-	    ].
-	    self showMatch:pattern atLine:line col:col.
+        searchBackwardFor:pattern
+        ignoreCase:ign
+        startingAtLine:startLine col:startCol
+        ifFound:[:line :col |
+            self cursorMovementAllowed ifTrue:[
+                self cursorLine:line col:col.
+            ].
+            self showMatch:pattern atLine:line col:col.
 "/            self makeLineVisible:cursorLine
-	    typeOfSelection := #search]
-	ifAbsent:aBlock
+            typeOfSelection := #search]
+        ifAbsent:aBlock
 
     "Modified: 9.10.1997 / 13:02:13 / cg"
 !
@@ -6597,6 +6607,30 @@
     self selectWordAtLine:cursorLine col:cursorCol
 !
 
+selectionForStringSearchTool
+
+    |sel searchPattern|
+
+    "/
+    "/ if there is a selection:
+    "/    if there was no previous search, take it as search pattern.
+    "/    if there was a previous search, only take the selection if
+    "/    it did not result from a paste.
+    "/    (to allow search-paste to be repeated)
+    "/
+
+    sel := self selection.
+    sel notNil ifTrue:[
+        typeOfSelection ~~ #search ifTrue:[
+            typeOfSelection ~~ #paste ifTrue:[
+                self cursorLine:selectionStartLine col:selectionStartCol.
+                searchPattern := sel asStringWithoutFinalCR.
+            ]
+        ]
+    ].
+    ^ searchPattern
+!
+
 unselect
     "forget and unhilight selection - must take care of cursor here"
 
@@ -7230,5 +7264,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.428 2008-04-02 11:58:41 fm Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.429 2008-04-04 16:26:13 fm Exp $'
 ! !