[squeak-dev] The Inbox: Morphic-Richo.583.mcz
Ricardo Moran
richi.moran at gmail.com
Thu Oct 6 19:43:02 UTC 2011
Hi guys,
Please review this commit if you have the time. I don't know how many of you
use OCompletion but this bug is really bothering me a lot, and programming
without #smartCharacters is not as nice :)
Thanks in advance!
Richo
On Thu, Oct 6, 2011 at 4:30 PM, <commits at source.squeak.org> wrote:
> A new version of Morphic was added to project The Inbox:
> http://source.squeak.org/inbox/Morphic-Richo.583.mcz
>
> ==================== Summary ====================
>
> Name: Morphic-Richo.583
> Author: Richo
> Time: 6 October 2011, 4:29:55.07 pm
> UUID: 4df53f26-036e-3c4a-8a98-af5e787d3ada
> Ancestors: Morphic-ul.582
>
> After installing OCompletion typing any of the following characters ')]}'
> signals an MNU: Character>>#keyCharacter.
>
> This commit seems to fix the problem by making
> SmalltalkEditor>>#blinkPrevParen: always receive a character instead of a
> KeyboardEvent.
>
> I lacked the courage to change TextEditor>>#blinkPrevParen: but I think it
> should be changed as well for consistency.
>
> =============== Diff against Morphic-ul.582 ===============
>
> Item was changed:
> ----- Method: SmalltalkEditor>>blinkPrevParen: (in category
> 'parenblinking') -----
> + blinkPrevParen: aCharacter
> - blinkPrevParen: aKeyboardEvent
> "Same as super, but tries to follow the Smalltalk syntax."
>
> | openDelimiter closeDelimiter level string here inside |
> string := paragraph text string.
> here := pointBlock stringIndex.
> + openDelimiter := aCharacter.
> - openDelimiter := aKeyboardEvent keyCharacter.
> closeDelimiter := '([{' at: (')]}' indexOf: openDelimiter).
> level := 1.
> inside := nil. "Tricky."
> (here > 1 and: [ (string at: here - 1) = $$ ]) ifTrue: [ ^self ].
> "Just a character literal."
> [ level > 0 and: [ here > 1 ] ] whileTrue: [
> | hereChar |
> hereChar := string at: (here := here - 1).
> inside "Are we inside a comment or string literal?"
> ifNotNil: [ "Yes."
> hereChar = inside ifTrue: [
> (here > 1 and: [ (string at: here -
> 1) ~= inside ])
> ifTrue: [ inside := nil ]
> ifFalse: [ here := here - 1
> ] ] ]
> ifNil: [
> (here > 1 and: [ (string at: here - 1) = $$
> ]) "Just a character literal."
> ifTrue: [ here := here - 1 ]
> ifFalse: [
> hereChar
> caseOf: {
> [
> closeDelimiter ] -> [
>
> (level := level - 1) = 0 ifTrue: [
>
> ^self blinkParenAt: here ] ].
> [
> openDelimiter ] -> [ level := level + 1 ].
> [ $" ] -> [
> inside := $" ].
> [ $' ] -> [
> inside := $' ] }
> otherwise: [] ] ] ]!
>
> 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 ].
> openers := '([{'.
> closers := ')]}'.
> result := self normalCharacter: aKeyboardEvent.
> (closers includes: aKeyboardEvent keyCharacter)
> + ifTrue: [ self blinkPrevParen: aKeyboardEvent
> keyCharacter].
> - ifTrue: [ self blinkPrevParen: aKeyboardEvent ].
> (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!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20111006/2515ae4c/attachment.htm
More information about the Squeak-dev
mailing list
|