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

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

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

Name: Morphic-mt.1053
Author: mt
Time: 22 November 2015, 2:45:14.467 pm
UUID: a55f6a5e-b5c9-4e64-9ffa-9cac6cbc8e54
Ancestors: Morphic-cmm.1052

Fixes undo for autoEnclose again.

=============== Diff against Morphic-cmm.1052 ===============

Item was changed:
  ----- Method: TextEditor>>autoEncloseFor: (in category 'typing support') -----
  autoEncloseFor: typedChar
  "Answer whether typeChar was handled by auto-enclosure.  Caller should call normalCharacter if not."
  | openers closers |
  openers := '([{'.
  closers := ')]}'.
  (closers includes: typedChar) ifTrue:
  [ | pos |
  self blinkPrevParen: typedChar.
  ((pos := self indexOfNextNonwhitespaceCharacter) notNil and: [ (paragraph string at: pos) = typedChar ])
  ifTrue:
  [ self
  moveCursor: [ : position | position + pos - pointBlock stringIndex + 1 ]
  forward: true
  select: false.
  ^ true ]
  ifFalse: [ ^ false ] ].
+ (openers includes: typedChar) ifTrue:
- (self class autoEnclose and: [ openers includes: typedChar ]) ifTrue:
  [ self
+ openTypeIn;
+ addString: typedChar asString;
+ addString: (closers at: (openers indexOf: typedChar)) asString;
+ insertAndCloseTypeIn;
- addString: (closers at: (openers indexOf: typedChar)) asString ;
- insertTypeAhead ;
 
  moveCursor: [ : position | position - 1 ]
  forward: false
  select: false.
+ ^ true ].
- ^ false ].
  ^ false!

Item was changed:
  ----- Method: TextEditor>>dispatchOnKeyboardEvent: (in category 'typing support') -----
  dispatchOnKeyboardEvent: aKeyboardEvent
  "Carry out the action associated with this character, if any. Type-ahead is passed so some routines can flush or use it."
 
  | honorCommandKeys typedChar |
  typedChar := aKeyboardEvent keyCharacter.
 
  "Create a new command for separating characters. Do not create separate commands for consecutive separators."
  ((Character separators includes: typedChar)
  and: [(Character separators includes: previousKeyCharacter) not])
  ifTrue: [self closeTypeIn].
  previousKeyCharacter := typedChar.
 
  "Handle one-line input fields."
  (typedChar == Character cr and: [morph acceptOnCR])
  ifTrue: [^ true].
 
  "Clear highlight for last opened parenthesis."
  self clearParens.
 
  "Handle line breaks and auto indent."
  typedChar == Character cr ifTrue: [
  aKeyboardEvent controlKeyPressed
  ifTrue: [^ self normalCharacter: aKeyboardEvent].
  aKeyboardEvent shiftPressed
  ifTrue: [^ self lf: aKeyboardEvent].
  aKeyboardEvent commandKeyPressed
  ifTrue: [^ self crlf: aKeyboardEvent].
  ^ self crWithIndent: aKeyboardEvent].
 
  "Handle indent/outdent with selected text block."
  typedChar == Character tab ifTrue: [
  aKeyboardEvent shiftPressed
  ifTrue: [self outdent: aKeyboardEvent. ^ true]
  ifFalse: [self hasMultipleLinesSelected
  ifTrue: [self indent: aKeyboardEvent. ^ true]]].
 
  honorCommandKeys := Preferences cmdKeysInText.
 
  (honorCommandKeys and: [typedChar == Character enter])
  ifTrue: [^ self dispatchOnEnterWith: aKeyboardEvent].
 
  "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: aKeyboardEvent keyValue)
  and: [aKeyboardEvent keyValue < 27])
  ifTrue: [^ aKeyboardEvent controlKeyPressed
  ifTrue: [self
  perform: (self class shiftCmdActions at: aKeyboardEvent keyValue + 1)
  with: aKeyboardEvent]
  ifFalse: [self
  perform: (self class cmdActions at: aKeyboardEvent keyValue + 1)
  with: aKeyboardEvent]].
 
  "backspace, and escape keys (ascii 8 and 27) are command keys"
  ((honorCommandKeys and: [aKeyboardEvent commandKeyPressed])
  or: [self class specialShiftCmdKeys includes: aKeyboardEvent keyValue])
  ifTrue: [ ^ aKeyboardEvent shiftPressed
  ifTrue: [self
  perform: (self class shiftCmdActions at: aKeyboardEvent keyValue + 1)
  with: aKeyboardEvent]
  ifFalse: [self
  perform: (self class cmdActions at: aKeyboardEvent keyValue + 1)
  with: aKeyboardEvent]].
 
  "the control key can be used to invoke shift-cmd shortcuts"
  (honorCommandKeys and: [ aKeyboardEvent controlKeyPressed ])
  ifTrue: [^ self
  perform: (self class shiftCmdActions at: aKeyboardEvent keyValue + 1)
  with: aKeyboardEvent].
 
+ "Automatically enclose paired characters such as brackets."
+ (self class autoEnclose and: [self autoEncloseFor: typedChar])
+ ifTrue: [^ true].
+
+ self normalCharacter: aKeyboardEvent.
- self class autoEnclose
- ifTrue:
- [ (self autoEncloseFor: typedChar) ifFalse: [ self normalCharacter: aKeyboardEvent ] ]
- ifFalse: [ self normalCharacter: aKeyboardEvent ].
-
  ^ false!