The Trunk: Morphic-mt.1145.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.1145.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1145.mcz

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

Name: Morphic-mt.1145
Author: mt
Time: 13 May 2016, 2:57:36.871874 pm
UUID: 1c7a50e2-ebed-b646-ae51-a50b313f7b35
Ancestors: Morphic-mt.1144

Pluggable text morphs can keep their selection/offset w/o using deferred UI messages. This is more robust when add/remove instance variables in classes related to text editing and tools.

No need for locking the offset in scroll panes anymore. Was a left-over from 4.5.

=============== Diff against Morphic-mt.1144 ===============

Item was changed:
  ----- Method: PluggableTextMorph>>accept (in category 'menu commands') -----
  accept
  "Inform the model of text to be accepted, and return true if OK."
 
+ | priorSelection priorScrollerOffset |
- | ok saveSelection saveScrollerOffset |
- "sps 8/13/2001 22:41: save selection and scroll info"
- saveSelection := self selectionInterval copy.
- saveScrollerOffset := scroller offset copy.
 
  (self canDiscardEdits and: [(self hasProperty: #alwaysAccept) not])
  ifTrue: [^ self flash].
 
+ self hasEditingConflicts ifTrue: [
+ (self confirm: 'Caution!! This method may have been\changed elsewhere since you started\editing it here.  Accept anyway?' withCRs translated) ifFalse: [^ self flash]].
- self hasEditingConflicts ifTrue:
- [(self confirm:
- 'Caution!! This method may have been
- changed elsewhere since you started
- editing it here.  Accept anyway?' translated) ifFalse: [^ self flash]].
- ok := self acceptTextInModel.
- ok==true ifTrue:
- [self setText: self getText.
- self hasUnacceptedEdits: false.
- (model dependents detect: [:dep | (dep isKindOf: PluggableTextMorph) and: [dep getTextSelector == #annotation]] ifNone: [nil]) ifNotNil:
- [:aPane | model changed: #annotation]].
 
+ priorSelection := self selectionInterval copy.
+ priorScrollerOffset := scroller offset copy.
+
+ self acceptTextInModel
+ ifFalse: [^ self "something went wrong"].
+
+ self setText: self getText.
+ self hasUnacceptedEdits: false.
- "sps 8/13/2001 22:41: restore selection and scroll info"
- ["During the step for the browser, updateCodePaneIfNeeded is called, and
- invariably resets the contents of the codeholding PluggableTextMorph
- at that time, resetting the cursor position and scroller in the process.
- The following line forces that update without waiting for the step, then restores the cursor and scrollbar"
 
+ (model dependents
+ detect: [:dep | (dep isKindOf: PluggableTextMorph) and: [dep getTextSelector == #annotation]]
+ ifNone: [nil])
+ ifNotNil: [:aPane | model changed: #annotation].
- ok ifTrue: "(don't bother if there was an error during compile)"
- [(model respondsTo: #updateCodePaneIfNeeded)
- ifTrue: [model updateCodePaneIfNeeded].
- WorldState addDeferredUIMessage:
- [self currentHand newKeyboardFocus: textMorph.
- scroller offset: saveScrollerOffset.
- self setScrollDeltas.
- selectionInterval := saveSelection. "restore prior selection"
- self selectFrom: saveSelection first to: saveSelection last]]]
 
+ "Update the model's internal caches. Note that this is specific to CodeHolder and the stepping it uses for updating. We have to trigger this here manually to avoid that the next step message destroys our selection and scrolling offset."
+ (model respondsTo: #updateCodePaneIfNeeded)
+ ifTrue: [model updateCodePaneIfNeeded].
+
+ "Restore prior selection:"
+ scroller offset: priorScrollerOffset.
+ selectionInterval := priorSelection.
+ self selectFrom: priorSelection first to: priorSelection last.!
- on: Error do: []
- !

Item was changed:
  ----- Method: ScrollPane>>hScrollBarValue: (in category 'scrolling') -----
  hScrollBarValue: scrollValue
 
  scroller hasSubmorphs ifFalse: [^ self].
+ scroller offset: (scrollValue max: 0) @ scroller offset y.!
- lockOffset == true ifFalse: [
- scroller offset: (scrollValue max: 0) @ scroller offset y].
- !

Item was changed:
  ----- Method: ScrollPane>>scrollToShow: (in category 'scrolling') -----
  scrollToShow: aRectangle
- "We have to lock the callback into me because rounding errors in scrollbar values would reset the offset to a different value. The given rectangle may not be visible anymore."
 
  scroller offset: (self offsetToShow: aRectangle).
- lockOffset := true.
  self setScrollDeltas.
+ !
- lockOffset := false.!

Item was changed:
  ----- Method: ScrollPane>>vScrollBarValue: (in category 'scrolling') -----
  vScrollBarValue: scrollValue
 
  scroller hasSubmorphs ifFalse: [^ self].
+ scroller offset: scroller offset x @ (scrollValue max: 0).!
- lockOffset == true ifFalse: [
- scroller offset: scroller offset x @ (scrollValue max: 0)].
- !