summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES13
-rw-r--r--src/Fl_Input_.cxx48
2 files changed, 39 insertions, 22 deletions
diff --git a/CHANGES b/CHANGES
index f927b140f..f2dafa3bc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,11 +1,12 @@
CHANGES IN FLTK 1.3.3 RELEASED: MMM DD YYYY
- - Mac OS X: fixed fl_read_image() and Fl_Paged_Device::print_window_part()
- when using a 'retina' display.
+ - Fix word select dragging bug in text input (STR #3014).
+ - Mac OS X: fixed fl_read_image() and Fl_Paged_Device::print_window_part()
+ when using a 'retina' display.
- on Linux/Unix, class Fl_Native_File_Chooser uses file dialogs of the Gnome
environment (provided by the libgtk dynamic library), when this is available,
and falls back to FLTK's Fl_File_Chooser, when it's not (STR #3088).
- - added class Fl_Copy_Surface allowing to copy graphical data to the clipboard
+ - added class Fl_Copy_Surface allowing to copy graphical data to the clipboard
in a cross-platform way (STR #3058).
- added support for pasting graphical data from the clipboard to an FLTK widget.
- added class Fl_Image_Surface allowing to draw into an Fl_Image object.
@@ -28,8 +29,8 @@ CHANGES IN FLTK 1.3.3 RELEASED: MMM
the output file extension gets changed when the user modifies the output file type.
- Removed the now unused src/Fl_mac.cxx
- Fixed various Mac specific opengl issues (STR #2944)
- - Added new method Fl_Widget::top_window() (STR #2948)
- - Added new method Fl_Widget::top_window_offset() (part of STR #2944)
+ - Added new method Fl_Widget::top_window() (STR #2948)
+ - Added new method Fl_Widget::top_window_offset() (part of STR #2944)
- Added ability to get notifications whenever the clipboard changes (STR#2636)
New methods:
Fl::add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data = 0)
@@ -42,7 +43,7 @@ CHANGES IN FLTK 1.3.3 RELEASED: MMM
(To enable the following ABI features, put: #define FLTK_ABI_VERSION 10303
at the top of your FL/Enumerations.H and rebuild FLTK and your app)
- - added Fl_Window::shape(const Fl_Image*) to create arbitrarily-shaped windows
+ - added Fl_Window::shape(const Fl_Image*) to create arbitrarily-shaped windows
- Made Fl_Help_View::handle() public and Fl_Help_View::draw() protected
to enable inheritance and for consistency (STR #2834).
Note: both methods were private.
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index 4f040b63c..a9caa5262 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -428,16 +428,17 @@ static int isword(char c) {
/**
Finds the end of a word.
- This call calculates the end of a word based on the given
- index \p i. Calling this function repeatedly will move
- forwards to the end of the text.
-
+ Returns the index after the last byte of a space-separated word. This
+ first skips spaces, and then non-spaces, so if you call it repeatedly
+ you will move forwards to the end of the text.
+
+ Note that this is inconsistent with line_end().
+
\param [in] i starting index for the search
\return end of the word
*/
int Fl_Input_::word_end(int i) const {
if (input_type() == FL_SECRET_INPUT) return size();
- //while (i < size() && !isword(index(i))) i++;
while (i < size() && !isword(index(i))) i++;
while (i < size() && isword(index(i))) i++;
return i;
@@ -446,17 +447,18 @@ int Fl_Input_::word_end(int i) const {
/**
Finds the start of a word.
- This call calculates the start of a word based on the given
- index \p i. Calling this function repeatedly will move
- backwards to the beginning of the text.
-
+ Returns the index of the first byte of a space-separated word.
+ If the index is already at the beginning of the word, it will find the
+ beginning of the previous word, so if you call it repeatedly you will
+ move backwards to the beginning of the text.
+
+ Note that this is inconsistent with line_start().
+
\param [in] i starting index for the search
- \return start of the word
+ \return start of the word, or previous word
*/
int Fl_Input_::word_start(int i) const {
if (input_type() == FL_SECRET_INPUT) return 0;
-// if (i >= size() || !isword(index(i)))
-// while (i > 0 && !isword(index(i-1))) i--;
while (i > 0 && !isword(index(i-1))) i--;
while (i > 0 && isword(index(i-1))) i--;
return i;
@@ -518,6 +520,20 @@ int Fl_Input_::line_start(int i) const {
} else return j;
}
+static int strict_word_start(const char *s, int i, int itype) {
+ if (itype == FL_SECRET_INPUT) return 0;
+ while (i > 0 && !isspace(s[i-1]))
+ i--;
+ return i;
+}
+
+static int strict_word_end(const char *s, int len, int i, int itype) {
+ if (itype == FL_SECRET_INPUT) return len;
+ while (i < len && !isspace(s[i]))
+ i++;
+ return i;
+}
+
/**
Handles mouse clicks and mouse moves.
\todo Add comment and parameters
@@ -571,16 +587,16 @@ void Fl_Input_::handle_mouse(int X, int Y, int /*W*/, int /*H*/, int drag) {
newpos = line_end(newpos);
newmark = line_start(newmark);
} else {
- newpos = word_end(newpos);
- newmark = word_start(newmark);
+ newpos = strict_word_end(value(), size(), newpos, input_type());
+ newmark = strict_word_start(value(), newmark, input_type());
}
} else {
if (Fl::event_clicks() > 1) {
newpos = line_start(newpos);
newmark = line_end(newmark);
} else {
- newpos = word_start(newpos);
- newmark = word_end(newmark);
+ newpos = strict_word_start(value(), newpos, input_type());
+ newmark = strict_word_end(value(), size(), newmark, input_type());
}
}
// if the multiple click does not increase the selection, revert