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

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

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

Name: Morphic-mt.1116
Author: mt
Time: 19 April 2016, 9:21:38.183868 am
UUID: e4b5b353-a769-2744-9fca-6552c4c25e52
Ancestors: Morphic-mt.1115

Adds preference to enclose a selection with brackets etc. to bypass the respective (shift)cmd-key shortcuts, which actually do not work on German keyboard layouts.

Updates wording and preference categorization for other text editing preferences.

=============== Diff against Morphic-mt.1115 ===============

Item was changed:
  Editor subclass: #TextEditor
  instanceVariableNames: 'model paragraph markBlock pointBlock beginTypeInIndex emphasisHere lastParenLocation otherInterval oldInterval typeAhead history'
+ classVariableNames: 'AutoEnclose AutoIndent ChangeText EncloseSelection FindText'
- classVariableNames: 'AutoEnclose AutoIndent ChangeText FindText'
  poolDictionaries: ''
  category: 'Morphic-Text Support'!
  TextEditor class
  instanceVariableNames: 'cmdActions shiftCmdActions yellowButtonMenu shiftedYellowButtonMenu'!
 
  !TextEditor commentStamp: '<historical>' prior: 0!
  See comment in Editor.
 
  My instances edit Text, this is, they support multiple lines and TextAttributes.
  They have no specific facilities for editing Smalltalk code. Those are found in SmalltalkEditor.!
  TextEditor class
  instanceVariableNames: 'cmdActions shiftCmdActions yellowButtonMenu shiftedYellowButtonMenu'!

Item was changed:
+ ----- Method: TextEditor class>>autoEnclose (in category 'preferences') -----
- ----- Method: TextEditor class>>autoEnclose (in category 'accessing') -----
  autoEnclose
+ <preference: 'Auto enclose brackets () {} []'
+ categoryList: #('Morphic' 'editing')
- <preference: 'Auto Enclose'
- category: 'Morphic'
  description: 'When true, typing an opening parenthesis, bracket or square-bracket will also add its corresponding closing character in front of the cursor.'
  type: #Boolean>
+
  ^ AutoEnclose ifNil: [ false ]!

Item was changed:
+ ----- Method: TextEditor class>>autoEnclose: (in category 'preferences') -----
- ----- Method: TextEditor class>>autoEnclose: (in category 'accessing') -----
  autoEnclose: aBoolean
  AutoEnclose := aBoolean!

Item was changed:
+ ----- Method: TextEditor class>>autoIndent (in category 'preferences') -----
- ----- Method: TextEditor class>>autoIndent (in category 'accessing') -----
  autoIndent
+ <preference: 'Auto indent on new line'
+ categoryList: #('Morphic' 'editing')
- <preference: 'Auto Indent'
- category: 'Morphic'
  description: 'When true, tabs will be inserted after pressing Enter | Return such that the new line will be indented equally with the previous line.'
  type: #Boolean>
  ^ AutoIndent ifNil: [ true ]!

Item was changed:
+ ----- Method: TextEditor class>>autoIndent: (in category 'preferences') -----
- ----- Method: TextEditor class>>autoIndent: (in category 'accessing') -----
  autoIndent: aBoolean
  AutoIndent := aBoolean!

Item was added:
+ ----- Method: TextEditor class>>encloseSelection (in category 'preferences') -----
+ encloseSelection
+ <preference: 'Enclose selection with brackets () {} [] '''' "" || <>'
+ categoryList: #('Morphic' 'editing')
+ description: 'When true, selecting text and typing an opening parenthesis, bracket, square-bracket, single quote, or double quote will add corresponding character around the selection.'
+ type: #Boolean>
+
+ ^ EncloseSelection ifNil: [ false ]!

Item was added:
+ ----- Method: TextEditor class>>encloseSelection: (in category 'preferences') -----
+ encloseSelection: boolean
+
+ EncloseSelection := boolean.!

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.
 
  "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].
 
+ "Enclose selection with brackets etc."
+ ((self class encloseSelection and: [self hasSelection]) and: [self enclose: aKeyboardEvent])
+ ifTrue: [^ true].
+
  "Automatically enclose paired characters such as brackets."
  (self class autoEnclose and: [self autoEncloseFor: typedChar])
  ifTrue: [^ true].
 
  self normalCharacter: aKeyboardEvent.
  ^ false!