[squeak-dev] The Trunk: ST80-nice.63.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Nov 9 22:51:42 UTC 2009


Nicolas Cellier uploaded a new version of ST80 to project The Trunk:
http://source.squeak.org/trunk/ST80-nice.63.mcz

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

Name: ST80-nice.63
Author: nice
Time: 8 November 2009, 11:52:42 am
UUID: 7dfed6ff-83ed-4f76-ab2d-65eb00d6f78f
Ancestors: ST80-dtl.62

Fix from http://bugs.squeak.org/view.php?id=7071 for unicode character input

=============== Diff against ST80-dtl.62 ===============

Item was changed:
  ----- Method: ParagraphEditor>>readKeyboard (in category 'typing support') -----
  readKeyboard
  	"Key struck on the keyboard. Find out which one and, if special, carry 
  	out the associated special action. Otherwise, add the character to the 
  	stream of characters.  Undoer & Redoer: see closeTypeIn."
  
  	| typeAhead char |
  	typeAhead := WriteStream on: (String new: 128).
  	[sensor keyboardPressed] whileTrue: 
  		[self deselect.
  		 [sensor keyboardPressed] whileTrue: 
  			[char := sensor keyboardPeek.
  			(self dispatchOnCharacter: char with: typeAhead) ifTrue:
  				[self doneTyping.
  				self setEmphasisHere.
  				^self selectAndScroll; updateMarker].
  			self openTypeIn].
  		self hasSelection ifTrue: "save highlighted characters"
  			[UndoSelection := self selection]. 
+ 		self zapSelectionWithCompositionWith: typeAhead contents.
- 		self zapSelectionWith: 
- 			(Text string: typeAhead contents emphasis: emphasisHere).
  		typeAhead reset.
  		self unselect.
  		sensor keyboardPressed ifFalse: 
  			[self selectAndScroll.
  			sensor keyboardPressed
  				ifFalse: [self updateMarker]]]!

Item was added:
+ ----- Method: ParagraphEditor>>charBefore (in category 'accessing-selection') -----
+ charBefore
+ 
+ 	| start |
+ 	(start := self startIndex) > 1 ifTrue: [^ paragraph text at: start - 1].
+ 	^ nil.
+ !

