diff options
| -rw-r--r-- | src/Fl_cocoa.mm | 21 | ||||
| -rw-r--r-- | src/Fl_compose.cxx | 35 |
2 files changed, 26 insertions, 30 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 6525a89e2..4b8a4232e 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2034,20 +2034,21 @@ static void q_set_window_title(NSWindow *nsw, const char * name, const char *mi @end void Fl_X::compose_state(int new_val) -{ // highlight marked text in text widgets +{ // select marked text in text widgets if (Fl::compose_state == 0 && new_val == 0) return; Fl::compose_state = new_val; Fl_Widget *widget = Fl::focus(); if (!widget) return; - if (dynamic_cast<Fl_Input_*>(widget) != NULL) { - if (dynamic_cast<Fl_Secret_Input*>(widget) != NULL) return; - Fl_Input_* input = (Fl_Input_*)widget; - input->mark( input->position() - Fl::compose_state ); - } - else if (dynamic_cast<Fl_Text_Display*>(widget) != NULL) { - Fl_Text_Display* input = (Fl_Text_Display*)widget; - int pos = input->insert_position(); - input->buffer()->highlight(pos - Fl::compose_state, pos); + + Fl_Input_* input = dynamic_cast<Fl_Input_*>(widget); + Fl_Text_Display* text; + if (input) { + if ( ! dynamic_cast<Fl_Secret_Input*>(input) ) + input->mark( input->position() - Fl::compose_state ); + } + else if ( text = dynamic_cast<Fl_Text_Display*>(widget) ) { + int pos = text->insert_position(); + text->buffer()->select(pos - Fl::compose_state, pos); } } diff --git a/src/Fl_compose.cxx b/src/Fl_compose.cxx index 870d2dc78..8aea820d1 100644 --- a/src/Fl_compose.cxx +++ b/src/Fl_compose.cxx @@ -46,33 +46,28 @@ extern XIC fl_xim_ic; other user-interface things to allow characters to be selected. */ int Fl::compose(int& del) { - // character composition is now handled by the OS - del = 0; + int condition; #if defined(__APPLE__) int has_text_key = Fl::compose_state || Fl::e_keysym <= '~' || Fl::e_keysym == FL_Iso_Key || - (Fl::e_keysym >= FL_KP && Fl::e_keysym <= FL_KP_Last && Fl::e_keysym != FL_KP_Enter); - if ( Fl::e_state&(FL_META | FL_CTRL) || + (Fl::e_keysym >= FL_KP && Fl::e_keysym <= FL_KP_Last && Fl::e_keysym != FL_KP_Enter); + condition = Fl::e_state&(FL_META | FL_CTRL) || (Fl::e_keysym >= FL_Shift_L && Fl::e_keysym <= FL_Alt_R) || // called from flagsChanged - !has_text_key ) { - // this stuff is to be treated as a function key - return 0; - } -#elif defined(WIN32) - unsigned char ascii = (unsigned)e_text[0]; - if ((e_state & (FL_ALT | FL_META)) && !(ascii & 128)) return 0; + !has_text_key ; #else - unsigned char ascii = (unsigned)e_text[0]; - if ((e_state & (FL_ALT | FL_META | FL_CTRL)) && !(ascii & 128)) return 0; +unsigned char ascii = (unsigned char)e_text[0]; +#if defined(WIN32) + condition = (e_state & (FL_ALT | FL_META)) && !(ascii & 128) ; +#else + condition = (e_state & (FL_ALT | FL_META | FL_CTRL)) && !(ascii & 128) ; +#endif #endif - if(Fl::compose_state) { - del = Fl::compose_state; + if (condition) { del = 0; return 0;} // this stuff is to be treated as a function key + del = Fl::compose_state; #ifndef __APPLE__ - Fl::compose_state = 0; - } else { - // Only insert non-control characters: - if (! (ascii & ~31 && ascii!=127)) { return 0; } + Fl::compose_state = 0; +// Only insert non-control characters: + if ( (!Fl::compose_state) && ! (ascii & ~31 && ascii!=127)) { return 0; } #endif - } return 1; } |
