[squeak-dev] Re: The Trunk: Morphic-cmm.977.mcz

karl ramberg karlramberg at gmail.com
Thu May 28 14:11:57 UTC 2015


Stéphane Rollandins fix should be in the release image.
That bug is really annoying

Karl

On Tue, May 19, 2015 at 3:20 PM, Stéphane Rollandin <lecteur at zogotounga.net>
wrote:

> It seems that "Auto Enclose" is not honored correctly. It is disabled in my
>> image but still seems to be enabled. :-(
>>
>> Try typing "()" then move the cursor between the parentheses and type the
>> closing one again. You will not end up with to closing ones...
>>
>
> Yes, I noticed that also, and it bothered me enough that I fixed it by
> modifying TextEditor>> #dispatchOnKeyboardEvent: as follow:
>
> ----------------------------------------------
>
> 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 ].
>         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
>         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 := ')]}'.
>         (closers includes: typedChar)
>                 ifTrue:
>                         [ self blinkPrevParen: typedChar.
>                         (self class autoEnclose and: [self
> nextNonwhitespaceCharacter = typedChar])
>                                 ifTrue:
>                                         [ 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
>
>
> ----------------------------------------------
>
> It looks like a correct fix to me.
>
> Best,
>
> Stef
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150528/e8147dca/attachment.htm


More information about the Squeak-dev mailing list