The Trunk: Morphic-mt.1047.mcz

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

The Trunk: Morphic-mt.1047.mcz

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

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

Name: Morphic-mt.1047
Author: mt
Time: 19 November 2015, 10:25:04.425 am
UUID: f799616d-945d-4e5e-975d-9b03a1b2c9ba
Ancestors: Morphic-mt.1046

Makes intent/outdent via TAB resp. SHIFT+TAB more robust and fixes some bugs like replacing whitespace-only selections with tabs or indenting a block where the selection starts before the first character in a line.

=============== Diff against Morphic-mt.1046 ===============

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."
  (Character separators includes: typedChar)
  ifTrue: [self closeTypeIn].
 
  "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
+ and: [self hasSelection])
+ and: [self isInWhitespaceAtStartOfLine]) ifTrue: [
+ aKeyboardEvent shiftPressed
+ ifTrue: [self outdent: aKeyboardEvent]
+ ifFalse: [self indent: aKeyboardEvent].
+ ^ true].
- (typedChar == Character tab and: [self isInWhitespaceAtStartOfLine]) ifTrue: [
- aKeyboardEvent shiftPressed
- ifTrue: [self outdent: aKeyboardEvent]
- ifFalse: [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
  ifTrue: [((self hasSelection and: [self enclose: aKeyboardEvent])
  or: [self autoEncloseFor: typedChar])
  ifTrue: [^ true]].
 
  self normalCharacter: aKeyboardEvent.
  ^ false!

Item was changed:
  ----- Method: TextEditor>>isInWhitespaceAtStartOfLine (in category 'typing support') -----
  isInWhitespaceAtStartOfLine
+
+ ^ (self selectionStringFromBeginningOfLine allSatisfy: [:c| c isSeparator])
+ and: [self selection anySatisfy: [:c | c isSeparator not] "Ignore whitespace-only selections."]!
- ^self selectionStringFromBeginningOfLine allSatisfy: [:c| c isSeparator]!

Item was changed:
  ----- Method: TextEditor>>selectionStringFromBeginningOfLine (in category 'accessing-selection') -----
  selectionStringFromBeginningOfLine
+
+ ^ self paragraph string
+ copyFrom: (self beginningOfLine: self startIndex) to: self startIndex - 1!
- ^paragraph string copyFrom: (self beginningOfLine: self startBlock stringIndex) to: (self startBlock stringIndex min: paragraph string size)!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-mt.1047.mcz

marcel.taeumel


LEER means SPACE key.
TABULATOR means TAB key.

Best,
Marcel