The Trunk: Morphic-cmm.1463.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-cmm.1463.mcz

commits-2
Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.1463.mcz

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

Name: Morphic-cmm.1463
Author: cmm
Time: 7 September 2018, 2:39:40.253459 pm
UUID: b8c63d7a-582f-453c-b85f-c2c315ce4243
Ancestors: Morphic-cmm.1462, Morphic-LM.1462

- Fix halo-invocation on a rotated Morph when halos are on the World.
- Provide access to the TextIndent attribute on the alignment menu.
- Fix a NonBooleanReceiver error that appeared when pressing backspace on a read-only text field.

=============== Diff against Morphic-cmm.1462 ===============

Item was changed:
  ----- Method: PasteUpMorph>>tryInvokeHalo: (in category 'events-processing') -----
  tryInvokeHalo: aUserInputEvent
  "Invoke halos around the top-most world container at aUserInputEvent's #position.  If it was already halo'd, zero-in on its next inward component morph at that position.  Holding Shift during the click reverses this traversal order."
  | stack innermost haloTarget |
  Preferences noviceMode ifTrue: [ ^ self ].
  Morph haloForAll ifFalse: [ ^ self ].
  "the stack is the top-most morph to bottom-most."
  stack := (self morphsAt: aUserInputEvent position unlocked: true) select:
  [ : each | each wantsHaloFromClick or: [ each handlesMouseDown: aUserInputEvent ] ].
  innermost := aUserInputEvent hand halo
  ifNil: [ stack first ]
  ifNotNil:
  [ : existingHalo | stack allButFirst "existingHalo is first on the stack, not a target"
  detect: [ : each | each owner == self ]
  ifFound:
  [ : worldContainer | "Is existingHalo's target part of the same worldContainer as the morph clicked?"
  (existingHalo target withAllOwners includes: worldContainer)
+ ifTrue: [ "same hierarchy, let #transferHalo: continue to handle it for now."  ^self ]
- ifTrue: [ "same hierarchy, let #transferHalo: continue to handle it for now."  ^ self ]
  ifFalse:
  [ "different hierarchy, remove + add."
  aUserInputEvent hand removeHalo.
  aUserInputEvent shiftPressed
  ifTrue: [ stack second "first is still the just removed halo" ]
  ifFalse: [ worldContainer ] ] ]
+ ifNone: [ "existingHalo is on the World, defer to #transferHalo: for now."  ^self ] ].
- ifNone: [ "Shouldn't get here, but defensive code."  self ] ].
  "If modifier key is pressed, start at innermost (the target), otherwise the outermost (direct child of the world (self))."
  haloTarget  := (innermost == self or: [aUserInputEvent shiftPressed])
  ifTrue: [ innermost ]
  ifFalse:
  [ "Find the outermost owner that wants it."
  innermost withAllOwners reversed allButFirst
  detect: [ : each | each wantsHaloFromClick ]
  ifNone: [ "haloTarget has its own mouseDown handler, don't halo."  ^ self ] ].
  "Now that we have the haloTarget, show the halo."
  aUserInputEvent hand
  newMouseFocus: haloTarget
  event: aUserInputEvent.
  haloTarget invokeHaloOrMove: aUserInputEvent.
  "aUserInputEvent has been consumed, don't let it cause any further side-effects."
  aUserInputEvent ignore!

Item was changed:
  ----- Method: TextEditor>>backTo: (in category 'typing support') -----
  backTo: startIndex
  "During typing, backspace to startIndex. If there already is a selection, just delete that selection. Otherwise, check if we did something else than backward-deletion and start a new command if so."
 
+ morph readOnly ifTrue: [^ false].
- morph readOnly ifTrue: [^ self].
 
  self hasSelection ifTrue: [
  "Add checkpoint in undo history."
  self replaceSelectionWith: self nullText.
  ^ true].
 
  startIndex > self text size ifTrue: [^ false].
 
  self selectInvisiblyFrom: startIndex to: self stopIndex-1.
 
  self isTypingIn ifTrue: [
  self history current type = #backward
  ifFalse: [self closeTypeIn]
  ifTrue: [
  "Accumulate all deleted characters in current undo command."
  self history current contentsBefore replaceFrom: 1 to: 0 with: self selection.
  self history current intervalBefore in: [:i |
  self history current intervalBefore: (startIndex to: i last)]]].
 
  self openTypeInFor: #backward.
  self zapSelectionWith: self nullText.
 
  ^ false!

Item was changed:
  ----- Method: TextEditor>>changeAlignment (in category 'menu messages') -----
  changeAlignment
+ | options reply |
+ options := self existingIndentation
+ caseOf:
+ {[0]-> [ #('leftFlush' 'indented' 'centered' 'justified' 'rightFlush') ].
+ [1] -> [ #('leftFlush' 'indented more' 'centered' 'justified' 'rightFlush') ]}
+ otherwise: [ #('leftFlush' 'indented less' 'indented more' 'centered' 'justified' 'rightFlush') ].
+ reply := UIManager default chooseFrom: options values: options.
+ reply ifNil: [ ^ self ].
- | aList reply  |
- aList := #(leftFlush centered justified rightFlush).
- reply := UIManager default chooseFrom: aList values: aList.
- reply ifNil:[^self].
  self setAlignment: reply.
  paragraph composeAll.
  self recomputeSelection.
  ^ true!

Item was added:
+ ----- Method: TextEditor>>existingIndentation (in category 'private') -----
+ existingIndentation
+ ^ paragraph text indentationAmountAt: (self encompassLine: self selectionInterval)!

Item was changed:
  ----- Method: TextEditor>>setAlignment: (in category 'menu messages') -----
+ setAlignment: selectionString
+ | attr interval  |
+ attr := selectionString
+ caseOf:
+ { [ 'indented' ] -> [ TextIndent amount: 1 ].
+ [ 'indented more' ] -> [ TextIndent amount: self existingIndentation+1 ].
+ [ 'indented less' ] -> [  TextIndent amount: (self existingIndentation-1 max: 0) ]}
+ otherwise:
+ [ TextAlignment perform: selectionString asSymbol ].
- setAlignment: aSymbol
- | attr interval |
- attr := TextAlignment perform: aSymbol.
  interval := self encompassLine: self selectionInterval.
+ paragraph
- paragraph
  replaceFrom: interval first
  to: interval last
  with: ((paragraph text copyFrom: interval first to: interval last) addAttribute: attr)!