From 936486cb1ccaba88add3b7caa984cdf841e019f1 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 17 Dec 2016 07:42:54 +0000 Subject: Handle non-ASCII characters when selecting a word or moving the cursor by one word. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12149 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Text_Display.cxx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/Fl_Text_Display.cxx') diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 52c506715..aacee88e6 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -1537,24 +1537,17 @@ int Fl_Text_Display::rewind_lines(int startPos, int nLines) { -static inline int fl_isseparator(unsigned int c) { - // FIXME: this does not take UCS-4 encoding into account - return c != '$' && c != '_' && (isspace(c) || ispunct(c)); -} - - - /** \brief Moves the current insert position right one word. */ void Fl_Text_Display::next_word() { int pos = insert_position(); - while (pos < buffer()->length() && !fl_isseparator(buffer()->char_at(pos))) { + while (pos < buffer()->length() && !buffer()->is_word_separator(pos)) { pos = buffer()->next_char(pos); } - while (pos < buffer()->length() && fl_isseparator(buffer()->char_at(pos))) { + while (pos < buffer()->length() && buffer()->is_word_separator(pos)) { pos = buffer()->next_char(pos); } @@ -1571,15 +1564,15 @@ void Fl_Text_Display::previous_word() { if (pos==0) return; pos = buffer()->prev_char(pos); - while (pos && fl_isseparator(buffer()->char_at(pos))) { + while (pos && buffer()->is_word_separator(pos)) { pos = buffer()->prev_char(pos); } - while (pos && !fl_isseparator(buffer()->char_at(pos))) { + while (pos && !buffer()->is_word_separator(pos)) { pos = buffer()->prev_char(pos); } - if (fl_isseparator(buffer()->char_at(pos))) { + if (buffer()->is_word_separator(pos)) { pos = buffer()->next_char(pos); } -- cgit v1.2.3