[squeak-dev] The Inbox: Morphic-Richo.583.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Fri Oct 7 17:57:31 UTC 2011


2011/10/7 Levente Uzonyi <leves at elte.hu>:
> On Thu, 6 Oct 2011, Ricardo Moran wrote:
>
>> 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 :)
>
> These changes revert to the previous version of these methods. While it
> works with OCompletion, it doesn't work with TextEditor anymore.
> IMHO it's slightly better if #blinkPrevParen: receives a character, because
> it doesn't need the KeyboardEvent at all. I wonder why Juan and Nicolas
> decided to pass the event instead of the character.
>
>
> Levente
>

Ah good question.
I didn't review this design decision.
My goal was more to minimize the differences between Cuis-Squeak-Pharo.
We should ask Juan. Maybe it was a spirit of homogeneity between all
such methods: if we pass the event, we can handle shift/control
modifiers, whether or not this will be used is not our matter as a
framework.
But obviously, Cuis doesn't have the same constraints, so afterward,
this is questionnable.

Nicolas

>>
>> 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!
>>>
>>>
>>>
>>
>
>



More information about the Squeak-dev mailing list