diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2006-04-19 03:00:26 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2006-04-19 03:00:26 +0000 |
| commit | 1df4a9fb4a222b160c01e115539d983434f5a152 (patch) | |
| tree | 2a34f353c253c1c62fe3e0f9f7ef4c9c7c39b9df /src | |
| parent | c9908d97e3ab4e4d0cd87435c52aea88a5a4abc0 (diff) | |
STR #1195: It was not possible to enter a whole range of characters on Mac OS X, including umlauts, etc. . The changes in this patch should not only allow the FLTK way of composing characters, but also support the Mac way of composing including the dead-key preview.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4984 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_compose.cxx | 35 | ||||
| -rw-r--r-- | src/Fl_mac.cxx | 19 |
2 files changed, 51 insertions, 3 deletions
diff --git a/src/Fl_compose.cxx b/src/Fl_compose.cxx index 29a820d12..b76170d7e 100644 --- a/src/Fl_compose.cxx +++ b/src/Fl_compose.cxx @@ -26,7 +26,6 @@ // #include <FL/Fl.H> -#include <stdio.h> // // MRS: Uncomment the following define to get the original (pre-1.1.2) @@ -37,12 +36,27 @@ //#define OLD_DEAD_KEY_CODE +#ifdef __APPLE__ + static const char* const compose_pairs = +":A*A,C'E~N:O:U'a`a^a:a~a*a,c'e`e" +"^e:e'i`i^i:i~n'o`o^o:o~o'u`u^u:u" +"+ o /c# SS* P|ssrOcOTM' : !=AE/O" +"oo+-<=>=Y=mudtSgPipiS a dgOmaeo/" +"? ! !!v-f ~~Dt<<>>.. `A~A~OOEoe" +"- --''``\"'\"`:-^V:y:Y//E=< > fifl" +"++..,,_\"%%^A^E'A:E`E'I^I:I`I'O^O" +"mc`O'U^U`U||^ ~ _ u . * , ~ ; v "; + +#else + "=E _'f _\"..+ ++^ %%^S< OE ^Z ^''^^\"\"^-*- --~ TM^s> oe ^z:Y" " ! % # $ y=| & : c a <<~ - r _ * +-2 3 ' u p . , 1 o >>141234? " "`A'A^A~A:A*AAE,C`E'E^E:E`I'I^I:I-D~N`O'O^O~O:Ox O/`U'U^U:U'YTHss" "`a'a^a~a:a*aae,c`e'e^e:e`i'i^i:i-d~n`o'o^o~o:o-:o/`u'u^u:u'yth:y"; +#endif + #if !defined(WIN32) && defined(OLD_DEAD_KEY_CODE) // X only // X dead-key lookup table. This turns a dead-key keysym into the // first of two characters for one of the compose sequences. These @@ -120,6 +134,14 @@ int Fl::compose(int& del) { } else if (compose_state) { // second character of compose char c1 = char(compose_state); // retrieve first character +#ifdef __APPLE__ + if ( (c1==0x60 && ascii==0xab) || (c1==0x27 && ascii==0x60)) { + del = 1; + compose_state = '^'; + e_text[0] = 0xf6; + return 1; + } +#endif // now search for the pair in either order: for (const char *p = compose_pairs; *p; p += 2) { if (p[0] == ascii && p[1] == c1 || p[1] == ascii && p[0] == c1) { @@ -141,7 +163,14 @@ int Fl::compose(int& del) { } #ifdef WIN32 -//#elif (defined __APPLE__) +#elif (defined __APPLE__) + if (e_state & 0x40000000) { + if (ascii<0x80) + compose_state = ascii; + else + compose_state = compose_pairs[(ascii-0x80)*2]; + return 1; + } #else // See if they typed a dead key. This gets it into the same state as // typing prefix+accent: @@ -173,3 +202,5 @@ int Fl::compose(int& del) { return 0; } + + diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index 4693f8316..b8df6264b 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -1067,10 +1067,27 @@ pascal OSStatus carbonKeyboardHandler( { case kEventRawKeyDown: case kEventRawKeyRepeat: + // When the user presses a "dead key", no information is send about + // which dead key symbol was created. So we need to trick Carbon into + // giving us the code by sending a "space" after the "dead key". + if (key==0) { + UInt32 ktState = 0; + KeyboardLayoutRef klr; + KLGetCurrentKeyboardLayout(&klr); + const void *kchar = 0; KLGetKeyboardLayoutProperty(klr, kKLKCHRData, &kchar); + KeyTranslate(kchar, (mods&0xff00) | keyCode, &ktState); // send the dead key + key = KeyTranslate(kchar, 0x31, &ktState); // fake a space key press + Fl::e_state |= 0x40000000; // mark this as a dead key + } else { + Fl::e_state &= 0xbfffffff; // clear the deadkey flag + } sendEvent = FL_KEYBOARD; // fall through case kEventRawKeyUp: - if ( !sendEvent ) sendEvent = FL_KEYUP; + if ( !sendEvent ) { + sendEvent = FL_KEYUP; + Fl::e_state &= 0xbfffffff; // clear the deadkey flag + } // if the user pressed alt/option, event_key should have the keycap, // but event_text should generate the international symbol if ( isalpha(key) ) |
