--- a/SettingsDialog.st Mon Jun 25 14:43:42 2018 +0200
+++ b/SettingsDialog.st Mon Jun 25 14:58:26 2018 +0200
@@ -20,7 +20,7 @@
enableReload enableHelp enableOK selectedItem applicationList
categoryIcons lastSelection whyDisabledInfoHolder
quickSearchStringHolder quickSearchFieldShownHolder
- highlightedWidgetsOriginalAttributes'
+ highlightedWidgetsOriginalAttributes prevSearchStringsPerApp'
classVariableNames:'ApplicationList IconList AutoSaveChangedSettingsOnClose'
poolDictionaries:''
category:'Interface-Smalltalk'
@@ -1999,6 +1999,41 @@
^ pattern.
!
+getWordMatchPatterns
+ "patterns are needed at multiple places"
+
+ |searchString plainWord pattern1 patterns|
+
+ searchString := self quickSearchStringHolder value.
+ searchString isEmptyOrNil ifTrue:[^ nil].
+
+ plainWord := searchString withoutSeparators.
+ plainWord isEmpty ifTrue:[^ nil].
+
+ searchString first isSeparator ifTrue:[
+ searchString last isSeparator ifTrue:[
+ pattern1 := plainWord.
+ ] ifFalse:[
+ pattern1 := plainWord,'*'.
+ ].
+ ] ifFalse:[
+ searchString last isSeparator ifTrue:[
+ pattern1 := '*',plainWord.
+ ] ifFalse:[
+ pattern1 := '*',searchString,'*'.
+ ].
+ ].
+ patterns := OrderedCollection with:pattern1.
+ (plainWord includes:Character space) ifTrue:[
+ plainWord asCollectionOfWordsDo:[:each |
+ patterns add:('*',each,'*')
+ ]
+ ].
+ ^ patterns
+
+ "Created: / 25-06-2018 / 14:47:10 / Claus Gittinger"
+!
+
highlightApplicationsForWhich:aBlock
"common code for string search and changed-settings search.
Enumerates all applications with aBlock;
@@ -2054,18 +2089,20 @@
go through the widgets and highlight those which match.
This is done by looking at the helpkey and model aspects for a match"
- |app pattern widgetsToHighlight|
+ |app widgetsToHighlight|
highlightedWidgetsOriginalAttributes notNil ifTrue:[
self unhighlightWidgets.
].
- (pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
+ (self getWordMatchPattern) isNil ifTrue:[^ self].
(app := subCanvasApplicationHolder value) isNil ifTrue:[^ self].
widgetsToHighlight := self widgetsWithMatchingSearchStringIn:app.
self highlightWidgets:widgetsToHighlight.
+
+ "Modified: / 25-06-2018 / 14:47:34 / Claus Gittinger"
!
quickSearchStringHolderChanged
@@ -2075,21 +2112,32 @@
then reselect (because the treeView is too stupid in loosing the selection,
when expanding/hiding)"
- |oldSelection pattern|
+ |oldSelection patterns pattern1|
+
+ prevSearchStringsPerApp isNil ifTrue:[
+ prevSearchStringsPerApp := Dictionary new
+ ].
oldSelection := self selectedItem value.
self unhighlightFoundItemsFromSearch.
- (pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
+ (patterns := self getWordMatchPatterns) isEmptyOrNil ifTrue:[^ self].
self
highlightApplicationsForWhich:[:app |
- |ok words widgetsToHighlight|
+ |ok words found widgetsToHighlight|
- words := app quickSearchStrings.
+ words := prevSearchStringsPerApp at:app class ifAbsentPut:[app quickSearchStrings].
ok := false.
- (words contains:[:word | pattern match:word caseSensitive:false ])
- ifTrue:[
+ patterns size > 1 ifTrue:[
+ found := patterns conform:[:eachPattern |
+ (words contains:[:word | eachPattern match:word caseSensitive:false ])
+ ].
+ ] ifFalse:[
+ pattern1 := patterns first.
+ found := (words contains:[:word | pattern1 match:word caseSensitive:false ])
+ ].
+ found ifTrue:[
ok := true.
"/ app window notNil ifTrue:[
"/ widgetsToHighlight := self widgetsWithMatchingSearchStringIn:app.
@@ -2105,7 +2153,7 @@
self highlightWidgetsWithMatchingSearchString.
].
- "Modified: / 25-06-2018 / 14:38:49 / Claus Gittinger"
+ "Modified: / 25-06-2018 / 14:56:48 / Claus Gittinger"
!
unhighlightFoundItemsFromSearch
@@ -2145,10 +2193,12 @@
go through the widgets and find those which match.
This is done by looking at the helpkey and model aspects for a match"
- |pattern words widgetsToHighlight allWords|
+ |patterns pattern1 wordPatterns words widgetsToHighlight allWords|
- (pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
-
+ (patterns := self getWordMatchPatterns) isNil ifTrue:[^ self].
+ pattern1 := patterns first.
+ wordPatterns := patterns copyFrom:2.
+
allWords :=
[:text |
@@ -2166,8 +2216,13 @@
widgetsToHighlight := Set new.
words := anApplication quickSearchStrings.
-
- (words contains:[:word | pattern match:word caseSensitive:false]) ifTrue:[
+
+ ((words contains:[:word | pattern1 match:word caseSensitive:false])
+ or:[
+ (wordPatterns
+ conform:[:eachPattern |
+ (words contains:[:word | eachPattern match:word caseSensitive:false])])]
+ ) ifTrue:[
"/ ok - there is a match in this app;
"/ look which widget matches it in its helpKey or label
@@ -2199,7 +2254,9 @@
wordsInWidget addAll:(allWords value:name)
].
- widgetHasIt := wordsInWidget contains:[:w | pattern match:w caseSensitive:false ].
+ widgetHasIt := patterns contains:[:somePattern |
+ wordsInWidget contains:[:w |
+ somePattern match:w caseSensitive:false ]].
widgetHasIt ifTrue:[
|alreadyIn|
@@ -2228,7 +2285,7 @@
].
^ widgetsToHighlight.
- "Modified: / 25-06-2018 / 14:36:35 / Claus Gittinger"
+ "Modified: / 25-06-2018 / 14:54:29 / Claus Gittinger"
! !
!SettingsDialog methodsFor:'selection'!