ListView.st
branchjv
changeset 5898 dd3d011daf37
parent 5881 ed8d6a1ebf38
parent 5885 38ee27139eb1
child 5981 50c1bb3e9f98
--- a/ListView.st	Fri Sep 23 07:02:28 2016 +0200
+++ b/ListView.st	Mon Oct 03 13:47:16 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -1882,46 +1880,46 @@
     |idx|
 
     changedObject == model ifTrue:[
-	model isList ifTrue:[
-	    list ~~ model ifTrue:[
-		something == #at: ifTrue:[
-		    idx := aParameter isCollection ifTrue:[aParameter at:1]
-						  ifFalse:[aParameter].
-		    ^ self at:aParameter put:(model at:idx).
-		].
-		something == #insert: ifTrue:[
-		    (list size + 1) >= aParameter ifTrue:[
-			^ self add:(model at:aParameter) beforeIndex:aParameter
-		    ].
-		].
-		something == #remove: ifTrue:[
-		    list size >= aParameter ifTrue:[
-			^ self removeIndex:aParameter
-		    ]
-		].
-	    ].
-	    self getListFromModel.
-	    ^ self
-	].
-
-	(aspectMsg notNil
-	and:[something == aspectMsg]) ifTrue:[
-	    self getListFromModel.
-	    ^ self
-	].
-	something isNil ifTrue:[
-	    "/ model changed (not more information)
-	    self getListFromModel.
-	    ^ self
-	].
-	something == #size ifTrue:[
-	    self getListFromModelScroll:false.
-	    ^ self
-	].
+        model isList ifTrue:[
+            list ~~ model ifTrue:[
+                something == #at: ifTrue:[
+                    idx := aParameter isCollection ifTrue:[aParameter at:1]
+                                                  ifFalse:[aParameter].
+                    ^ self at:aParameter put:(model at:idx).
+                ].
+                something == #insert: ifTrue:[
+                    (list size + 1) >= aParameter ifTrue:[
+                        ^ self add:(model at:aParameter) beforeIndex:aParameter
+                    ].
+                ].
+                something == #remove: ifTrue:[
+                    list size >= aParameter ifTrue:[
+                        ^ self removeIndex:aParameter
+                    ]
+                ].
+            ].
+            self getListFromModel.
+            ^ self
+        ].
+
+        (aspectMsg notNil
+        and:[something == aspectMsg]) ifTrue:[
+            self getListFromModel.
+            ^ self
+        ].
+        something isNil ifTrue:[
+            "/ model changed (not more information)
+            self getListFromModel.
+            ^ self
+        ].
+        something == #size ifTrue:[
+            self getListFromModelScroll:false.
+            ^ self
+        ].
     ].
     changedObject == listChannel ifTrue:[
-	self getListFromModel.
-	^ self
+        self getListFromModel.
+        ^ self
     ].
 
     ^ super update:something with:aParameter from:changedObject
@@ -2951,54 +2949,61 @@
     |newText msg doCompareIfUnchanged|
 
     model notNil ifTrue:[
-	msg := listMsg ? aspectMsg.
-
-	msg notNil ifTrue:[
-	    doCompareIfUnchanged := compareModelOnUpdate.
-	    newText := model perform:msg.
-	    "/ cg: this makes many optimizations (virtualArray) useless;
-	    "/ I do not think that this is a good idea:
-	    "/     text notNil ifTrue:[
-	    "/ so I changed it to:
-	    (newText notNil and:[newText isString]) ifTrue:[
-		newText := newText asStringCollection.
-	    ] ifFalse:[
-		newText == model ifTrue:[
-		    "/ I must operate on a copy
-		    newText := model asNewOrderedCollection.
-		    "/ doCompareIfUnchanged := false.
-		].
-	    ].
-
-	    doCompareIfUnchanged ifTrue:[
-		"/ see if there is a change at all.
-		"/ use to compare using =, but that's not enough in case of emphasis change.
-		newText size == list size ifTrue:[
-		    |same|
-
-		    same := true.
-		    newText size > 0 ifTrue:[
-			newText with:list do:[:eachNewLine :eachOldLine |
-			    (eachNewLine == eachOldLine) ifFalse:[
-				same := false.
-			    ]
-			]
-		    ].
-		    same ifTrue:[^ self].
-		].
-	    ].
-
-	    "/ SV: this compare does not work, if model uses (i.e. updates)
-	    "/ the same stringCollection as the view!!
-	    true "text ~= list" ifTrue:[
-		"/ changed #list to care for scrollLocked
+        msg := listMsg ? aspectMsg.
+
+        msg notNil ifTrue:[
+            doCompareIfUnchanged := compareModelOnUpdate.
+            newText := model perform:msg.
+            "/ cg: this makes many optimizations (virtualArray) useless;
+            "/ I do not think that this is a good idea:
+            "/     text notNil ifTrue:[
+            "/ so I changed it to:
+            (newText notNil and:[newText isString]) ifTrue:[
+                newText := newText asStringCollection.
+            ] ifFalse:[
+                newText == model ifTrue:[
+                    self isReadOnly ifTrue:[
+                        newText := model.
+                        self list:newText expandTabs:expandTabsWhenUpdating scanForNonStrings:expandTabsWhenUpdating.
+                        ^ self.
+                    ] .
+                    "/ I must operate on a copy
+                    newText := model asNewOrderedCollection.
+                    "/ doCompareIfUnchanged := false.
+                ].
+            ].
+
+            doCompareIfUnchanged ifTrue:[
+                "/ see if there is a change at all.
+                "/ use to compare using =, but that's not enough in case of emphasis change.
+                newText size == list size ifTrue:[
+                    |same|
+
+                    same := true.
+                    newText size > 0 ifTrue:[
+                        newText ~~ list ifTrue:[
+                            newText with:list do:[:eachNewLine :eachOldLine |
+                                (eachNewLine == eachOldLine) ifFalse:[
+                                    same := false.
+                                ]
+                            ]
+                        ].
+                    ].
+                    same ifTrue:[^ self].
+                ].
+            ].
+
+            "/ SV: this compare does not work, if model uses (i.e. updates)
+            "/ the same stringCollection as the view!!
+            true "text ~= list" ifTrue:[
+                "/ changed #list to care for scrollLocked
 "/                scrollLocked ifTrue:[
 "/                    self setList:newText expandTabs:expandTabsWhenUpdating
 "/                ] ifFalse:[
-		    self list:newText expandTabs:expandTabsWhenUpdating scanForNonStrings:expandTabsWhenUpdating
+                    self list:newText expandTabs:expandTabsWhenUpdating scanForNonStrings:expandTabsWhenUpdating
 "/                ]
-	    ].
-	].
+            ].
+        ].
     ].
 
     "Modified: 26.4.1996 / 14:09:42 / cg"
@@ -3185,7 +3190,8 @@
 
     |w|
 
-    (w := self widthOfLineString:aLine) > widthOfWidestLine ifTrue:[
+    w := self widthOfLineString:aLine.
+    w > (widthOfWidestLine ? 0) ifTrue:[
         widthOfWidestLine := w.
         self contentsChanged.
     ].    
@@ -3707,8 +3713,8 @@
     ] ifFalse:[
         checkedLinesForWidthOfContentsComputation == 0 ifTrue:[
             start := firstLineShown.
-            stop := start + nLinesShown - 1.
-        ] ifFalse:[    
+            stop := (start + nLinesShown - 1) min:list size.
+        ] ifFalse:[
             checkedLinesForWidthOfContentsComputation > 0 ifTrue:[
                 start := 1.
                 stop := (checkedLinesForWidthOfContentsComputation min:list size)