#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Thu, 17 Aug 2017 10:13:14 +0200
changeset 6191 315e21126832
parent 6190 5cbc34a6f2d0
child 6192 3d0f6912e305
#REFACTORING by cg class: SelectionInListView changed: #keyPress:x:y:
SelectionInListView.st
--- a/SelectionInListView.st	Thu Aug 17 00:12:15 2017 +0200
+++ b/SelectionInListView.st	Thu Aug 17 10:13:14 2017 +0200
@@ -2543,192 +2543,192 @@
      backSearch searchPrefix shifted
      mySize sensor s index0 stillSearching|
 
-    enabled ifFalse:[
-        ^ self
-    ].
-    sensor := self sensor.
-    shifted := sensor notNil and:[sensor shiftDown].
-
-    (key == #CursorUp) ifTrue:[
-        index0 := self firstInSelection.
-        index := self previousSelectableBefore:selection.
-        stillSearching := true.
-        [stillSearching
-         and:[selectConditionBlock notNil 
-              and:[(selectConditionBlock value:index) not]]] whileTrue:[
-            index := self previousSelectableBefore:index.
-            stillSearching := index0 notNil and:[index ~= index0]
+    enabled ifTrue:[
+        sensor := self sensor.
+        shifted := sensor notNil and:[sensor shiftDown].
+
+        (key == #CursorUp) ifTrue:[
+            index0 := self firstInSelection.
+            index := self previousSelectableBefore:selection.
+            stillSearching := true.
+            [stillSearching
+             and:[selectConditionBlock notNil 
+                  and:[(selectConditionBlock value:index) not]]] whileTrue:[
+                index := self previousSelectableBefore:index.
+                stillSearching := index0 notNil and:[index ~= index0]
+            ].
+            (index0 notNil and:[index isNil or:[index > index0]]) ifTrue:[
+                UserPreferences current beepInEditor ifTrue:[                
+                    self beep      "/ wrapped
+                ].  
+            ].   
+            self key:key select:index x:x y:y shifted:shifted.
+            ^ self
         ].
-        (index0 notNil and:[index isNil or:[index > index0]]) ifTrue:[
-            UserPreferences current beepInEditor ifTrue:[                
-                self beep      "/ wrapped
+        (key == #CursorDown) ifTrue:[
+            index0 := self lastInSelection.
+            index := self nextSelectableAfter:selection.
+            stillSearching := true.
+            [stillSearching
+             and:[selectConditionBlock notNil 
+                  and:[(selectConditionBlock value:index) not]]] whileTrue:[
+                index := self nextSelectableAfter:index.
+                stillSearching := index0 notNil and:[index ~= index0]
+            ].
+            (index0 notNil and:[index isNil or:[index < index0]]) ifTrue:[
+                UserPreferences current beepInEditor ifTrue:[                
+                    self beep      "/ wrapped
+                ].  
             ].  
-        ].   
-        self key:key select:index x:x y:y shifted:shifted.
-        ^ self
-    ].
-    (key == #CursorDown) ifTrue:[
-        index0 := self lastInSelection.
-        index := self nextSelectableAfter:selection.
-        stillSearching := true.
-        [stillSearching
-         and:[selectConditionBlock notNil 
-              and:[(selectConditionBlock value:index) not]]] whileTrue:[
-            index := self nextSelectableAfter:index.
-            stillSearching := index0 notNil and:[index ~= index0]
+            self key:key select:index x:x y:y shifted:shifted.
+            ^ self
+        ].
+        "/
+        "/ stupid: Home and End are caught in ScrollableView
+        "/ we normally do not get them ...
+        "/ (need to call handlesKey: from there ...
+        "/  ... and implement it here)
+        "/
+        ((key == #BeginOfText) or:[key == #BeginOfLine]) ifTrue:[
+            self key:key select:1 x:x y:y shifted:shifted.
+            ^ self
         ].
-        (index0 notNil and:[index isNil or:[index < index0]]) ifTrue:[
-            UserPreferences current beepInEditor ifTrue:[                
-                self beep      "/ wrapped
-            ].  
-        ].  
-        self key:key select:index x:x y:y shifted:shifted.
-        ^ self
-    ].
-    "/
-    "/ stupid: Home and End are caught in ScrollableView
-    "/ we normally do not get them ...
-    "/ (need to call handlesKey: from there ...
-    "/  ... and implement it here)
-    "/
-    ((key == #BeginOfText) or:[key == #BeginOfLine]) ifTrue:[
-        self key:key select:1 x:x y:y shifted:shifted.
-        ^ self
-    ].
-    ((key == #EndOfText) or:[key == #EndOfLine]) ifTrue:[
-        index := self size.
-        self key:key select:index x:x y:y shifted:shifted.
-        ^ self
-    ].
-    key == #Return ifTrue:[
-        returnKeyActionStyle == #doubleClick ifTrue:[
-            selection notNil ifTrue:[
-                self doubleClicked
+        ((key == #EndOfText) or:[key == #EndOfLine]) ifTrue:[
+            index := self size.
+            self key:key select:index x:x y:y shifted:shifted.
+            ^ self
+        ].
+        key == #Return ifTrue:[
+            returnKeyActionStyle == #doubleClick ifTrue:[
+                selection notNil ifTrue:[
+                    self doubleClicked
+                ].
+                ^ self
+            ].
+            returnKeyActionStyle ~~ #pass ifTrue:[
+                ^ self
+            ].
+        ].
+        (key == #SelectAll) ifTrue:[
+            self multipleSelectOk ifTrue:[
+                self selectAll. 
             ].
             ^ self
         ].
-        returnKeyActionStyle ~~ #pass ifTrue:[
-            ^ self
+
+        mySize := self size.
+
+        "
+         alphabetic keys: search for next entry
+         starting with key's character. If shift is pressed, search backward
+        "
+        (mySize > 0
+        and:[key isCharacter
+        and:[key isLetter]]) ifTrue:[
+            keyActionStyle isNil ifTrue:[^ self].
+            "/        self multipleSelectOk ifTrue:[^ self].
+
+            keyActionStyle == #pass ifFalse:[
+                searchPrefix := key asLowercase asString.
+
+                "/            ... isISearch... ifFalse:[
+                "/                iSearchString := ''
+                "/            ] ifTrue:[
+                "/                iSearchString := iSearchString , searchPrefix.
+                "/                searchPrefix := iSearchString
+                "/            ].
+
+                backSearch := shifted.
+                backSearch ifTrue:[
+                    selection notNil ifTrue:[
+                        startSearch := self firstInSelection - 1.
+                        "/                    selection size > 0 ifTrue:[
+                        "/                        startSearch := selection first - 1
+                        "/                    ] ifFalse:[
+                        "/                        selection isCollection ifTrue:[
+                        "/                            startSearch := mySize
+                        "/                        ] ifFalse:[
+                        "/                            startSearch := selection - 1
+                        "/                        ]
+                        "/                    ]
+                    ] ifFalse:[
+                        startSearch := mySize
+                    ].
+                    startSearch < 1 ifTrue:[
+                        startSearch := mySize.
+                    ].
+                ] ifFalse:[    
+                    selection notNil ifTrue:[
+                        startSearch := self lastInSelection + 1.
+                        "/                    selection size > 0 ifTrue:[
+                        "/                        startSearch := selection last + 1
+                        "/                    ] ifFalse:[
+                        "/                        selection isCollection ifTrue:[
+                        "/                            startSearch := 1
+                        "/                        ] ifFalse:[
+                        "/                            startSearch := selection + 1
+                        "/                        ]
+                        "/                    ]
+                    ] ifFalse:[
+                        startSearch := 1
+                    ].
+                    startSearch > self size ifTrue:[
+                        startSearch := 1.
+                    ].
+                ].
+                searchIndex := startSearch.
+                [true] whileTrue:[
+                    s := self characterSearchItemStringAt:searchIndex.
+                    s notNil ifTrue:[
+                        (s string withoutSeparators asLowercase startsWith:searchPrefix) ifTrue:[
+                            |selectable didAskInteractively|
+
+                            searchIndex = selection ifTrue:[^ self].
+                            Dialog aboutToOpenBoxNotificationSignal
+                                handle:[:ex |
+                                    didAskInteractively := true.
+                                    selectable := false.
+                                ] do:[    
+                                    didAskInteractively := false.
+                                    selectable := selectConditionBlock isNil or:[(selectConditionBlock value:searchIndex)].
+                                ].
+
+                            selectable ifTrue:[
+                                ^ self key:key select:searchIndex x:x y:y shifted:false
+                            ].
+                            didAskInteractively ifTrue:[^ self]. "/ ignore
+                        ].
+                    ].
+                    backSearch ifTrue:[
+                        searchIndex := searchIndex - 1.
+                        searchIndex < 1 ifTrue:[searchIndex := mySize]
+                    ] ifFalse:[
+                        searchIndex := searchIndex + 1.
+                        searchIndex > mySize ifTrue:[searchIndex := 1].
+                    ].
+                    searchIndex == startSearch ifTrue:[
+                        |prefix|
+
+                        "/ none found.
+                        searchPrefix size == 1 ifTrue:[
+                            "/ if all start with the same prefix, use the char after the prefix
+                            prefix := (self list collect:[:l | (l ? '')string]) longestCommonPrefixCaseSensitive:false.
+                            prefix isEmptyOrNil ifTrue:[
+                                ^ self
+                            ].
+                            searchPrefix := prefix , searchPrefix.
+                        ] ifFalse:[
+                            ^ self
+                        ]
+                    ]
+                ]
+            ].
         ].
     ].
-    (key == #SelectAll) ifTrue:[
-        self multipleSelectOk ifTrue:[
-            self selectAll. 
-        ].
-        ^ self
-    ].
-
-    mySize := self size.
-
-    "
-     alphabetic keys: search for next entry
-     starting with key's character. If shift is pressed, search backward
-    "
-    (mySize > 0
-    and:[key isCharacter
-    and:[key isLetter]]) ifTrue:[
-        keyActionStyle isNil ifTrue:[^ self].
-"/        self multipleSelectOk ifTrue:[^ self].
-
-        keyActionStyle == #pass ifFalse:[
-            searchPrefix := key asLowercase asString.
-
-"/            ... isISearch... ifFalse:[
-"/                iSearchString := ''
-"/            ] ifTrue:[
-"/                iSearchString := iSearchString , searchPrefix.
-"/                searchPrefix := iSearchString
-"/            ].
-
-            backSearch := shifted.
-            backSearch ifTrue:[
-                selection notNil ifTrue:[
-                    startSearch := self firstInSelection - 1.
-"/                    selection size > 0 ifTrue:[
-"/                        startSearch := selection first - 1
-"/                    ] ifFalse:[
-"/                        selection isCollection ifTrue:[
-"/                            startSearch := mySize
-"/                        ] ifFalse:[
-"/                            startSearch := selection - 1
-"/                        ]
-"/                    ]
-                ] ifFalse:[
-                    startSearch := mySize
-                ].
-                startSearch < 1 ifTrue:[
-                    startSearch := mySize.
-                ].
-            ] ifFalse:[    
-                selection notNil ifTrue:[
-                    startSearch := self lastInSelection + 1.
-"/                    selection size > 0 ifTrue:[
-"/                        startSearch := selection last + 1
-"/                    ] ifFalse:[
-"/                        selection isCollection ifTrue:[
-"/                            startSearch := 1
-"/                        ] ifFalse:[
-"/                            startSearch := selection + 1
-"/                        ]
-"/                    ]
-                ] ifFalse:[
-                    startSearch := 1
-                ].
-                startSearch > self size ifTrue:[
-                    startSearch := 1.
-                ].
-            ].
-            searchIndex := startSearch.
-            [true] whileTrue:[
-                s := self characterSearchItemStringAt:searchIndex.
-                s notNil ifTrue:[
-                    (s string withoutSeparators asLowercase startsWith:searchPrefix) ifTrue:[
-                        |selectable didAskInteractively|
-                        
-                        searchIndex = selection ifTrue:[^ self].
-                        Dialog aboutToOpenBoxNotificationSignal
-                            handle:[:ex |
-                                didAskInteractively := true.
-                                selectable := false.
-                            ] do:[    
-                                didAskInteractively := false.
-                                selectable := selectConditionBlock isNil or:[(selectConditionBlock value:searchIndex)].
-                            ].
-                            
-                        selectable ifTrue:[
-                            ^ self key:key select:searchIndex x:x y:y shifted:false
-                        ].
-                        didAskInteractively ifTrue:[^ self]. "/ ignore
-                    ].
-                ].
-                backSearch ifTrue:[
-                    searchIndex := searchIndex - 1.
-                    searchIndex < 1 ifTrue:[searchIndex := mySize]
-                ] ifFalse:[
-                    searchIndex := searchIndex + 1.
-                    searchIndex > mySize ifTrue:[searchIndex := 1].
-                ].
-                searchIndex == startSearch ifTrue:[
-                    |prefix|
-
-                    "/ none found.
-                    searchPrefix size == 1 ifTrue:[
-                        "/ if all start with the same prefix, use the char after the prefix
-                        prefix := (self list collect:[:l | (l ? '')string]) longestCommonPrefixCaseSensitive:false.
-                        prefix isEmptyOrNil ifTrue:[
-                            ^ self
-                        ].
-                        searchPrefix := prefix , searchPrefix.
-                    ] ifFalse:[
-                        ^ self
-                    ]
-                ]
-            ]
-        ].
-    ].
-    ^ super keyPress:key x:x y:y
-
-    "Modified: / 15.9.1998 / 18:22:31 / cg"
+    
+    super keyPress:key x:x y:y
+
+    "Modified: / 17-08-2017 / 09:42:06 / cg"
 !
 
 sizeChanged:how