Author: manolo
Date: 2013-02-08 03:58:19 -0800 (Fri, 08 Feb 2013)
New Revision: 9816
Log:
Mac OS text input: removed the Fl::marked_text_length() function that's not 
necessary.

Modified:
   branches/branch-1.3/FL/Fl.H
   branches/branch-1.3/src/Fl_Input.cxx
   branches/branch-1.3/src/Fl_Input_.cxx
   branches/branch-1.3/src/Fl_Text_Display.cxx
   branches/branch-1.3/src/Fl_Text_Editor.cxx
   branches/branch-1.3/src/Fl_cocoa.mm
   branches/branch-1.3/src/Fl_compose.cxx

Modified: branches/branch-1.3/FL/Fl.H
===================================================================
--- branches/branch-1.3/FL/Fl.H 2013-02-05 16:04:05 UTC (rev 9815)
+++ branches/branch-1.3/FL/Fl.H 2013-02-08 11:58:19 UTC (rev 9816)
@@ -142,10 +142,9 @@
   static Fl_Widget* selection_owner_;
   static Fl_Window* modal_;
   static Fl_Window* grab_;
-  static int compose_state;
+  static int compose_state; // used for dead keys (WIN32) or marked text 
(MacOS)
   static void call_screen_init(); // recompute screen number and dimensions
 #ifdef __APPLE__
-  static int marked_text_length(void); // returns length of marked text
   static void reset_marked_text(); // resets marked text
   static void insertion_point_location(int x, int y, int height); // sets 
window coordinates & height of insertion point
 #endif

Modified: branches/branch-1.3/src/Fl_Input.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Input.cxx        2013-02-05 16:04:05 UTC (rev 
9815)
+++ branches/branch-1.3/src/Fl_Input.cxx        2013-02-08 11:58:19 UTC (rev 
9816)
@@ -359,8 +359,8 @@
                   Fl::event_text(), Fl::event_length());
     }
 #ifdef __APPLE__
