# HG changeset patch # User Claus Gittinger # Date 1462628934 -7200 # Node ID f2d5d5d5d4d614b167b8bd309334a9bae48f5d05 # Parent 8baebc416a383e18f76e82fa3e9090b9f6259dac #OTHER by cg class: TextView fix: selecting the search result of a pattern search added: #showMatch:isMatch:atLine:col:endCol: changed: #searchBwdUsingSpec:ifAbsent: #searchFwdUsingSpec:startingAtLine:col:ifAbsent: #showMatch:atLine:col: #showMatch:isMatch:atLine:col: diff -r 8baebc416a38 -r f2d5d5d5d4d6 TextView.st --- a/TextView.st Sat May 07 15:48:27 2016 +0200 +++ b/TextView.st Sat May 07 15:48:54 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 ! @@ -4493,33 +4495,43 @@ ! showMatch:pattern atLine:line col:col + "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 + + "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 + |endCol realPattern| + + (endCol := encColOrNil) isNil ifTrue:[ + "/ a hack. + realPattern := pattern. + isMatch ifTrue: [ + (realPattern startsWith:$*) ifTrue:[ + realPattern := realPattern copyButFirst + ]. + (realPattern endsWith:$*) ifTrue:[ + realPattern := realPattern copyButLast + ]. ]. - (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 !