#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Tue, 26 Apr 2016 11:37:38 +0200
changeset 16325 073884e3213d
parent 16324 5f36246be507
child 16326 d7236edb4060
#UI_ENHANCEMENT by cg class: SettingsDialog better word matching; changed discard to give embedded settings app a chance to undo already changed stuff (especiall syntaxColorsettings, which has already modified the userPrefs) added: #getWordMatchPattern comment/format in: #doSave #highlightWidgets: #unhighlightWidgets changed:5 methods
SettingsDialog.st
--- a/SettingsDialog.st	Tue Apr 26 11:36:10 2016 +0200
+++ b/SettingsDialog.st	Tue Apr 26 11:37:38 2016 +0200
@@ -340,6 +340,9 @@
 #saveSettingsToFile
 'Save the current settings into a file.\The "settings.stx" file is automatically read upon every fresh start of ST/X.'
 
+#quickSearchString
+'Quick search pattern. Highlights settings which contain the entered string.\Prefix with a space to search for words starting with it;\append a space, to search for words ending with it.'
+
 )
 
     "Modified: / 31-07-2013 / 09:52:36 / cg"
@@ -407,6 +410,7 @@
                               (SpecCollection
                                  collection: (
                                   (LabelSpec
+                                     activeHelpKey: quickSearchString
                                      label: 'Quick Search:'
                                      name: 'Label1'
                                      layout: (LayoutFrame 0 0 0 0 150 0 0 1)
@@ -414,6 +418,7 @@
                                      adjust: left
                                    )
                                   (InputFieldSpec
+                                     activeHelpKey: quickSearchString
                                      name: 'QuickSeachEntryField'
                                      layout: (LayoutFrame 150 0 0 0 0 1 0 1)
                                      model: quickSearchStringHolder
@@ -825,16 +830,20 @@
 !
 
 doReload
+    "discard button was pressed"
+    
     |item|
 
     item := self selectedItem value.
     (item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[
         ^ self
     ].
-    item application readSettings
+    item application discardChangesAndReadSettings
 !
 
 doSave
+    "accept button was pressed"
+
     | item |
 
     item := self selectedItem value.
@@ -1789,6 +1798,33 @@
 
 !SettingsDialog methodsFor:'quick search support'!
 
+getWordMatchPattern
+    "pattern is needed at multiple places"
+
+    |searchString plainWord pattern|
+
+    searchString := self quickSearchStringHolder value.
+    searchString isEmptyOrNil ifTrue:[^ nil].
+
+    plainWord := searchString withoutSeparators.
+    plainWord isEmpty ifTrue:[^ nil].
+
+    searchString first isSeparator ifTrue:[
+        searchString last isSeparator ifTrue:[
+            pattern := plainWord.
+        ] ifFalse:[
+            pattern := plainWord,'*'.
+        ].    
+    ] ifFalse:[
+        searchString last isSeparator ifTrue:[
+            pattern := '*',plainWord.
+        ] ifFalse:[    
+            pattern := '*',searchString,'*'.
+        ].
+    ].
+    ^ pattern.
+!
+
 highlightWidgets:aSetOfWidget
     "highlight a matching widget"
 
@@ -1810,16 +1846,13 @@
      go through the widgets and highlight those which match.
      This is done by looking at the helpkey and model aspects for a match"
 
-    |app searchString pattern words widgetsToHighlight|
+    |app pattern words widgetsToHighlight|
     
     highlightedWidgetsOriginalAttributes notNil ifTrue:[
         self unhighlightWidgets.
     ].
     
-    searchString := self quickSearchStringHolder value.
-    searchString isEmptyOrNil ifTrue:[^ self].
-    
-    pattern := '*',searchString,'*'.
+    (pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
 
     (app := subCanvasApplicationHolder value) isNil ifTrue:[^ self].
 
@@ -1871,7 +1904,7 @@
 !
 
 quickSearchStringHolderChanged
-    |oldSelection searchString pattern matches|
+    |oldSelection pattern matches|
     
     self unhighlightWidgets.
 
@@ -1879,15 +1912,15 @@
     
     "/ make all labels normal
     applicationList root recursiveDo:[:eachSettingsAppItem |
-        eachSettingsAppItem label:(eachSettingsAppItem label string).
+        |lbl|
+        lbl := eachSettingsAppItem label.
+        lbl hasChangeOfEmphasis ifTrue:[
+            eachSettingsAppItem label:(lbl string).
+            applicationList itemChanged:#redraw with:nil from:eachSettingsAppItem.
+        ]. 
     ]. 
 
-    searchString := self quickSearchStringHolder value.
-    searchString isEmptyOrNil ifTrue:[
-        ^ self
-    ].
-    
-    pattern := '*',searchString,'*'.
+    (pattern := self getWordMatchPattern) isNil ifTrue:[^ self].
 
     applicationList root recursiveExpand.
 "/    applicationList root recursiveDo:[:eachSettingsAppItem |
@@ -1911,7 +1944,8 @@
     applicationList root children do:[:c | c recursiveCollapse].
     "/ now expand all matches
     matches do:[:eachMatchingItem |
-        eachMatchingItem label:(eachMatchingItem label string allBold).
+        eachMatchingItem label:(eachMatchingItem label string allBold colorizeAllWith:Color red).
+        applicationList itemChanged:#redraw with:nil from:eachMatchingItem.
         eachMatchingItem makeVisible
     ].