[Vm-dev] Unicode VM keyboard shortcut...

Chris Petsos chrispetsos at sch.gr
Tue Jun 5 10:39:43 UTC 2007


This is my work around for keyboard shortcuts with the Unicode VM...
The UnicodeInputInterpreter has this method 

nextCharFrom: sensor firstEvt: evtBuf

 | keyValue |
" Unicode charCode expected as the sixth data member ! "

"If Alt or Ctrl is pressed and we have a unicode char code... delegate shortcut conversion to the locale specific class..."
 (((evtBuf fifth = 2 or: [evtBuf fifth = 8])) and: [evtBuf sixth > 255])
  ifTrue: [
    keyValue := evtBuf sixth.
    ^ Character value:(((Locale currentPlatform) languageEnvironment) unicodeToLatinCharMap:keyValue).]

  ifFalse: [keyValue := evtBuf sixth.].
 ^ keyValue asCharacter.

(OK, it needs some refactoring but you get the clue...)

Now the specific locale class (for me is the GreekEnvironment class) must have an instance method called
    
    unicodeToLatinCharMap:charCode

that will convert the unicode char codes to MacRoman codes that work for the shortcuts.
I know the the all-around conversion back to MacRoman seems redundant, but at least we avoided the pollution of the unicode environment classes with locale specific code...

The trick was that we can get an instance of the current LanguageEnvironment, without referring to it, with

    (Locale currentPlatform) languageEnvironment

Good Smalltalk...good...

I don't know though for how long we are going to get away with it this way...

Christos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20070605/d900df14/attachment-0001.htm


More information about the Vm-dev mailing list