Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2011-10-22 13:28:10 +0400
committerDalai Felinto <dfelinto@gmail.com>2011-10-22 13:28:10 +0400
commitcac4fde224f3dfb2831779df7b61f819a3564e2d (patch)
tree647a8f2a5cc4ac40f171fd78064b123b3862237a /intern
parent8f4a01568460ad20c5a5c8a39feadea512e60d8f (diff)
utf8 OSX - cleanup
I still think utf8_buf can be 5 (4 bytes + '\0'), but even 6 may not be enough to what is coming next (NFC - precomposedStringWithCanonicalMapping) incorporating ascii as a subset of utf8. I don't think we need to re-encode it. U+0000 ~ U+00FF - latin1 set
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm43
1 files changed, 10 insertions, 33 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 1a6aaadb506..9ec8dd0abad 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1655,15 +1655,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
return GHOST_kFailure;
}
- /* unicode input - not entirely supported yet
- * but we are getting the right byte, Blender is not drawing it though
- * also some languages may need special treatment:
- - Japanese: romanji is used as input, and every 2 letters OSX converts the text
- to Hiragana/Katakana.
- - Korean: one add one letter at a time, and then the OSX join them in the equivalent
- combined letter.
- */
char utf8_buf[6]= {'\0'};
+ ascii = 0;
switch ([event type]) {
@@ -1678,32 +1671,18 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
keyCode = convertKey([event keyCode],0,
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
- /* ascii */
+ /* handling both unicode or ascii */
characters = [event characters];
- if ([characters length]>0) { //Check for dead keys
- //Convert characters to iso latin 1 encoding
- convertedCharacters = [characters dataUsingEncoding:NSISOLatin1StringEncoding];
- if ([convertedCharacters length]>0)
- ascii =((char*)[convertedCharacters bytes])[0];
- else
- ascii = 0; //Character not available in iso latin 1 encoding
- }
- else
- ascii= 0;
-
- /* unicode */
if ([characters length]>0) {
convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
- if ([convertedCharacters length]>0) {
- utf8_buf[0] = ((char*)[convertedCharacters bytes])[0];
- utf8_buf[1] = ((char*)[convertedCharacters bytes])[1];
- utf8_buf[2] = ((char*)[convertedCharacters bytes])[2];
- utf8_buf[3] = ((char*)[convertedCharacters bytes])[3];
- utf8_buf[4] = ((char*)[convertedCharacters bytes])[4];
- utf8_buf[5] = ((char*)[convertedCharacters bytes])[5];
+
+ for (int x = 0; x < [convertedCharacters length]; x++) {
+ utf8_buf[x] = ((char*)[convertedCharacters bytes])[x];
}
- else {
- utf8_buf[0] = '\0';
+
+ /* ascii is a subset of unicode */
+ if ([convertedCharacters length] == 1) {
+ ascii = utf8_buf[0];
}
}
@@ -1714,9 +1693,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) );
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
} else {
- // XXX Font Object bug - backspace or adding new chars are being computed twice (keydown and keyup)
- utf8_buf[0] = '\0';
- pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii, utf8_buf) );
+ pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, 0, '\0') );
//printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
}
break;