[squeak-dev] The Trunk: Morphic-mt.906.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Apr 19 11:52:58 UTC 2015


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

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

Name: Morphic-mt.906
Author: mt
Time: 19 April 2015, 1:52:24.5 pm
UUID: f3f6cb03-d30e-6149-b2dc-60db97306b0b
Ancestors: Morphic-mt.905

Text fields can be #readOnly now. This is not the same as #lock because you can still select and copy things but not modify.

=============== Diff against Morphic-mt.905 ===============

Item was changed:
  ----- Method: PluggableTextMorph>>drawFrameAdornmentsOn: (in category 'drawing') -----
  drawFrameAdornmentsOn: aCanvas 
  	"Include a thin red inset border for unaccepted edits, or, if the unaccepted edits are known to conflict with a change made somewhere else to the same method (typically), put a thick red frame"
  
+ 	self wantsFrameAdornments ifFalse: [^ self].
+ 	
+ 	self readOnly ifTrue: [^ self drawFrameAdornment: Color black on: aCanvas].
+ 	
+ 	(model notNil and: [model refusesToAcceptCode])
+ 		ifTrue: [
+ 			"Put up feedback showing that code cannot be submitted in this state"
+ 			^ self drawFrameAdornment: Color tan on: aCanvas].
+ 	
+ 	self hasEditingConflicts
+ 		ifTrue: [^ self drawFrameAdornment: Color red on: aCanvas].
+ 		 
+ 	self hasUnacceptedEdits ifTrue: [
+ 		model wantsDiffFeedback
+ 			ifTrue: [self drawFrameAdornment: Color yellow on: aCanvas]
+ 			ifFalse: [self drawFrameAdornment: Color orange on: aCanvas].
+ 		^ self].
+ 
+ 	model wantsDiffFeedback
+ 		ifTrue: [self drawFrameAdornment: Color green on: aCanvas].!
- 	self wantsFrameAdornments ifTrue:
- 		[(model notNil and: [model refusesToAcceptCode])
- 			ifTrue:  "Put up feedback showing that code cannot be submitted in this state"
- 				[self drawFrameAdornment: Color tan on: aCanvas]
- 			ifFalse:
- 				[self hasEditingConflicts
- 					ifTrue:
- 						[self drawFrameAdornment: Color red on: aCanvas] 
- 					ifFalse:
- 						[self hasUnacceptedEdits
- 							ifTrue:
- 								[model wantsDiffFeedback
- 									ifTrue:
- 										[self drawFrameAdornment: Color yellow on: aCanvas]
- 									ifFalse:
- 										[self drawFrameAdornment: Color orange on: aCanvas]]
- 							ifFalse:
- 								[model wantsDiffFeedback
- 									ifTrue:
- 										[self drawFrameAdornment: Color green on: aCanvas]]]]]!

Item was added:
+ ----- Method: PluggableTextMorph>>readOnly (in category 'accessing') -----
+ readOnly
+ 
+ 	^ textMorph readOnly!

Item was added:
+ ----- Method: PluggableTextMorph>>readOnly: (in category 'accessing') -----
+ readOnly: aBoolean
+ 
+ 	textMorph readOnly: aBoolean.!

Item was changed:
  ----- Method: TextEditor>>addString: (in category 'typing support') -----
  addString: aString
+ 	morph readOnly ifTrue: [^ self].
+ 	self typeAhead nextPutAll: aString.!
- 	self typeAhead nextPutAll: aString!

Item was changed:
  ----- Method: TextEditor>>backTo: (in category 'typing support') -----
  backTo: startIndex
  	"During typing, backspace to startIndex.  Deleted characters fall into three
  	 clusters, from left to right in the text: (1) preexisting characters that were
  	 backed over; (2) newly typed characters that were backed over;
  	(3) preexisting characters that
  	 were highlighted before typing began.  If typing has not yet been opened,
  	 open it and watch for the first and third cluster.  If typing has been opened,
  	 watch for the first and second cluster.  Save characters from the first and third
  	 cluster in UndoSelection.  Tally characters from the first cluster in UndoMessage's parameter.
  	 Delete all the clusters.  Do not alter Undoer or UndoInterval (except via
  	 openTypeIn).  The code is shorter than the comment."
  
  	| saveLimit newBackovers |
+ 	morph readOnly ifTrue: [^ self].
  	saveLimit := beginTypeInIndex
  		ifNil: [self openTypeIn. UndoSelection := self nullText. self stopIndex].
  	markBlock := paragraph characterBlockForIndex: startIndex.
  	startIndex < saveLimit ifTrue: [
  		newBackovers := beginTypeInIndex - startIndex.
  		beginTypeInIndex := self startIndex.
  		UndoSelection replaceFrom: 1 to: 0 with:
  			(self text copyFrom: startIndex to: saveLimit - 1).
  		UndoMessage arguments size > 0 ifTrue: [
  			UndoMessage argument: (UndoMessage argument ifNil: [1]) + newBackovers]].
  	self zapSelectionWith: self nullText.
  	self unselect!

