> I've started a change/patch to r8507 as below, but it is incomplete (it 
> breaks the scroll in drawtext or somewhere else). The goal is to wrap long 
> lines of unbroken (un-spaced) text in an Fl_Multiline_Input widget.
>
> I'll appreciate knowing if someone else has already been down this road.
>
> DLT

Draft patch 2, working toward "wrap on word, else wrap on character if word is 
longer than the visible space". I can see that this breaks arrow/end/home 
navigation inside the text input field ... big problem. I'll stop the insanity 
here, rather than trying to reinvent the wheel.

Final application is calendar-like. I'm looking for a widget that wraps like a 
text editor, but is light enough that I can dynamically generate and move 
80-100 of them at a time, often, for just a few lines of text (1-10). Font 
styling not really necessary, so I figured the multiline input would be best.

Other ideas welcome!

DLT

--- Fl_Input_.cxx-original      2011-04-10 21:07:47.583326523 +1100
+++ Fl_Input_.cxx       2011-04-11 09:11:23.975809010 +1100
@@ -81,7 +81,8 @@
     }

   } else while (o<e) {
-    if (wrap() && (p >= value_+size_ || isspace(*p & 255))) {
+    if (wrap()) {
+      if (p >= value_+size_ || isspace(*p & 255)) {
       word_wrap = w() - Fl::box_dw(box()) - 2;
       width_to_lastspace += (int)fl_width(lastspace_out, o-lastspace_out);
       if (p > lastspace+1) {
@@ -89,10 +90,15 @@
          p = lastspace; o = lastspace_out; break;
        }
        word_count++;
-      }
+      }
       lastspace = p;
       lastspace_out = o;
-    }
+      }
+      else if ((int)fl_width(buf, o-buf) > w() - Fl::box_dw(box()) - 2) {
+         p--; o--; *o = 0;
+         return p;
+      } //end if (word longer than visible space)
+    } //end if wrap

     if (p >= value_+size_) break;
     int c = *p++ & 255;
@@ -259,6 +265,10 @@
       curx = int(expandpos(p, value()+position(), buf, 0)+.5);
       if (Fl::focus()==this && !was_up_down) up_down_pos = curx;
       cury = lines*height;
+
+      if(wrap() && input_type()==FL_MULTILINE_INPUT) {
+       curx = 0;
+      } else {
       int newscroll = xscroll_;
       if (curx > newscroll+W-threshold) {
        // figure out scrolling so there is space after the cursor:
@@ -275,10 +285,13 @@
        xscroll_ = newscroll;
        mu_p = 0; erase_cursor_only = 0;
       }
+      }
     }
     lines++;
     if (e >= value_+size_) break;
-    p = e+1;
+    if((*p & 255) == '\n')
+     p = e+1; //e is supposed to be a newline char ...
+    else p = e; // if it's not, don't skip a character.
   }

   // adjust the scrolling:

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

Reply via email to