The Inbox: Morphic-mt.1493.mcz

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

The Inbox: Morphic-mt.1493.mcz

commits-2
A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-mt.1493.mcz

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

Name: Morphic-mt.1493
Author: mt
Time: 20 July 2019, 9:59:23.026728 am
UUID: 22c8cff7-de9c-8348-9a19-4cdd14621253
Ancestors: Morphic-mt.1492

Finally have a robust version for the #textEdited: callback in pluggable text morphs.

Thanks to Christoph Thiede for the idea!

=============== Diff against Morphic-mt.1492 ===============

Item was changed:
  ScrollPane subclass: #PluggableTextMorph
+ instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits hasUserEdited askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder'
- instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder'
  classVariableNames: 'AdornmentCache SimpleFrameAdornments SoftLineWrap VisualWrapBorder VisualWrapBorderLimit'
  poolDictionaries: ''
  category: 'Morphic-Pluggable Widgets'!

Item was changed:
+ ----- Method: PluggableTextMorph>>hasUnacceptedEdits (in category 'unaccepted edits') -----
- ----- Method: PluggableTextMorph>>hasUnacceptedEdits (in category 'dependents access') -----
  hasUnacceptedEdits
  "Return true if this view has unaccepted edits."
 
  ^ hasUnacceptedEdits!

Item was changed:
  ----- Method: PluggableTextMorph>>hasUnacceptedEdits: (in category 'unaccepted edits') -----
