#OTHER by mawalch
class: ListView
comment/format in: #update:with:from:
changed:
#getListFromModel
#updateWidthOfWidestLineFor:
--- a/ListView.st Fri Sep 23 13:56:57 2016 +0200
+++ b/ListView.st Fri Sep 23 17:50:57 2016 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -1865,46 +1863,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
@@ -2934,55 +2932,62 @@
|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"
@@ -3169,7 +3174,8 @@
|w|
- (w := self widthOfLineString:aLine) > widthOfWidestLine ifTrue:[
+ w := self widthOfLineString:aLine.
+ w > (widthOfWidestLine ? 0) ifTrue:[
widthOfWidestLine := w.
self contentsChanged.
].