On Apr 28, 2013, at 7:47 PM, Denis Kudriashov <dionisiydk@gmail.com> wrote:

I upload new version 0.7:
- clipboard operations
- more navigation shortcuts
- fixed bugs when editing text from start or end text positions
- optimized text drawing to draw only visible lines
- optimized TxInterval>>contains:. So now #newTextContents: works on big strings

With this version I again investigate beautiful morphic events code (you should install slice 10427).
I add shortcuts "Character end ctrl" and "Character home ctrl" to move cursor at text end and start. And it was not work.
I debug what happens and KeyboardEvent from "Character home ctrl" was printed as ctrl+d. What's the crap!
Ok I found this code:

modifiedCharacter
    self flag: #hack.
    "Hack me.  When Ctrl is pressed, the key ascii value is not right and we have to do something ugly"
    ^(self controlKeyPressed and: [ (#(MacOSX Windows) includes: Smalltalk os current platformFamily) and: [ keyValue <= 26 ]])
        ifTrue: [ (self keyValue + $a asciiValue - 1) asCharacter ]   
        ifFalse: [ self keyCharacter ]

horrible!
As igor said this is not that we do not want but we have to pay attention to our ressources.


I don't know why such complicated code needed but with only "^self keyCharacter" you will replace many standart shortcuts with some random behaviour.
So I just extract special logic to method and put here special checking for home and end characters:

KeyboardEvent>>hasSpecialCTRLKeyValue
"
    4 - Character end
    1 - Character home
"

    ^ self controlKeyPressed and: [ keyValue <= 26 & (keyValue ~= 4) & (keyValue ~= 1) ]

And I remove dublication in printing keyboard event.

Slice with fix here https://pharo.fogbugz.com/default.asp?10427. Should I put it at configuration dependency?

I read about new events system at pharo vision. Is new system will remove such hacks?