+ hasUnacceptedEdits: wasJustEdited
+
+ wasJustEdited = hasUnacceptedEdits ifFalse: [
+ hasUnacceptedEdits := wasJustEdited.
- hasUnacceptedEdits: aBoolean
- "Set the hasUnacceptedEdits flag to the given value. "
- aBoolean == hasUnacceptedEdits ifFalse:
- [hasUnacceptedEdits := aBoolean.
  self changed].
+
+ wasJustEdited
+ ifTrue: [self hasUserEdited: true]
+ ifFalse: [self hasEditingConflicts: false].!
- aBoolean ifFalse: [hasEditingConflicts := false]!

Item was added:
+ ----- Method: PluggableTextMorph>>hasUserEdited (in category 'unaccepted edits') -----
+ hasUserEdited
+
+ ^ hasUserEdited!

Item was added:
+ ----- Method: PluggableTextMorph>>hasUserEdited: (in category 'unaccepted edits') -----
+ hasUserEdited: aBoolean
+
+ hasUserEdited := aBoolean.!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
  | view |
 
  editView deleteBalloon.
  self editor model: editView model.  "For evaluateSelection"
  view := editView.  "Copy into temp for case of a self-mutating doit"
  (acceptOnCR and: [evt keyCharacter = Character cr])
  ifTrue: [^ self editor accept].
+
+ view hasUserEdited: false.
  super keyStroke: evt.
  view scrollSelectionIntoView.
 
+ view hasUserEdited
+ ifTrue: [ view textEdited: self contents].!
- "Make a cheap check and guess editing. (Alternative would be to copy the old contents and then compare them against the new ones. Maybe add a better hook in the TextEditor."
- (self readOnly not and: [self eventCharacterModifiesText: evt keyCharacter])
- ifTrue: [view textEdited: self contents]!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Morphic-mt.1493.mcz

Christoph Thiede
Hi Marcel,

thank your for taking up my proposal! Allow me one question, why did you decide not to track hasUnacceptedEdits directly in the TextMorphForEditView? I think this would keep the changes small and not even require additional accessors, and in Editor>>#userHasEdited, #hasUnacceptedEdits: apparently is always called on the TextMorphForEditView. Also, aren't there any other possible clients of TextMorphForEditView beside PluggableTextMorph? Would be great to here the reasons!

Have a nice weekend,
Christoph

Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Samstag, 20. Juli 2019 09:59 Uhr
An: [hidden email] <[hidden email]>
Betreff: [squeak-dev] The Inbox: Morphic-mt.1493.mcz
 
A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-mt.1493.mcz

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

Name: Morphic-mt.1493
Author: mt
Time: 20 July 2019, 9:59:23.026728 am
UUID: 22c8cff7-de9c-8348-9a19-4cdd14621253
Ancestors: Morphic-mt.1492

Finally have a robust version for the #textEdited: callback in pluggable text morphs.

Thanks to Christoph Thiede for the idea!

=============== Diff against Morphic-mt.1492 ===============

Item was changed:
  ScrollPane subclass: #PluggableTextMorph
+        instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits hasUserEdited askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder'
-        instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder'
         classVariableNames: 'AdornmentCache SimpleFrameAdornments SoftLineWrap VisualWrapBorder VisualWrapBorderLimit'
         poolDictionaries: ''
         category: 'Morphic-Pluggable Widgets'!

Item was changed:
+ ----- Method: PluggableTextMorph>>hasUnacceptedEdits (in category 'unaccepted edits') -----
- ----- Method: PluggableTextMorph>>hasUnacceptedEdits (in category 'dependents access') -----
  hasUnacceptedEdits
         "Return true if this view has unaccepted edits."
 
         ^ hasUnacceptedEdits!

Item was changed:
  ----- Method: PluggableTextMorph>>hasUnacceptedEdits: (in category 'unaccepted edits') -----
+ hasUnacceptedEdits: wasJustEdited
+
+        wasJustEdited = hasUnacceptedEdits ifFalse: [
+                hasUnacceptedEdits := wasJustEdited.
- hasUnacceptedEdits: aBoolean
-        "Set the hasUnacceptedEdits flag to the given value. "
-        aBoolean == hasUnacceptedEdits ifFalse:
-                [hasUnacceptedEdits := aBoolean.
                 self changed].
+
+        wasJustEdited
+                ifTrue: [self hasUserEdited: true]
+                ifFalse: [self hasEditingConflicts: false].!
-        aBoolean ifFalse: [hasEditingConflicts := false]!

Item was added:
+ ----- Method: PluggableTextMorph>>hasUserEdited (in category 'unaccepted edits') -----
+ hasUserEdited
+       
+        ^ hasUserEdited!

Item was added:
+ ----- Method: PluggableTextMorph>>hasUserEdited: (in category 'unaccepted edits') -----
+ hasUserEdited: aBoolean
+       
+        hasUserEdited := aBoolean.!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
         | view |
        
         editView deleteBalloon.
         self editor model: editView model.  "For evaluateSelection"
         view := editView.  "Copy into temp for case of a self-mutating doit"
         (acceptOnCR and: [evt keyCharacter = Character cr])
                 ifTrue: [^ self editor accept].
+
+        view hasUserEdited: false.
         super keyStroke: evt.
         view scrollSelectionIntoView.
        
+        view hasUserEdited
+                ifTrue: [       view textEdited: self contents].!
-        "Make a cheap check and guess editing. (Alternative would be to copy the old contents and then compare them against the new ones. Maybe add a better hook in the TextEditor."
-        (self readOnly not and: [self eventCharacterModifiesText: evt keyCharacter])
-                ifTrue: [view textEdited: self contents]!




Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Morphic-mt.1493.mcz

marcel.taeumel
Hi Christoph,

I see #userHasEdited as an extension to #hasUnacceptedEdits and #hasEditingConflicts, which is already in PluggableTextMorph. It seemed better to keep all together. Especially since the entire reason - #textEdited: - is only implemented in PluggableTextMorph. This way, we can keep TextMorphForEditView as small as possible. Maybe also because I don't like having TextMorphForEditView at all. I would prefer being able to use a regular TextMorph.

Just some thoughts. :-)

Best,
Marcel

Am 20.07.2019 21:03:10 schrieb Christoph Thiede <[hidden email]>:

Hi Marcel,

thank your for taking up my proposal! Allow me one question, why did you decide not to track hasUnacceptedEdits directly in the TextMorphForEditView? I think this would keep the changes small and not even require additional accessors, and in Editor>>#userHasEdited, #hasUnacceptedEdits: apparently is always called on the TextMorphForEditView. Also, aren't there any other possible clients of TextMorphForEditView beside PluggableTextMorph? Would be great to here the reasons!

Have a nice weekend,
Christoph

Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Samstag, 20. Juli 2019 09:59 Uhr
An: [hidden email] <[hidden email]>
Betreff: [squeak-dev] The Inbox: Morphic-mt.1493.mcz
 
A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-mt.1493.mcz

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

Name: Morphic-mt.1493
Author: mt
Time: 20 July 2019, 9:59:23.026728 am
UUID: 22c8cff7-de9c-8348-9a19-4cdd14621253
Ancestors: Morphic-mt.1492

Finally have a robust version for the #textEdited: callback in pluggable text morphs.

Thanks to Christoph Thiede for the idea!

=============== Diff against Morphic-mt.1492 ===============

Item was changed:
  ScrollPane subclass: #PluggableTextMorph
+        instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits hasUserEdited askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder'
-        instanceVariableNames: 'textMorph getTextSelector setTextSelector getSelectionSelector hasUnacceptedEdits askBeforeDiscardingEdits selectionInterval hasEditingConflicts editTextSelector wantsWrapBorder'
         classVariableNames: 'AdornmentCache SimpleFrameAdornments SoftLineWrap VisualWrapBorder VisualWrapBorderLimit'
         poolDictionaries: ''
         category: 'Morphic-Pluggable Widgets'!

Item was changed:
+ ----- Method: PluggableTextMorph>>hasUnacceptedEdits (in category 'unaccepted edits') -----
- ----- Method: PluggableTextMorph>>hasUnacceptedEdits (in category 'dependents access') -----
  hasUnacceptedEdits
         "Return true if this view has unaccepted edits."
 
         ^ hasUnacceptedEdits!

Item was changed:
  ----- Method: PluggableTextMorph>>hasUnacceptedEdits: (in category 'unaccepted edits') -----
+ hasUnacceptedEdits: wasJustEdited
+
+        wasJustEdited = hasUnacceptedEdits ifFalse: [
+                hasUnacceptedEdits := wasJustEdited.
- hasUnacceptedEdits: aBoolean
-        "Set the hasUnacceptedEdits flag to the given value. "
-        aBoolean == hasUnacceptedEdits ifFalse:
-                [hasUnacceptedEdits := aBoolean.
                 self changed].
+
+        wasJustEdited
+                ifTrue: [self hasUserEdited: true]
+                ifFalse: [self hasEditingConflicts: false].!
-        aBoolean ifFalse: [hasEditingConflicts := false]!

Item was added:
+ ----- Method: PluggableTextMorph>>hasUserEdited (in category 'unaccepted edits') -----
+ hasUserEdited
+       
+        ^ hasUserEdited!

Item was added:
+ ----- Method: PluggableTextMorph>>hasUserEdited: (in category 'unaccepted edits') -----
+ hasUserEdited: aBoolean
+       
+        hasUserEdited := aBoolean.!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
         | view |
        
         editView deleteBalloon.
         self editor model: editView model.  "For evaluateSelection"
         view := editView.  "Copy into temp for case of a self-mutating doit"
         (acceptOnCR and: [evt keyCharacter = Character cr])
                 ifTrue: [^ self editor accept].
+
+        view hasUserEdited: false.
         super keyStroke: evt.
         view scrollSelectionIntoView.
        
+        view hasUserEdited
+                ifTrue: [       view textEdited: self contents].!
-        "Make a cheap check and guess editing. (Alternative would be to copy the old contents and then compare them against the new ones. Maybe add a better hook in the TextEditor."
-        (self readOnly not and: [self eventCharacterModifiesText: evt keyCharacter])
-                ifTrue: [view textEdited: self contents]!