--- a/TextView.st Sat May 07 06:52:44 2016 +0200
+++ b/TextView.st Mon May 09 21:43:19 2016 +0200
@@ -3647,10 +3647,12 @@
startCol := pos x.
self
- searchBackwardUsingSpec:searchSpec
- startingAtLine:startLine col:startCol
- ifFound:[:line :col | self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col]
- ifAbsent:aBlock
+ searchBackwardUsingSpec:searchSpec
+ startingAtLine:startLine col:startCol
+ ifFound:[:line :col :endColOrNil|
+ self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col endCol:endColOrNil
+ ]
+ ifAbsent:aBlock
!
searchForAndSelectMatchingParenthesisFromLine:startLine col:startCol
@@ -4390,8 +4392,8 @@
self
searchForwardUsingSpec:searchSpec
startingAtLine:startLine col:startCol
- ifFound:[:line :col |
- self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col
+ ifFound:[:line :col :endColOrNil|
+ self showMatch:searchSpec pattern isMatch:searchSpec match atLine:line col:col endCol:endColOrNil
]
ifAbsent:aBlock
!
@@ -4403,33 +4405,41 @@
!
searchUsingSearchAction:direction
+ "search using a searchaction which has been given by someone else.
+ Typically, this is the embedding browser, which has provided an action for
+ a language aware search (as opposed to a naive string search)"
+
self
- searchUsingSearchAction:direction
- ifAbsent:[
- self sensor compressKeyPressEventsWithKey:#FindNext.
- self showNotFound
- ]
+ searchUsingSearchAction:direction
+ ifAbsent:[
+ self sensor compressKeyPressEventsWithKey:#FindNext.
+ self showNotFound
+ ]
!
searchUsingSearchAction:direction ifAbsent:notFoundAction
+ "search using a searchaction which has been given by someone else.
+ Typically, this is the embedding browser, which has provided an action for
+ a language aware search (as opposed to a naive string search)"
+
|pos startLine startCol|
pos := direction == #backward
- ifTrue:[self startPositionForSearchBackward]
- ifFalse:[self startPositionForSearchForward].
+ ifTrue:[self startPositionForSearchBackward]
+ ifFalse:[self startPositionForSearchForward].
startLine := pos y.
startCol := pos x.
searchAction notNil ifTrue:[
- searchAction
- value:direction
- value:startLine
- value:startCol
- value:[:line :col | self selectFromLine:line toLine:line]
- value:notFoundAction.
- self hasSelection ifTrue: [
- self changeTypeOfSelectionTo: #searchAction.
- ].
+ searchAction
+ value:direction
+ value:startLine
+ value:startCol
+ value:[:line :col | self selectFromLine:line toLine:line]
+ value:notFoundAction.
+ self hasSelection ifTrue: [
+ self changeTypeOfSelectionTo: #searchAction.
+ ].
].
!
@@ -4459,6 +4469,14 @@
lastSearchIgnoredCase := aBoolean.
!
+setSearchPattern:aString ignoreCase:ignoreCaseBoolean match:matchBoolean
+ "set the searchpattern and caseIgnore for future searches"
+
+ self setSearchPattern:aString.
+ lastSearchIgnoredCase := ignoreCaseBoolean.
+ lastSearchWasMatch := matchBoolean.
+!
+
setSearchPatternWithMatchEscapes: match
"set the searchpattern from the selection if there is one"
@@ -4477,33 +4495,43 @@
!
showMatch:pattern atLine:line col:col
+ <resource: #obsolete>
"after a search, highlight the matched pattern.
The code below needs a rewrite to take care of match-characters
(for now, it only highlights simple patterns and '*string*' correctly)"
- self showMatch:pattern isMatch:true atLine:line col:col
+ self showMatch:pattern isMatch:true atLine:line col:col endCol:nil
!
showMatch:pattern isMatch:isMatch atLine:line col:col
+ <resource: #obsolete>
+ "after a search, highlight the matched pattern."
+
+ self showMatch:pattern isMatch:isMatch atLine:line col:col endCol:nil
+!
+
+showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil
"after a search, highlight the matched pattern.
The code below needs a rewrite to take care of match-characters
(for now, it only highlights simple patterns and '*string*' correctly)"
- |realPattern|
-
- realPattern := pattern.
-
- isMatch ifTrue: [
- (realPattern startsWith:$*) ifTrue:[
- realPattern := realPattern copyButFirst
- ].
- (realPattern endsWith:$*) ifTrue:[
- realPattern := realPattern copyButLast
- ].
+ |endCol realPattern|
+
+ (endCol := encColOrNil) isNil ifTrue:[
+ "/ a hack.
+ realPattern := pattern.
+ isMatch ifTrue: [
+ (realPattern startsWith:$*) ifTrue:[
+ realPattern := realPattern copyButFirst
+ ].
+ (realPattern endsWith:$*) ifTrue:[
+ realPattern := realPattern copyButLast
+ ].
+ ].
+ endCol := (col + realPattern size - 1).
].
- self selectFromLine:line col:col
- toLine:line col:(col + realPattern size - 1).
+ self selectFromLine:line col:col toLine:line col:endCol.
self makeLineVisible:line
!