Item was changed:
  ----- Method: TextEditor>>zapSelectionWith: (in category 'mvc compatibility') -----
  zapSelectionWith: replacement
  
  	| start stop rep |
+ 	morph readOnly ifTrue: [^ self].
  	self deselect.
  	start := self startIndex.
  	stop := self stopIndex.
  	(replacement isEmpty and: [stop > start]) ifTrue: [
  		"If deleting, then set emphasisHere from 1st character of the deletion"
  		emphasisHere := (self text attributesAt: start) select: [:att | att mayBeExtended]].
  	(start = stop and: [ replacement isEmpty ]) ifFalse: [
  		replacement isText
  			ifTrue: [ rep := replacement]
  			ifFalse: [ rep := Text string: replacement attributes: emphasisHere ].
  		self text replaceFrom: start to: stop - 1 with: rep.
  		paragraph
  			recomposeFrom: start
  			to:  start + rep size - 1
  			delta: rep size - (stop-start).
  		self markIndex: start pointIndex: start + rep size.
  		UndoInterval := otherInterval := self selectionInterval].
  
  	self userHasEdited  " -- note text now dirty"!

Item was changed:
  RectangleMorph subclass: #TextMorph
+ 	instanceVariableNames: 'textStyle text wrapFlag paragraph editor container predecessor successor backgroundColor margins editHistory readOnly'
- 	instanceVariableNames: 'textStyle text wrapFlag paragraph editor container predecessor successor backgroundColor margins editHistory'
  	classVariableNames: 'CaretForm DefaultEditorClass'
  	poolDictionaries: ''
  	category: 'Morphic-Basic'!
  
  !TextMorph commentStamp: 'nice 3/24/2010 07:40' prior: 0!
  TextMorphs support display of text with emphasis.  They also support reasonable text-editing capabilities, as well as embedded hot links, and the ability to embed submorphs in the text.
  
  Late in life, TextMorph was made a subclass of BorderedMorph to provide border and background color if desired.  In order to keep things compatible, protocols have been redirected so that color (preferably textColor) relates to the text, and backgroundColor relates to the inner fill color.
  
  Text display is clipped to the innerBounds of the rectangle, and text composition is normally performed within a rectangle which is innerBounds inset by the margins parameter.
  
  If text has been embedded in another object, one can elect to fill the owner's shape, in which case the text will be laid out in the shape of the owner's shadow image (including any submorphs other than the text).  One can also elect to have the text avoid occlusions, in which case it will avoid the bounds of any sibling morphs that appear in front of it.  It may be necessary to update bounds in order for the text runaround to notice the presence of a new occluding shape.
  
  The optional autoFitContents property enables the following feature:  if the text contents changes, then the bounds of the morph will be adjusted to fit the minimum rectangle that encloses the text (plus any margins specified).  Similarly, any attempt to change the size of the morph will be resisted if this parameter is set.  Except...
  
  If the wrapFlag parameter is true, then text will be wrapped at word boundaries based on the composition width (innerBounds insetBy: margins) width.  Thus an attempt to resize the morph in autofit mode, if it changes the width, will cause the text to be recomposed with the new width, and then the bounds will be reset to the minimum enclosing rectangle.  Similarly, if the text contents are changed with the wrapFlag set to true, word wrap will be performed based on the current compostion width, after which the bounds will be set (or not), based on the autoFitcontents property.
  
  Note that fonts can only be applied to the TextMorph as a whole.  While you can change the size, color, and emphasis of a subsection of the text and have it apply to only that subsection, changing the font changes the font for the entire contents of the TextMorph. 
  
  Still a TextMorph can be composed of several texts of different fonts
  | font1 font2 t1 t2 tMorph|
  tMorph := TextMorph new.
  font1 := (TextFontReference toFont: (StrikeFont familyName: 'Atlanta' size: 22)).
  font2 := (TextFontReference toFont: (StrikeFont familyName: 'Atlanta' size: 11)).
  t1 := 'this is font1' asText addAttribute: font1.
  t2 := ' and this is font2' asText addAttribute: font2.
  tMorph contents: (t1,t2).
  tMorph openInHand.
  
  
  Yet to do:
  Make a comprehensive control for the eyedropper, with border width and color, inner color and text color, and margin widths.!

Item was added:
+ ----- Method: TextMorph>>readOnly (in category 'accessing') -----
+ readOnly
+ 
+ 	^ readOnly ifNil: [false]!

Item was added:
+ ----- Method: TextMorph>>readOnly: (in category 'accessing') -----
+ readOnly: aBoolean
+ 
+ 	readOnly := aBoolean.!

Item was changed:
  ----- Method: TextMorphForEditView>>keyStroke: (in category 'event handling') -----
  keyStroke: evt
  	| view |
  	editView deleteBalloon.
  	(editView scrollByKeyboard: evt) ifTrue: [^self].
  	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: [evt keyCharacter isAlphaNumeric or: [evt keyCharacter isSeparator]])
- 	(evt keyCharacter isAlphaNumeric or: [evt keyCharacter isSeparator])
  		ifTrue: [view textEdited: self contents].!



More information about the Squeak-dev mailing list