[squeak-dev] The Trunk: Morphic-pre.1488.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Apr 29 18:20:32 UTC 2019

Patrick Rein uploaded a new version of Morphic to project The Trunk:

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

Name: Morphic-pre.1488
Author: pre
Time: 29 April 2019, 8:20:28.689145 pm
UUID: 72aff730-f2b8-9e4b-b830-b56fcf18438b
Ancestors: Morphic-cmm.1487

Improves the check for whether a keystroke for the text morph for edit view will change the text to send the #editText callback. Refactors the check by creating a cached character set.

=============== Diff against Morphic-cmm.1487 ===============

Item was changed:
  TextMorph subclass: #TextMorphForEditView
  	instanceVariableNames: 'editView acceptOnCR'
+ 	classVariableNames: 'DraggableTextSelection TextModificationCharacterSet'
- 	classVariableNames: 'DraggableTextSelection'
  	poolDictionaries: ''
  	category: 'Morphic-Text Support'!

Item was added:
+ ----- Method: TextMorphForEditView class>>defaultTextModificationCharacterSet (in category 'constants') -----
+ defaultTextModificationCharacterSet
+ 	^ (ByteCharacterSet newFrom: (((0 to: 30) collect: [:code | Character value: code]) difference: Character separators asArray , {Character backspace})) complement!

Item was added:
+ ----- Method: TextMorphForEditView class>>initialize (in category 'class initialization') -----
+ initialize
+ 	TextModificationCharacterSet := self defaultTextModificationCharacterSet!

Item was added:
+ ----- Method: TextMorphForEditView class>>textModificationCharacterSet (in category 'constants') -----
+ textModificationCharacterSet
+ 	^ TextModificationCharacterSet!

Item was added:
+ ----- Method: TextMorphForEditView>>eventCharacterModifiesText: (in category 'private') -----
+ eventCharacterModifiesText: aCharacter
+ 	^ self class textModificationCharacterSet includes: aCharacter!

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].
  	super keyStroke: evt.
  	view scrollSelectionIntoView.
  	"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]!
- 	(self readOnly not and: [evt keyCharacter isAlphaNumeric or: [evt keyCharacter isSeparator]])
- 		ifTrue: [view textEdited: self contents].!

More information about the Squeak-dev mailing list