-    if (Fl::marked_text_length()) {
-      this->mark( this->position() - Fl::marked_text_length() );
+    if (Fl::compose_state) {
+      this->mark( this->position() - Fl::compose_state );
       }
 #endif
     return 1;
@@ -592,7 +592,7 @@
   switch (event) {
 #ifdef __APPLE__
     case FL_UNFOCUS:
-      if (Fl::marked_text_length()) {
+      if (Fl::compose_state) {
        this->mark( this->position() );
        Fl::reset_marked_text();
       }
@@ -818,7 +818,7 @@
 int Fl_Secret_Input::handle(int event) {
   int retval = Fl_Input::handle(event);
 #ifdef __APPLE__
-  if (event == FL_KEYBOARD && Fl::marked_text_length()) {
+  if (event == FL_KEYBOARD && Fl::compose_state) {
     this->mark( this->position() ); // don't underline marked text
   }
 #endif

Modified: branches/branch-1.3/src/Fl_Input_.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Input_.cxx       2013-02-05 16:04:05 UTC (rev 
9815)
+++ branches/branch-1.3/src/Fl_Input_.cxx       2013-02-08 11:58:19 UTC (rev 
9816)
@@ -339,8 +339,8 @@
       int offset2;
       if (pp <= e) x2 = xpos + (float)expandpos(p, pp, buf, &offset2);
       else offset2 = (int) strlen(buf);
-#ifdef __APPLE__ // Mac OS: underline marked ( = selected + 
Fl::marked_text_length() != 0) text 
-      if (Fl::marked_text_length()) {
+#ifdef __APPLE__ // Mac OS: underline marked ( = selected + Fl::compose_state 
!= 0) text 
+      if (Fl::compose_state) {
         fl_color(textcolor());
       }
       else 
@@ -351,8 +351,8 @@
       fl_color(fl_contrast(textcolor(), selection_color()));
       }
       fl_draw(buf+offset1, offset2-offset1, x1, (float)(Y+ypos+desc));
-#ifdef __APPLE__ // Mac OS: underline marked ( = selected + 
Fl::marked_text_length() != 0) text
-      if (Fl::marked_text_length()) {
+#ifdef __APPLE__ // Mac OS: underline marked ( = selected + Fl::compose_state 
!= 0) text
+      if (Fl::compose_state) {
         fl_color( fl_color_average(textcolor(), color(), 0.6) );
         float width = fl_width(buf+offset1, offset2-offset1);
         fl_line(x1, Y+ypos+height-1, x1+width, Y+ypos+height-1);
@@ -374,7 +374,7 @@
     // draw the cursor:
     if (Fl::focus() == this && (
 #ifdef __APPLE__
-                               Fl::marked_text_length() || 
+                               Fl::compose_state || 
 #endif
                                selstart == selend) &&
        position() >= p-value() && position() <= e-value()) {

Modified: branches/branch-1.3/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Display.cxx 2013-02-05 16:04:05 UTC (rev 
9815)
+++ branches/branch-1.3/src/Fl_Text_Display.cxx 2013-02-08 11:58:19 UTC (rev 
9816)
@@ -1942,7 +1942,7 @@
     if (style & PRIMARY_MASK) {
       if (Fl::focus() == (Fl_Widget*)this) {
 #ifdef __APPLE__
-       if (Fl::marked_text_length()) background = color();// Mac OS: underline 
marked text
+       if (Fl::compose_state) background = color();// Mac OS: underline marked 
text
        else 
 #endif
        background = selection_color();
@@ -1978,8 +1978,8 @@
     fl_push_clip(X, Y, toX - X, mMaxsize);
 #endif
     fl_draw( string, nChars, X, Y + mMaxsize - fl_descent());
-#ifdef __APPLE__ // Mac OS: underline marked (= selected + 
Fl::marked_text_length() != 0) text
-    if (Fl::marked_text_length() && (style & PRIMARY_MASK)) {
+#ifdef __APPLE__ // Mac OS: underline marked (= selected + Fl::compose_state 
!= 0) text
+    if (Fl::compose_state && (style & PRIMARY_MASK)) {
       fl_color( fl_color_average(foreground, background, 0.6) );
       fl_line(X, Y + mMaxsize - 1, X + fl_width(string, nChars), Y + mMaxsize 
- 1);
     }
@@ -3476,7 +3476,7 @@
   if (damage() & (FL_DAMAGE_ALL | FL_DAMAGE_SCROLL | FL_DAMAGE_EXPOSE)
       && (
 #ifdef __APPLE__
-         Fl::marked_text_length() ||
+         Fl::compose_state ||
 #endif
          !has_selection || mCursorPos < start || mCursorPos > end) &&
       mCursorOn && Fl::focus() == (Fl_Widget*)this ) {

Modified: branches/branch-1.3/src/Fl_Text_Editor.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Editor.cxx  2013-02-05 16:04:05 UTC (rev 
9815)
+++ branches/branch-1.3/src/Fl_Text_Editor.cxx  2013-02-08 11:58:19 UTC (rev 
9816)
@@ -526,9 +526,9 @@
       else overstrike(Fl::event_text());
     }
 #ifdef __APPLE__
-    if (Fl::marked_text_length()) {
+    if (Fl::compose_state) {
       int pos = this->insert_position();
-      this->buffer()->select(pos - Fl::marked_text_length(), pos);
+      this->buffer()->select(pos - Fl::compose_state, pos);
       }
 #endif
     show_insert_position();
@@ -569,7 +569,7 @@
     case FL_UNFOCUS:
       show_cursor(mCursorOn); // redraws the cursor
 #ifdef __APPLE__
-      if (buffer()->selected() && Fl::marked_text_length()) {
+      if (buffer()->selected() && Fl::compose_state) {
        int pos = insert_position();
        buffer()->select(pos, pos);
        Fl::reset_marked_text();

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2013-02-05 16:04:05 UTC (rev 9815)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2013-02-08 11:58:19 UTC (rev 9816)
@@ -2055,8 +2055,8 @@
   } else {
     received = (NSString*)aString;
   }
-  /*NSLog(@"insertText=%@ l=%d Fl::marked_text_length()=%d range=%d,%d",
-       received,strlen([received 
UTF8String]),Fl::marked_text_length(),replacementRange.location,replacementRange.length);*/
+  /*NSLog(@"insertText=%@ l=%d Fl::compose_state=%d range=%d,%d",
+       received,strlen([received 
UTF8String]),Fl::compose_state,replacementRange.location,replacementRange.length);*/
   fl_lock_function();
   Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
   while (replacementRange.length--) { // delete replacementRange.length 
characters before insertion point
@@ -2075,7 +2075,7 @@
   // We can get called outside of key events (e.g., from the character 
palette, from CJK text input). 
   // Transform character palette actions to FL_PASTE events.
   Fl_X::next_marked_length = 0;
-  int flevent = (in_key_event || Fl::marked_text_length()) ? FL_KEYBOARD : 
FL_PASTE;
+  int flevent = (in_key_event || Fl::compose_state) ? FL_KEYBOARD : FL_PASTE;
   if (!in_key_event) Fl::handle( flevent, target);
   else need_handle = YES;
   selectedRange = NSMakeRange(100, 0); // 100 is an arbitrary value
@@ -2098,8 +2098,8 @@
     received = (NSString*)aString;
   }
   fl_lock_function();
-  /*NSLog(@"setMarkedText:%@ l=%d newSelection=%d,%d 
Fl::marked_text_length()=%d replacement=%d,%d", 
-       received, strlen([received UTF8String]), newSelection.location, 
newSelection.length, Fl::marked_text_length(),
+  /*NSLog(@"setMarkedText:%@ l=%d newSelection=%d,%d Fl::compose_state=%d 
replacement=%d,%d", 
+       received, strlen([received UTF8String]), newSelection.location, 
newSelection.length, Fl::compose_state,
        replacementRange.location, replacementRange.length);*/
   Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
   while (replacementRange.length--) { // delete replacementRange.length 
characters before insertion point
@@ -2137,13 +2137,13 @@
 }
 
 - (NSRange)markedRange {
-  //NSLog(@"markedRange=%d %d", Fl::marked_text_length() > 0?0:NSNotFound, 
Fl::marked_text_length());
-  return NSMakeRange(Fl::marked_text_length() > 0?0:NSNotFound, 
Fl::marked_text_length());
+  //NSLog(@"markedRange=%d %d", Fl::compose_state > 0?0:NSNotFound, 
Fl::compose_state);
+  return NSMakeRange(Fl::compose_state > 0?0:NSNotFound, Fl::compose_state);
 }
 
 - (BOOL)hasMarkedText {
-  //NSLog(@"hasMarkedText %s", Fl::marked_text_length() > 0?"YES":"NO");
-  return (Fl::marked_text_length() > 0);
+  //NSLog(@"hasMarkedText %s", Fl::compose_state > 0?"YES":"NO");
+  return (Fl::compose_state > 0);
 }
 
 - (NSAttributedString *)attributedSubstringFromRange:(NSRange)aRange {

Modified: branches/branch-1.3/src/Fl_compose.cxx
===================================================================
--- branches/branch-1.3/src/Fl_compose.cxx      2013-02-05 16:04:05 UTC (rev 
9815)
+++ branches/branch-1.3/src/Fl_compose.cxx      2013-02-08 11:58:19 UTC (rev 
9816)
@@ -54,8 +54,8 @@
  temporary text replaced by other text during the input process. This occurs,
  e.g., when using dead keys or when entering CJK characters.
  Text editing widgets should preferentially signal
- marked text, usually underlining it. Widgets can call
- <tt>int Fl::marked_text_length()</tt> <i>after</i> having called 
Fl::compose(int&)
+ marked text, usually underlining it. Widgets can use
+ <tt>int Fl::compose_state</tt> <i>after</i> having called Fl::compose(int&)
  to obtain the length in bytes of marked text that always finishes at the
  current insertion point. It's the widget's task to underline marked text.
  Widgets should also call <tt>void Fl::reset_marked_text()</tt> when 
processing FL_UNFOCUS
@@ -105,10 +105,6 @@
 }
 
 #ifdef __APPLE__
-int Fl::marked_text_length() {
-  return (Fl::compose_state ? Fl::compose_state : Fl_X::next_marked_length);
-  }
-
 static int insertion_point_x = 0;
 static int insertion_point_y = 0;
 static int insertion_point_height = 0;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to