diff options
| author | Manolo Gouy <Manolo> | 2010-10-26 21:01:17 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2010-10-26 21:01:17 +0000 |
| commit | 901bc31ec35c79ea245a2895ff7a80657d01cf8b (patch) | |
| tree | 488b52e672804a207ac229f912b55c6cae6f74c4 /src/Fl_compose.cxx | |
| parent | cac2ff33395798abaf2fa8a3041dea3819e4a36e (diff) | |
Use Mac OS-defined character composition method. It allows to handle composed characters of many more languages than before (e.g., Polish, Greek).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7759 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_compose.cxx')
| -rw-r--r-- | src/Fl_compose.cxx | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/src/Fl_compose.cxx b/src/Fl_compose.cxx index 3f2ff0bae..1601c74dd 100644 --- a/src/Fl_compose.cxx +++ b/src/Fl_compose.cxx @@ -37,14 +37,7 @@ //#define OLD_DEAD_KEY_CODE -#ifdef __APPLE__ - -static const char* const compose_pairs = -" ! % # $ y=| & : c a <<~ - r _ * +-2 3 ' u p . , 1 o >>141234? "//00A0 ... -"`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" //00C0 ... -"`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";//00E0 ... - -#else +#ifndef __APPLE__ static const char* const compose_pairs = "=E _'f _\"..+ ++^ %%^S< OE ^Z ^''^^\"\"^-*- --~ TM^s> oe ^z:Y" @@ -85,6 +78,26 @@ static char dead_keys[] = { int Fl::compose_state = 0; #endif +#ifdef __APPLE__ +// under Mac OS X character composition is handled by the OS +int Fl::compose(int& del) { + if(Fl::e_length == 0 || Fl::e_keysym == FL_Enter || Fl::e_keysym == FL_KP_Enter || + Fl::e_keysym == FL_Tab || Fl::e_keysym == FL_Escape || Fl::e_state&FL_META || Fl::e_state&FL_CTRL) { + del = 0; + return 0; + } + if(Fl::compose_state) { + del = 1; + Fl::compose_state = 0; + } + else { + del = 0; + } + return 1; +} + +#else + /** Any text editing widget should call this for each FL_KEYBOARD event. Use of this function is very simple. @@ -114,11 +127,7 @@ int Fl::compose(int& del) { // // OSX users sometimes need to hold down ALT for keys, so we only check // for META on OSX... -#ifdef __APPLE__ - if ((e_state & FL_META) && !(ascii & 128)) return 0; -#else if ((e_state & (FL_ALT|FL_META)) && !(ascii & 128)) return 0; -#endif // __APPLE__ if (compose_state == 1) { // after the compose key if ( // do not get distracted by any modifier keys @@ -134,15 +143,9 @@ int Fl::compose(int& del) { ) return 0; if (ascii == ' ') { // space turns into nbsp -#ifdef __APPLE__ - int len = fl_utf8encode(0xCA, e_text); - e_text[len] = '\0'; - e_length = len; - #else int len = fl_utf8encode(0xA0, e_text); e_text[len] = '\0'; e_length = len; -#endif compose_state = 0; return 1; } else if (ascii < ' ' || ascii == 127) { @@ -171,19 +174,6 @@ 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; - } - if (ascii==' ') { - del = 0; - compose_state = 0; - return 0; - } -#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) { @@ -206,16 +196,7 @@ int Fl::compose(int& del) { return 1; } -#ifdef WIN32 -#elif (defined __APPLE__) - if (e_state & 0x40000000) { - if (ascii<0x80) - compose_state = ascii; - else - compose_state = compose_pairs[(ascii-0x80)*2]; - return 1; - } -#else +#ifndef WIN32 // See if they typed a dead key. This gets it into the same state as // typing prefix+accent: if (i >= 0xfe50 && i <= 0xfe5b) { @@ -246,5 +227,9 @@ int Fl::compose(int& del) { return 0; } +#endif // __APPLE__ +// +// End of "$Id$" +// |
