[Pkg] The Trunk: Morphic-cmm.568.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Aug 17 00:42:27 UTC 2011
Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.568.mcz
==================== Summary ====================
Name: Morphic-cmm.568
Author: cmm
Time: 16 August 2011, 7:41:16.85 pm
UUID: 0e5f72e8-32fa-4608-bb91-f08260ecbab5
Ancestors: Morphic-nice.567
- Fixed Auto Enclose preference.
- Restored ability to use Control in lieu of Alt+Shift for enclosing with (, {, or double-quote.
=============== Diff against Morphic-nice.567 ===============
Item was changed:
----- Method: TextEditor class>>initializeShiftCmdKeyShortcuts (in category 'keyboard shortcut tables') -----
initializeShiftCmdKeyShortcuts
"Initialize the shift-command-key (or control-key) shortcut table."
"NOTE: if you don't know what your keyboard generates, use Sensor kbdTest"
"wod 11/3/1998: Fix setting of cmdMap for shifted keys to actually use the
capitalized versions of the letters.
TPR 2/18/99: add the plain ascii values back in for those VMs that don't return the shifted values."
"TextEditor initialize"
| cmdMap cmds |
"shift-command and control shortcuts"
cmdMap := Array new: 256 withAll: #noop:. "use temp in case of a crash"
cmdMap at: ( 1 + 1) put: #cursorHome:. "home key"
cmdMap at: ( 4 + 1) put: #cursorEnd:. "end key"
cmdMap at: ( 8 + 1) put: #forwardDelete:. "ctrl-H or delete key"
cmdMap at: (11 + 1) put: #cursorPageUp:. "page up key"
cmdMap at: (12 + 1) put: #cursorPageDown:. "page down key"
cmdMap at: (13 + 1) put: #crWithIndent:. "ctrl-Return"
cmdMap at: (27 + 1) put: #offerMenuFromEsc:. "escape key"
cmdMap at: (28 + 1) put: #cursorLeft:. "left arrow key"
cmdMap at: (29 + 1) put: #cursorRight:. "right arrow key"
cmdMap at: (30 + 1) put: #cursorUp:. "up arrow key"
cmdMap at: (31 + 1) put: #cursorDown:. "down arrow key"
cmdMap at: (32 + 1) put: #selectWord:. "space bar key"
cmdMap at: (45 + 1) put: #changeEmphasis:. "cmd-sh-minus"
cmdMap at: (61 + 1) put: #changeEmphasis:. "cmd-sh-plus"
cmdMap at: (127 + 1) put: #forwardDelete:. "del key"
"On some keyboards, these characters require a shift"
+ '([<{|"''9' do: [:char | cmdMap at: char asciiValue + 1 put: #enclose:].
- '([<{|"''' do: [:char | cmdMap at: char asciiValue + 1 put: #enclose:].
"NB: sw 12/9/2001 commented out the idiosyncratic line just below, which was grabbing shift-esc in the text editor and hence which argued with the wish to have shift-esc be a universal gesture for escaping the local context and calling up the desktop menu."
"cmdMap at: (27 + 1) put: #shiftEnclose:." "ctrl-["
"'""''(' do: [ :char | cmdMap at: (char asciiValue + 1) put: #enclose:]."
cmds := #(
$c compareToClipboard:
$d duplicate:
$h cursorTopHome:
$j doAgainMany:
$k changeStyle:
$l outdent:
$m selectCurrentTypeIn:
$r indent:
$s search:
$u changeLfToCr:
$x makeLowercase:
$y makeUppercase:
$z makeCapitalized:
).
1 to: cmds size by: 2 do: [ :i |
cmdMap at: ((cmds at: i) asciiValue + 1) put: (cmds at: i + 1). "plain keys"
cmdMap at: ((cmds at: i) asciiValue - 32 + 1) put: (cmds at: i + 1). "shifted keys"
cmdMap at: ((cmds at: i) asciiValue - 96 + 1) put: (cmds at: i + 1). "ctrl keys"
].
shiftCmdActions := cmdMap!
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 openers closers result |
(aKeyboardEvent keyCharacter == Character cr and: [ morph acceptOnCR ])
ifTrue: [
self closeTypeIn.
^ true ].
self clearParens.
aKeyboardEvent keyValue = 13
ifTrue: [
aKeyboardEvent controlKeyPressed
ifTrue: [ ^ self normalCharacter: aKeyboardEvent ].
aKeyboardEvent shiftPressed
ifTrue: [ ^ self lf: aKeyboardEvent ].
aKeyboardEvent commandKeyPressed
ifTrue: [ ^ self crlf: aKeyboardEvent ].
^ self crWithIndent: aKeyboardEvent ].
((honorCommandKeys := Preferences cmdKeysInText) and: [ aKeyboardEvent keyCharacter = 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 ].
- ifTrue: [ ^ self perform: (self class shiftCmdActions at: aKeyboardEvent keyValue + 1) with: aKeyboardEvent ].
openers := '([{'.
closers := ')]}'.
result := self normalCharacter: aKeyboardEvent.
(closers includes: aKeyboardEvent keyCharacter)
ifTrue: [ self blinkPrevParen: aKeyboardEvent ].
(self class autoEnclose and: [ openers includes: aKeyboardEvent keyCharacter ])
ifTrue: [
+ markBlock := pointBlock.
self addString: (closers at: (openers indexOf: aKeyboardEvent keyCharacter)) asString.
+ markBlock := pointBlock.
self moveCursor: [ :position | position - 1 ] forward: false select: false "no special behavior" ].
^ result!
Item was changed:
----- Method: TextEditor>>enclose: (in category 'editing keys') -----
enclose: aKeyboardEvent
"Insert or remove bracket characters around the current selection."
| left right startIndex stopIndex oldSelection which t |
self closeTypeIn.
startIndex := self startIndex.
stopIndex := self stopIndex.
oldSelection := self selection.
+ which := '([<{|"''9' indexOf: aKeyboardEvent keyCharacter ifAbsent: [ ^true ].
+ "Allow Control key in lieu of Alt+Shift for (, {, and double-quote."
+ left := ((Preferences cmdKeysInText and: [ aKeyboardEvent controlKeyPressed ])
+ ifTrue: [ '({<{|""(' ]
+ ifFalse: ['([<{|"''(']) at: which.
+ right := ((Preferences cmdKeysInText and: [ aKeyboardEvent controlKeyPressed ])
+ ifTrue: [ ')}>}|"")' ]
+ ifFalse: [')]>}|"'')']) at: which.
- which := '([<{|"''' indexOf: aKeyboardEvent keyCharacter ifAbsent: [ ^true ].
- left := '([<{|"''' at: which.
- right := ')]>}|"''' at: which.
t := self text.
((startIndex > 1 and: [stopIndex <= t size])
and: [ (t at: startIndex-1) = left and: [(t at: stopIndex) = right]])
ifTrue: [
"already enclosed; strip off brackets"
self selectFrom: startIndex-1 to: stopIndex.
self replaceSelectionWith: oldSelection]
ifFalse: [
"not enclosed; enclose by matching brackets"
self replaceSelectionWith:
(Text string: (String with: left), oldSelection string, (String with: right) attributes: emphasisHere).
self selectFrom: startIndex+1 to: stopIndex].
^true!
More information about the Packages
mailing list