SelectionInListModelView.st
changeset 1563 f67940c89977
parent 1561 edac7f38341b
child 1564 6c73d2b8c0e7
--- a/SelectionInListModelView.st	Tue Sep 28 15:11:20 1999 +0200
+++ b/SelectionInListModelView.st	Tue Sep 28 15:12:32 1999 +0200
@@ -313,76 +313,66 @@
 listSizeChanged:aLnNr nLines:aDeltaLines
     "update selection
     "
-    |newSel noChg size changed|
+    |changed cnts|
 
     super listSizeChanged:aLnNr nLines:aDeltaLines.
 
     selection isNil ifTrue:[^ self].
 
     list size == 0 ifTrue:[
-      ^ self deselectWithoutRedraw
-    ].
-    multipleSelectOk ifFalse:[
-        selection >= aLnNr ifTrue:[
-            selection := selection + aDeltaLines.
-
-            (aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
-                self deselectWithoutRedraw
-            ] ifFalse:[
-                (model notNil and:[useIndex]) ifTrue:[
-                    model setValue:selection
-                ]
-            ]
-        ].
-        ^ self
+        selection := nil.
+      ^ self selectionChanged
     ].
 
-    size    := selection size.
-    changed := false.
+    multipleSelectOk ifFalse:[
+        selection < aLnNr ifTrue:[^ self].
+
+        selection := selection + aDeltaLines.
 
-    aDeltaLines < 0  ifFalse:[
-        1 to:size do:[:anIndex|
-            newSel := selection at:anIndex.
+        (aDeltaLines < 0 and:[selection < aLnNr]) ifTrue:[
+            selection := nil.
+          ^ self selectionChanged
+        ]
+    ] ifTrue:[
+        changed := false.
 
-            newSel >= aLnNr ifTrue:[
-                changed := true.
-                selection at:anIndex put:(newSel + aDeltaLines)
+        aDeltaLines < 0  ifFalse:[
+            selection keysAndValuesDo:[:i :ln|
+                ln >= aLnNr ifTrue:[
+                    changed := true.
+                    selection at:i put:(ln + aDeltaLines)
+                ]
             ]
-        ].
-        (changed and:[useIndex and:[model notNil]]) ifTrue:[
-            model setValue:(selection copy)
+        ] ifTrue:[
+            cnts := 0.
+
+            selection keysAndValuesDo:[:i :ln||new|
+                ln >= aLnNr ifTrue:[
+                    changed := true.
+
+                    (new := ln + aDeltaLines) < aLnNr ifTrue:[
+                        cnts := cnts + 1.
+                        new  := nil
+                    ].
+                    selection at:i put:new
+                ]
+            ].
+            cnts ~~ 0 ifTrue:[
+                cnts == selection size ifTrue:[
+                    selection := nil
+                ] ifFalse:[
+                    selection := selection select:[:ln| ln notNil]
+                ].
+              ^ self selectionChanged.
+            ].
         ].
-        ^ self
-    ].
-    noChg := 0.
-
-    1 to:size do:[:anIndex|
-        newSel := selection at:anIndex.
-
-        newSel >= aLnNr ifTrue:[
-            newSel  := newSel + aDeltaLines.
-            changed := true.
-
-            newSel < aLnNr ifTrue:[
-                noChg  := noChg + 1.
-                newSel := 0.
-            ].
-            selection at:anIndex put:newSel
-        ]
+        changed ifFalse:[^ self].
     ].
 
-    noChg ~~ 0 ifTrue:[
-        noChg == size ifTrue:[
-            self deselectWithoutRedraw.
-        ] ifFalse:[
-            selection := selection select:[:i| i ~~ 0].
-            self selectionChanged
-        ]
-    ] ifFalse:[
-        (changed and:[useIndex and:[model notNil]]) ifTrue:[
-            model setValue:(selection copy)
-        ]
-    ]
+    (useIndex and:[model notNil]) ifTrue:[
+        model setValue:(self argForChangeMessage)
+    ].
+
 
 !
 
@@ -1271,6 +1261,6 @@
 !SelectionInListModelView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.20 1999-09-28 07:48:05 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInListModelView.st,v 1.21 1999-09-28 13:12:32 ca Exp $'
 ! !
 SelectionInListModelView initialize!