--- a/TextView.st Thu Apr 29 22:07:39 1999 +0200
+++ b/TextView.st Mon May 03 15:29:27 1999 +0200
@@ -1044,9 +1044,9 @@
keyPress:key x:x y:y
"handle some keyboard input (there is not much to be done here)"
- <resource: #keyboard (#Find #Copy #FindNext #FindPrev
- #GotoLine #SelectAll #SaveAs #Print
- #'F*' #'f*' )>
+ <resource: #keyboard (#Find #Copy #FindNext #FindPrev #FindAgain
+ #GotoLine #SelectAll #SaveAs #Print
+ #'F*' #'f*' )>
(key == #Find) ifTrue:[self search. ^self].
(key == #Copy) ifTrue:[self copySelection. ^self].
@@ -1054,6 +1054,7 @@
(key == #FindNext) ifTrue:[self searchFwd. ^self].
(key == #FindPrev) ifTrue:[self searchBwd. ^self].
+ (key == #FindAgain) ifTrue:[self searchAgainInSameDirection. ^self].
(key == #SelectAll) ifTrue:[self selectAll. ^self].
@@ -1068,22 +1069,22 @@
(see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y)
"
(key size > 1 and:[(key at:1) asLowercase == $f]) ifTrue:[
- (('[fF][0-9]' match:key)
- or:['[fF][0-9][0-9]' match:key]) ifTrue:[
- self sensor shiftDown ifTrue:[
- (Smalltalk at:#FunctionKeySequences) isNil ifTrue:[
- Smalltalk at:#FunctionKeySequences put:Dictionary new
- ].
- (Smalltalk at:#FunctionKeySequences) at:key put:(self selection)
- ].
- ^ self
- ].
+ (('[fF][0-9]' match:key)
+ or:['[fF][0-9][0-9]' match:key]) ifTrue:[
+ self sensor shiftDown ifTrue:[
+ (Smalltalk at:#FunctionKeySequences) isNil ifTrue:[
+ Smalltalk at:#FunctionKeySequences put:Dictionary new
+ ].
+ (Smalltalk at:#FunctionKeySequences) at:key put:(self selection)
+ ].
+ ^ self
+ ].
].
super keyPress:key x:x y:y
- "Modified: 2.4.1997 / 16:48:26 / cg"
- "Modified: 18.4.1997 / 12:12:27 / stefan"
+ "Modified: / 18.4.1997 / 12:12:27 / stefan"
+ "Modified: / 3.5.1999 / 15:03:16 / cg"
!
mapped
@@ -1432,12 +1433,12 @@
"/ searchBox addButton:(Button label:(resources at:'all'));
lastSearchPattern notNil ifTrue:[
- stringHolder value:lastSearchPattern
+ stringHolder value:lastSearchPattern
].
self hasSelection ifTrue:[
- selectionStartLine == selectionEndLine ifTrue:[
- stringHolder value:self selection
- ]
+ selectionStartLine == selectionEndLine ifTrue:[
+ stringHolder value:self selection
+ ]
].
patternField selectAll.
@@ -1445,28 +1446,30 @@
searchBox open.
searchBox accepted ifTrue:[
- pattern := stringHolder value.
- pattern := pattern string withoutSeparators. "/ is that a good idea ?
- pattern notEmpty ifTrue:[
- LastSearchPatterns isNil ifTrue:[
- LastSearchPatterns := OrderedCollection new.
- ].
- (LastSearchPatterns includes:pattern) ifTrue:[
- LastSearchPatterns remove:pattern.
- ] ifFalse:[
- LastSearchPatterns size > 10 ifTrue:[
- LastSearchPatterns removeFirst
- ]
- ].
- LastSearchPatterns addFirst:pattern.
-
- ign := caseHolder value.
- fwd ifFalse:[
- self searchBwd:pattern ignoreCase:ign.
- ] ifTrue:[
- self searchFwd:pattern ignoreCase:ign.
- ]
- ]
+ pattern := stringHolder value.
+ pattern := pattern string withoutSeparators. "/ is that a good idea ?
+ pattern notEmpty ifTrue:[
+ LastSearchPatterns isNil ifTrue:[
+ LastSearchPatterns := OrderedCollection new.
+ ].
+ (LastSearchPatterns includes:pattern) ifTrue:[
+ LastSearchPatterns remove:pattern.
+ ] ifFalse:[
+ LastSearchPatterns size > 10 ifTrue:[
+ LastSearchPatterns removeFirst
+ ]
+ ].
+ LastSearchPatterns addFirst:pattern.
+
+ ign := caseHolder value.
+ fwd ifFalse:[
+ lastSearchDirection := #backward.
+ self searchBwd:pattern ignoreCase:ign.
+ ] ifTrue:[
+ lastSearchDirection := #forward.
+ self searchFwd:pattern ignoreCase:ign.
+ ]
+ ]
].
"/ searchBox :=
@@ -1488,7 +1491,7 @@
"/ ].
"/ searchBox showAtPointer
- "Modified: / 17.9.1998 / 16:01:32 / cg"
+ "Modified: / 3.5.1999 / 15:01:09 / cg"
! !
!TextView methodsFor:'private'!
@@ -2086,6 +2089,30 @@
"Created: 11.9.1997 / 04:36:29 / cg"
!
+searchAgainInSameDirection
+ "search again in the same direction and -if found- position cursor"
+
+ |ign|
+
+ ign := lastSearchIgnoredCase ? false.
+
+ self setSearchPattern.
+ lastSearchPattern notNil ifTrue:[
+ lastSearchDirection == #backward ifTrue:[
+ self
+ searchBwd:lastSearchPattern
+ ignoreCase:ign
+ ] ifFalse:[
+ self
+ searchFwd:lastSearchPattern
+ ignoreCase:ign
+ ]
+ ]
+
+ "Modified: / 3.5.1999 / 15:00:28 / cg"
+ "Created: / 3.5.1999 / 15:02:16 / cg"
+!
+
searchBwd
"search backward and -if found- position cursor"
@@ -2095,12 +2122,13 @@
self setSearchPattern.
lastSearchPattern notNil ifTrue:[
- self
- searchBwd:lastSearchPattern
- ignoreCase:ign
+ lastSearchDirection := #backward.
+ self
+ searchBwd:lastSearchPattern
+ ignoreCase:ign
]
- "Modified: 13.9.1997 / 06:24:35 / cg"
+ "Modified: / 3.5.1999 / 15:00:28 / cg"
!
searchBwd:pattern
@@ -2351,21 +2379,22 @@
ign := lastSearchIgnoredCase ? false.
selectStyle == #wordLeft ifTrue:[
- "
- remove the space from the selection
- "
- selectionStartCol := selectionStartCol + 1.
- super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1.
- selectStyle := #word.
+ "
+ remove the space from the selection
+ "
+ selectionStartCol := selectionStartCol + 1.
+ super redrawLine:selectionStartLine from:selectionStartCol-1 to:selectionStartCol-1.
+ selectStyle := #word.
].
self setSearchPattern.
lastSearchPattern notNil ifTrue:[
- self
- searchFwd:lastSearchPattern
- ignoreCase:ign
+ lastSearchDirection := #forward.
+ self
+ searchFwd:lastSearchPattern
+ ignoreCase:ign
]
- "Modified: 13.9.1997 / 06:24:26 / cg"
+ "Modified: / 3.5.1999 / 15:00:40 / cg"
!
searchFwd:pattern
@@ -2926,5 +2955,5 @@
!TextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.134 1999-04-21 10:34:56 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.135 1999-05-03 13:29:27 cg Exp $'
! !