--- a/TextView.st Fri May 18 04:28:00 2018 +0200
+++ b/TextView.st Tue May 22 18:25:08 2018 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -25,15 +23,14 @@
lastSearchWasMatch lastSearchIgnoredCase lastSearchDirection
lastSearchWasVariableSearch parenthesisSpecification dropSource
dragIsActive saveAction st80SelectMode searchBarActionBlock'
- classVariableNames:'DefaultViewBackground DefaultSelectionForegroundColor
- DefaultSelectionBackgroundColor
+ classVariableNames:'DefaultAlternativeSelectionBackgroundColor
DefaultAlternativeSelectionForegroundColor
- DefaultAlternativeSelectionBackgroundColor MatchDelayTime
- WordSelectCatchesBlanks LastSearchPatterns
- NumRememberedSearchPatterns LastSearchIgnoredCase
- LastSearchWasMatch DefaultParenthesisSpecification
- LastSearchWasMatchWithRegex LastSearchWasWrapAtEndOfText
- LastSearchWasReplace LastSearchReplacedString'
+ DefaultParenthesisSpecification DefaultSelectionBackgroundColor
+ DefaultSelectionForegroundColor DefaultViewBackground
+ LastSearchIgnoredCase LastSearchPatterns LastSearchReplacedString
+ LastSearchWasMatch LastSearchWasMatchWithRegex
+ LastSearchWasReplace LastSearchWasWrapAtEndOfText MatchDelayTime
+ NumRememberedSearchPatterns WordSelectCatchesBlanks'
poolDictionaries:''
category:'Views-Text'
!
@@ -2390,6 +2387,21 @@
over time, it got more and more functions, so a separate appModel class
would no be appropriate..."
+ ^ self openSearchBoxAndSearchWithReplaceChecked:false
+
+ "Modified: / 11-07-2006 / 11:18:38 / fm"
+ "Created: / 08-03-2012 / 14:02:59 / cg"
+ "Modified: / 22-05-2018 / 15:48:41 / Claus Gittinger"
+!
+
+openSearchBoxAndSearchWithReplaceChecked:replaceChecked
+ "search for a string - show a box to enter searchpattern and replace options.
+ If replaceChecked is true, the 'replace' checkbox and 'replace to end' are
+ initially checked, and the focus is on the replace field.
+ TODO: this started as an ad-hoc box, which is manually constructed.
+ over time, it got more and more functions, so a separate appModel class
+ would now be appropriate..."
+
"
Q: is it a good idea to preserve the last searchstring between views?
cg: yes - turns out to be useful and less confusing than keeping last per view
@@ -2423,6 +2435,7 @@
].
ign := lastSearchIgnoredCase "? LastSearchIgnoredCase " ? true.
+ replaceChecked ifTrue:[ign := false].
caseHolder := ign not asValue.
match := lastSearchWasMatch ? LastSearchWasMatch ? false.
@@ -2430,11 +2443,11 @@
matchWithRegexHolder := (LastSearchWasMatchWithRegex ? false) asValue.
wrapAtEndHolder := (LastSearchWasWrapAtEndOfText ? false) asValue.
searchVariableHolder := (lastSearchWasVariableSearch ? false) asValue.
- searchFullWordHolder := false asValue.
+ searchFullWordHolder := replaceChecked asValue.
searchAtBeginOfLineOnlyHolder := false asValue.
selectLinesHolder := false asValue.
- replaceBooleanHolder := ("LastSearchWasReplace ?" false) asValue.
- replaceAllBooleanHolder := false asValue.
+ replaceBooleanHolder := replaceChecked asValue.
+ replaceAllBooleanHolder := replaceChecked asValue.
replacePreserveCaseBooleanHolder := false asValue.
replaceTextHolder := (LastSearchReplacedString ? '') asValue.
replaceBooleanEnabledHolder := self isReadOnly not asValue.
@@ -2446,10 +2459,10 @@
lastSearchPattern notNil ifTrue:[
initialString := lastSearchPattern.
].
-"/ No longer force the current selection to be the initialString
-"/ self hasSelectionWithinSingleLine ifTrue:[
-"/ initialString := self selection asString.
-"/ ].
+ "/ No longer force the current selection to be the initialString
+ "/ self hasSelectionWithinSingleLine ifTrue:[
+ "/ initialString := self selection asString.
+ "/ ].
initialString isNil ifTrue:[
LastSearchPatterns size > 0 ifTrue:[
initialString := LastSearchPatterns first.
@@ -2661,6 +2674,11 @@
bldr aspectAt:#helpSpec put:(self class helpSpec).
searchBox allButOpenFrom:(self class searchDialogSpec).
+ replaceChecked ifTrue:[
+ bldr window label:'String search & replace'.
+ bldr keyboardProcessor componentWithInitialFocus:(bldr componentAt:#ReplaceEntryField).
+ ].
+
(bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
(bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
(bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
@@ -2688,8 +2706,8 @@
self objectAttributeAt:#currentModelessSearchBox put:searchBox.
]
- "Modified: / 11-07-2006 / 11:18:38 / fm"
- "Created: / 08-03-2012 / 14:02:59 / cg"
+ "Created: / 22-05-2018 / 15:47:29 / Claus Gittinger"
+ "Modified: / 22-05-2018 / 18:24:22 / Claus Gittinger"
!
openWorkspaceWithIt