Unicode VM keyboard shortcut...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Unicode VM keyboard shortcut...

Chris Petsos
 
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.