A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-cmm.759.mcz ==================== Summary ==================== Name: Morphic-cmm.759 Author: cmm Time: 24 February 2015, 2:54:22.757 pm UUID: c7ecd89e-da26-47fb-8302-3ccaff6b9b54 Ancestors: Morphic-mt.758 Improved "Auto Enclose" preference to behave like it does in eclipse; when typing the closer (paren / bracket / curly), simply advance the cursor past it rather than insert an additional closer. =============== Diff against Morphic-mt.758 =============== 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 typedChar | + ((typedChar := aKeyboardEvent keyCharacter) == Character cr and: [ morph acceptOnCR ]) ifTrue: + [ self closeTypeIn. + ^ true ]. - 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: [ typedChar = Character enter ]) ifTrue: [ ^ self dispatchOnEnterWith: aKeyboardEvent ]. + "Special keys overwrite crtl+key combinations - at least on Windows. To resolve this - 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 ]. - ((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 ]. openers := '([{'. closers := ')]}'. + (closers includes: typedChar) + ifTrue: + [ self blinkPrevParen: typedChar. + self nextNonwhitespaceCharacter = typedChar + ifTrue: + [ [self nextNonwhitespaceCharacter = typedChar] whileTrue: [self + moveCursor: [ : position | position + 1 ] + forward: true + select: false ]. + ^ false ] + ifFalse: [ result := self normalCharacter: aKeyboardEvent ] ] + ifFalse: [ result := self normalCharacter: aKeyboardEvent ]. + (self class autoEnclose and: [ openers includes: typedChar ]) ifTrue: + [ self + addString: (closers at: (openers indexOf: typedChar)) asString ; + insertTypeAhead ; + + moveCursor: + [ : position | position - 1 ] + forward: false + select: false ]. - result := self normalCharacter: aKeyboardEvent. - (closers includes: aKeyboardEvent keyCharacter) - ifTrue: [ self blinkPrevParen: aKeyboardEvent keyCharacter]. - (self class autoEnclose and: [ openers includes: aKeyboardEvent keyCharacter ]) - ifTrue: [ - self - addString: (closers at: (openers indexOf: aKeyboardEvent keyCharacter)) asString; - insertTypeAhead ; - - moveCursor: [ :position | position - 1 ] - forward: false - select: false ]. ^ result! Item was added: + ----- Method: TextEditor>>nextNonwhitespaceCharacter (in category 'private') ----- + nextNonwhitespaceCharacter + pointBlock stringIndex + to: paragraph string size + do: + [ : n | | char | (char := paragraph string at: n) isSeparator ifFalse: [ ^ char ] ]. + ^ nil! |
Free forum by Nabble | Edit this page |