diff options
Diffstat (limited to 'src/Fl_Input_.cxx')
| -rw-r--r-- | src/Fl_Input_.cxx | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx index ae4799e45..bebd08712 100644 --- a/src/Fl_Input_.cxx +++ b/src/Fl_Input_.cxx @@ -25,6 +25,14 @@ // http://www.fltk.org/str.php // +/** FIXME DOX: APIs not found + fn int Fl_Input_::wordboundary(int i) const + Returns true if position i is at the start or end of a word. + + fn int Fl_Input_::lineboundary(int i) const + Returns true if position i is at the start or end of a line. + +*/ // This is the base class for Fl_Input. You can use it directly // if you are one of those people who like to define their own // set of editing keys. It may also be useful for adding scrollbars @@ -165,6 +173,12 @@ void Fl_Input_::setfont() const { fl_font(textfont(), textsize()); } +/** + Draw the text in the passed bounding box. If damage() + & FL_DAMAGE_ALL is true, this assumes the area has + already been erased to color(). Otherwise it does + minimal update and erases the area itself. +*/ void Fl_Input_::drawtext(int X, int Y, int W, int H) { int do_mu = !(damage()&FL_DAMAGE_ALL); @@ -472,6 +486,7 @@ void Fl_Input_::handle_mouse(int X, int Y, int /*W*/, int /*H*/, int drag) { position(newpos, newmark); } +/** See int Fl_Input_::position() const */ int Fl_Input_::position(int p, int m) { int is_same = 0; was_up_down = 0; @@ -520,6 +535,12 @@ int Fl_Input_::position(int p, int m) { return 1; } +/** + Do the correct thing for arrow keys. Sets the position (and + mark if <I>keepmark</I> is zero) to somewhere in the same line + as <I>i</I>, such that pressing the arrows repeatedly will cause + the point to move up and down. +*/ int Fl_Input_::up_down_position(int i, int keepmark) { // unlike before, i must be at the start of the line already! @@ -539,6 +560,13 @@ int Fl_Input_::up_down_position(int i, int keepmark) { return j; } +/** + Put the current selection between mark() and + position() into the specified clipboard. Does not + replace the old clipboard contents if position() and + mark() are equal. Clipboard 0 maps to the current text + selection and clipboard 1 maps to the cut/paste clipboard. +*/ int Fl_Input_::copy(int clipboard) { int b = position(); int e = mark(); @@ -574,6 +602,29 @@ static void undobuffersize(int n) { } // all changes go through here, delete characters b-e and insert text: +/** + This call does all editing of the text. It deletes the region + between a and b (either one may be less or + equal to the other), and then inserts the string insert + at that point and leaves the mark() and + position() after the insertion. Does the callback if + when() & FL_WHEN_CHANGED and there is a change. + + <P>Set start and end equal to not delete + anything. Set insert to NULL to not insert + anything.</P> + + <P>length must be zero or strlen(insert), this + saves a tiny bit of time if you happen to already know the + length of the insertion, or can be used to insert a portion of a + string or a string containing nul's.</P> + + <P>a and b are clamped to the + 0..size() range, so it is safe to pass any values.</P> + + <P>cut() and insert() are just inline + functions that call replace(). +*/ int Fl_Input_::replace(int b, int e, const char* text, int ilen) { int ul, om, op; was_up_down = 0; @@ -669,6 +720,10 @@ int Fl_Input_::replace(int b, int e, const char* text, int ilen) { return 1; } +/** + Does undo of several previous calls to replace(). + Returns non-zero if any change was made. +*/ int Fl_Input_::undo() { was_up_down = 0; if (undowidget != this || !undocut && !undoinsert) return 0; @@ -709,6 +764,10 @@ int Fl_Input_::undo() { return 1; } +/** + Copy all the previous contiguous cuts from the undo + information to the clipboard. This is used to make ^K work. +*/ int Fl_Input_::copy_cuts() { // put the yank buffer into the X clipboard if (!yankcut || input_type()==FL_SECRET_INPUT) return 0; @@ -839,6 +898,11 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) { /*------------------------------*/ +/** + Creates a new Fl_Input_ widget using the given + position, size, and label string. The default boxtype is + FL_DOWN_BOX. +*/ Fl_Input_::Fl_Input_(int X, int Y, int W, int H, const char* l) : Fl_Widget(X, Y, W, H, l) { box(FL_DOWN_BOX); @@ -892,7 +956,7 @@ void Fl_Input_::put_in_buffer(int len) { memmove(buffer, value_, size_); buffer[size_] = 0; value_ = buffer; } - +/** See int Fl_Input::static_value(const char*) */ int Fl_Input_::static_value(const char* str, int len) { clear_changed(); if (undowidget == this) undowidget = 0; @@ -923,16 +987,27 @@ int Fl_Input_::static_value(const char* str, int len) { return 1; } +/** + Change the text and set the mark and the point to the end of + it. The string is <I>not</I> copied. If the user edits the + string it is copied to the internal buffer then. This can save a + great deal of time and memory if your program is rapidly + changing the values of text fields, but this will only work if + the passed string remains unchanged until either the + Fl_Input is destroyed or value() is called + again. +*/ int Fl_Input_::static_value(const char* str) { return static_value(str, str ? strlen(str) : 0); } - +/** See const char *Fl_Input_::value() const */ int Fl_Input_::value(const char* str, int len) { int r = static_value(str, len); if (len) put_in_buffer(len); return r; } +/** See const char *Fl_Input_::value() const */ int Fl_Input_::value(const char* str) { return value(str, str ? strlen(str) : 0); } |