Item was changed:
  ----- Method: ParagraphEditor>>dispatchOnCharacter:with: (in category 'parenblinking') -----
  dispatchOnCharacter: char with: typeAheadStream
  	"Carry out the action associated with this character, if any.
  	Type-ahead is passed so some routines can flush or use it."
  
  	| honorCommandKeys |
  	self clearParens.
    
  	"mikki 1/3/2005 21:31 Preference for auto-indent on return added."
  	char asciiValue = 13 ifTrue: [
  		^Preferences autoIndent 
  			ifTrue: [
  				sensor controlKeyPressed
  					ifTrue: [self normalCharacter: typeAheadStream]
  					ifFalse: [self crWithIndent: typeAheadStream]]
  			ifFalse: [
  				sensor controlKeyPressed
  					ifTrue: [self crWithIndent: typeAheadStream]
  					ifFalse: [self normalCharacter: typeAheadStream]]].
  
  	((honorCommandKeys := Preferences cmdKeysInText) and: [char = Character enter])
  		ifTrue: [^ self dispatchOnEnterWith: typeAheadStream].
  		
  	"Special keys overwrite crtl+key combinations - at least on Windows. To resolve this
  	conflict, assume that keys other than cursor keys aren't used together with Crtl." 
  	((self class specialShiftCmdKeys includes: char asciiValue) and: [char asciiValue < 27])
  		ifTrue: [^ sensor controlKeyPressed
  			ifTrue: [self perform: (ShiftCmdActions at: char asciiValue + 1) with: typeAheadStream]
  			ifFalse: [self perform: (CmdActions at: char asciiValue + 1) with: typeAheadStream]].
  
  	"backspace, and escape keys (ascii 8 and 27) are command keys"
  	((honorCommandKeys and: [sensor commandKeyPressed]) or: [self class specialShiftCmdKeys includes: char asciiValue]) ifTrue:
  		[^ sensor leftShiftDown
  			ifTrue:
+ 				[self perform: (ShiftCmdActions at: char asciiValue + 1 ifAbsent: [#noop:]) with: typeAheadStream]
- 				[self perform: (ShiftCmdActions at: char asciiValue + 1) with: typeAheadStream]
  			ifFalse:
+ 				[self perform: (CmdActions at: char asciiValue + 1 ifAbsent: [#noop:]) with: typeAheadStream]].
- 				[self perform: (CmdActions at: char asciiValue + 1) with: typeAheadStream]].
  
  	"the control key can be used to invoke shift-cmd shortcuts"
  	(honorCommandKeys and: [sensor controlKeyPressed])
  		ifTrue:
+ 			[^ self perform: (ShiftCmdActions at: char asciiValue + 1 ifAbsent: [#noop:]) with: typeAheadStream].
- 			[^ self perform: (ShiftCmdActions at: char asciiValue + 1) with: typeAheadStream].
  
  	(')]}' includes: char)
  		ifTrue: [self blinkPrevParen].
  
  	^ self perform: #normalCharacter: with: typeAheadStream!

Item was added:
+ ----- Method: ParagraphEditor>>wasComposition (in category 'accessing-selection') -----
+ wasComposition
+ 
+ 	^ wasComposition ifNil: [^ false].
+ !

Item was added:
+ ----- Method: ParagraphEditor>>zapSelectionWithCompositionWith: (in category 'accessing-selection') -----
+ zapSelectionWithCompositionWith: aString
+ 	"Deselect, and replace the selection text by aString.
+ 	 Remember the resulting selectionInterval in UndoInterval and otherInterval.
+ 	 Do not set up for undo."
+ 
+ 	| stream newString aText beforeChar |
+ 	wasComposition := false.
+ 	((aString isEmpty or: [(beforeChar := self charBefore) isNil]) or: [
+ 		aString size = 1 and: [(Unicode isComposition: aString first) not]]) ifTrue: [
+ 			^ self zapSelectionWith: (Text string: aString emphasis: emphasisHere)].
+ 
+ 	stream := UnicodeCompositionStream on: (String new: 16).
+ 	stream nextPut: beforeChar.
+ 	stream nextPutAll: aString.
+ 	newString := stream contents.
+ 	aText := Text string: newString emphasis: emphasisHere.
+ 	self markBlock < self pointBlock
+ 		ifTrue: [self setMark: self markBlock stringIndex - 1]
+ 		ifFalse: [self setPoint: self  pointBlock stringIndex - 1].
+ 
+ 	wasComposition := true. 
+ 	self zapSelectionWith: aText.
+ !

Item was changed:
  ----- Method: ParagraphEditor>>zapSelectionWith: (in category 'accessing-selection') -----
  zapSelectionWith: aText
  	"Deselect, and replace the selection text by aText.
  	 Remember the resulting selectionInterval in UndoInterval and otherInterval.
  	 Do not set up for undo."
  
  	| start stop |
  	self deselect.
  	start := self startIndex.
  	stop := self stopIndex.
  	(aText isEmpty and: [stop > start]) ifTrue:
  		["If deleting, then set emphasisHere from 1st character of the deletion"
  		emphasisHere := (paragraph text attributesAt: start forStyle: paragraph textStyle)
  					select: [:att | att mayBeExtended]].
  	(start = stop and: [aText size = 0]) ifFalse:
  		[paragraph
  			replaceFrom: start
  			to: stop - 1
  			with: aText
  			displaying: true.
  		self computeIntervalFrom: start to: start + aText size - 1.
+ 		self wasComposition ifTrue: [wasComposition := false. self setPoint: start + 1].
  		UndoInterval := otherInterval := self selectionInterval]!

Item was changed:
  ScrollController subclass: #ParagraphEditor
+ 	instanceVariableNames: 'paragraph startBlock stopBlock beginTypeInBlock emphasisHere initialText selectionShowing otherInterval lastParentLocation wasComposition'
- 	instanceVariableNames: 'paragraph startBlock stopBlock beginTypeInBlock emphasisHere initialText selectionShowing otherInterval lastParentLocation'
  	classVariableNames: 'ChangeText CmdActions FindText Keyboard ShiftCmdActions UndoInterval UndoMessage UndoParagraph UndoSelection Undone'
  	poolDictionaries: 'TextConstants'
  	category: 'ST80-Controllers'!
  
  !ParagraphEditor commentStamp: '<historical>' prior: 0!
  I am a Controller for editing a Paragraph. I am a kind of ScrollController, so that more text can be created for the Paragraph than can be viewed on the screen. Editing messages are sent by issuing commands from a yellow button menu or from keys on the keyboard. My instances keep control as long as the cursor is within the view when the red or yellow mouse button is pressed; they give up control if the blue button is pressed.!




More information about the Squeak-dev mailing list