The Trunk: Morphic-mt.1701.mcz

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

The Trunk: Morphic-mt.1701.mcz

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:

==================== Summary ====================

Name: Morphic-mt.1701
Author: mt
Time: 14 October 2020, 2:03:16.450569 pm
UUID: 64fc03e9-6c0b-fc48-885c-61f038e93dff
Ancestors: Morphic-mt.1700

Rename #doWithIndex: to #withIndexDo:. See

=============== Diff against Morphic-mt.1700 ===============

Item was changed:
  ----- Method: MorphicModel>>use:orMakeModelSelectorFor:in: (in category 'compilation') -----
  use: cachedSelector orMakeModelSelectorFor: selectorBody in: selectorBlock
  | selector |
  model ifNil: [^ nil].
  cachedSelector ifNil:
  ["Make up selector from slotname if any"
  selector := (slotName ifNil: [selectorBody]
  ifNotNil: [slotName , selectorBody]) asSymbol.
  (model class canUnderstand: selector) ifFalse:
  [(self confirm: 'Shall I compile a null response for'
  , Character cr asString
  , model class name , '>>' , selector)
  ifFalse: [self halt].
  model class compile: (String streamContents:
+ [:s | selector keywords withIndexDo:
- [:s | selector keywords doWithIndex:
  [:k :i | s nextPutAll: k , ' arg' , i printString].
  s cr; nextPutAll: '"Automatically generated null response."'.
  s cr; nextPutAll: '"Add code below for appropriate behavior..."'.])
  classified: 'input events'
  notifying: nil]]
  [selector := cachedSelector].
  ^ selectorBlock value: selector!

Item was changed:
  ----- Method: PluggableListMorph>>filterList:matching: (in category 'filtering') -----
  filterList: someItems matching: aPattern
  "Filter someStrings according to aPattern. Prepend best matches in the result. Update the model-to-view map."
  | frontMatching substringMatching tmp |
  aPattern ifEmpty: [ ^ someItems ].
  someItems ifEmpty: [ ^ someItems ].
  frontMatching := OrderedCollection new.
  substringMatching := OrderedCollection new.
  self assert: modelToView isEmpty.
  self assert: viewToModel isEmpty.
  tmp := OrderedCollection new.
+ someItems withIndexDo:
- someItems doWithIndex:
  [ :each :n | | foundPos |
  foundPos := self filterListItem: each matching: aPattern.
  foundPos = 1
  [ frontMatching add: each.
  modelToView at: n put: frontMatching size.
  viewToModel at: frontMatching size put: n ]
  [ foundPos > 1 ifTrue:
  [ substringMatching add: each.
  tmp add: n; add:  substringMatching size ] ] ].
  tmp pairsDo: [:modelIndex :viewIndex |
  modelToView at: modelIndex put: viewIndex + frontMatching size.
  viewToModel at: viewIndex + frontMatching size put: modelIndex].
  ^ frontMatching, substringMatching!

Item was changed:
  ----- Method: PluggableMultiColumnListMorph>>getFullList (in category 'model access - cached') -----
  "The full list arranges all items column-first."
  fullList ifNotNil: [^ fullList].
  fullList := getListSelector
  ifNotNil: [:selector | "A) Fetch the list column-first from the model."
  model perform: selector]
  ifNil: [
  (getListSizeSelector notNil and: [getListElementSelector notNil])
  ifFalse: ["X) We cannot fetch the list from the model. Make it empty."
  ifTrue: [ "B) Fetch the list row-first from the model:"
  | listSize |
  listSize := self getListSize.
  listSize = 0 ifTrue: [#() "Empty list"] ifFalse: [
  | firstRow columns |
  firstRow := self getListItem: 1.
  columns := Array new: firstRow size.
  1 to: columns size do: [:columnIndex |
  "Initialize all columns."
  columns at: columnIndex put: (Array new: listSize).
  "Put the first row in."
  (columns at: columnIndex) at: 1 put: (firstRow at: columnIndex)].
  "Put all other rows in."
  2 to: listSize do: [:rowIndex | (self getListItem: rowIndex)
+ withIndexDo: [:item :columnIndex |
- doWithIndex: [:item :columnIndex |
  (columns at: columnIndex) at: rowIndex put: item]].
  self updateColumns.
  ^ fullList!

Item was changed:
  ----- Method: PluggableMultiColumnListMorph>>selection: (in category 'selection') -----
  selection: someObjects
  | found |
  someObjects size ~= self columnCount ifTrue: [^ self].
  1 to: self listSize do: [:row |
  found := true.
+ self getList withIndexDo: [:items :column |
- self getList doWithIndex: [:items :column |
  found := found and: [(items at: row) = (someObjects at: column)]].
  found ifTrue: [^ self selectionIndex: row]].!

Item was changed:
  ----- Method: PluggableMultiColumnListMorph>>updateColumns (in category 'updating') -----
  "The number of columns must match the number of list morphs."
  | columnsChanged |
  columnsChanged := self columnCount ~= listMorphs size.
  [self columnCount < listMorphs size]
  whileTrue: [
  listMorphs removeLast delete].
  [self columnCount > listMorphs size]
  whileTrue: [
  listMorphs addLast: self createListMorph.
  self scroller addMorphBack: listMorphs last].
+ listMorphs withIndexDo: [:listMorph :columnIndex |
- listMorphs doWithIndex: [:listMorph :columnIndex |
  columnIndex: columnIndex;
  color: self textColor;
  cellPositioning: (self cellPositioningAtColumn: columnIndex);
  cellInset: (self cellInsetAtColumn: columnIndex);
  hResizing: (self hResizingAtColumn: columnIndex);
  spaceFillWeight: (self spaceFillWeightAtColumn: columnIndex)].
  columnsChanged ifTrue: [self setListParameters].!

Item was changed:
  ----- Method: PluggableMultiColumnListMorph>>verifyContents (in category 'updating') -----
  "Verify the contents of the receiver, reconstituting if necessary.  Called whenever window is reactivated, to react to possible structural changes.  Also called periodically in morphic if the smartUpdating preference is true"
  | changed currentList modelList modelIndex |
  self flag: #performance. "mt: We do have changed/update. Why can't the tools communicate through an appropriate notifier such as the SystemChangeNotifier?"
  "1) Is the list still up to date?"
  currentList := fullList. fullList := nil.
  modelList := self getFullList.
  changed := false.
+ modelList withIndexDo: [:column :index |
- modelList doWithIndex: [:column :index |
  changed := changed or: [(currentList at: index) ~= column]].
  changed ifFalse: [^ self].
  self updateList: modelList.
  "2) Is the selection still up to date?"
  modelIndex := self getCurrentSelectionIndex.
  (self modelIndexFor: self selectionIndex) = modelIndex ifTrue: [^ self].
  self updateListSelection: modelIndex.!

Item was changed:
  ----- Method: PluggableMultiColumnListMorphByItem>>getCurrentSelectionIndex (in category 'model access') -----
  "Answer the index of the current selection. Similar to #selection: but with the full list instead of the (maybe) filtered list."
  getIndexSelector ifNil: [^ 0].
  (model perform: getIndexSelector) in: [:row |
  row ifNil: [^ 0].
  row ifEmpty: [^ 0].
  1 to: self fullListSize do: [:rowIndex |
  | match |
  match := true.
+ self getFullList withIndexDo: [:column :columnIndex |
- self getFullList doWithIndex: [:column :columnIndex |
  match := match and: [(column at: rowIndex) = (row at: columnIndex)]].
  match ifTrue: [^ rowIndex]]].
  ^ 0!

Item was changed:
  ----- Method: PolygonMorph>>nextDuplicateVertexIndex (in category 'geometry') -----
+ withIndexDo: [:vert :index | ((index between: 2 and: vertices size - 1)
- doWithIndex: [:vert :index | ((index between: 2 and: vertices size - 1)
  and: [| epsilon v1 v2 |
  v1 := vertices at: index - 1.
  v2 := vertices at: index + 1.
  epsilon := ((v1 x - v2 x) abs max: (v1 y - v2 y) abs)
  // 32 max: 1.
  onLineFrom: v1
  to: v2
  within: epsilon])
  ifTrue: [^ index]].
  ^ 0!