Author: manolo
Date: 2012-12-18 06:24:07 -0800 (Tue, 18 Dec 2012)
New Revision: 9763
Log:
Mac OS text input support: use primary selection for marked text in
Fl_Text_Display + some reformatting.
Modified:
branches/branch-1.3/src/Fl_cocoa.mm
branches/branch-1.3/src/Fl_compose.cxx
Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2012-12-17 20:49:29 UTC (rev 9762)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2012-12-18 14:24:07 UTC (rev 9763)
@@ -2034,20 +2034,21 @@
@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 );
+
+ 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 (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);
+ else if ( text = dynamic_cast<Fl_Text_Display*>(widget) ) {
+ int pos = text->insert_position();
+ text->buffer()->select(pos - Fl::compose_state, pos);
}
}
Modified: branches/branch-1.3/src/Fl_compose.cxx
===================================================================
--- branches/branch-1.3/src/Fl_compose.cxx 2012-12-17 20:49:29 UTC (rev
9762)
+++ branches/branch-1.3/src/Fl_compose.cxx 2012-12-18 14:24:07 UTC (rev
9763)
@@ -46,33 +46,28 @@
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
- if(Fl::compose_state) {
- del = Fl::compose_state;
+#endif
+ 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;
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit