diff --git a/src/include/Fl_Text_Buffer_mod_1_3.H b/src/include/Fl_Text_Buffer_mod_1_3.H index b6f29417..a3c4bcca 100644 --- a/src/include/Fl_Text_Buffer_mod_1_3.H +++ b/src/include/Fl_Text_Buffer_mod_1_3.H @@ -617,7 +617,10 @@ public: */ int search_backward(int startPos, const char* searchString, int* foundPos, int matchCase = 0) const; - + + int findchars_forward(int startPos, const char* searchChars, int* foundPos); + int findchars_backward(int startPos, const char* searchChars, int* foundPos); + /** Returns the primary selection. */ diff --git a/src/widgets/FTextView.cxx b/src/widgets/FTextView.cxx index 42d1fe66..96b50358 100644 --- a/src/widgets/FTextView.cxx +++ b/src/widgets/FTextView.cxx @@ -408,10 +408,10 @@ char* FTextBase::get_word(int x, int y, const char* nwchars, bool ontext) return tbuf->selection_text(); } -#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3 - start = tbuf->word_start(p); - end = tbuf->word_end(p); -#else +//#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR == 3 +// start = tbuf->word_start(p); +// end = tbuf->word_end(p); +//#else string nonword = nwchars; nonword.append(" \t\n"); if (!tbuf->findchars_backward(p, nonword.c_str(), &start)) @@ -420,7 +420,7 @@ char* FTextBase::get_word(int x, int y, const char* nwchars, bool ontext) start++; if (!tbuf->findchars_forward(p, nonword.c_str(), &end)) end = tbuf->length(); -#endif +//#endif if (ontext && (p < start || p >= end)) return 0; diff --git a/src/widgets/Fl_Text_Buffer_mod_1_3.cxx b/src/widgets/Fl_Text_Buffer_mod_1_3.cxx index fd88fed5..fc57b2cd 100644 --- a/src/widgets/Fl_Text_Buffer_mod_1_3.cxx +++ b/src/widgets/Fl_Text_Buffer_mod_1_3.cxx @@ -848,6 +848,35 @@ int Fl_Text_Buffer_mod::word_start(int pos) const { return pos; } +/* +** Search backwards in buffer for characters in "searchChars", starting +** with the character BEFORE "startPos", returning the result in "foundPos" +** returns 1 if found, 0 if not. +*/ +int Fl_Text_Buffer_mod::findchars_backward( int startPos, const char *searchChars, + int *foundPos ) { + int pos = startPos; + const char *c; + char ch = 0; + + if ( startPos == 0 ) { + *foundPos = 0; + return 0; + } + while ( pos > 0 ) { + ch = char_at(pos); + for ( c = searchChars; *c != '\0'; c++ ) { + if ( ch == *c ) { + *foundPos = pos; + return 1; + } + } + pos = prev_char(pos); + } + *foundPos = 0; + return 0; +} + /* Find the end of a word. @@ -862,6 +891,31 @@ int Fl_Text_Buffer_mod::word_end(int pos) const { return pos; } +/* +** Search forwards in buffer for characters in "searchChars", starting +** with the character "startPos", and returning the result in "foundPos" +** returns 1 if found, 0 if not. +*/ +int Fl_Text_Buffer_mod::findchars_forward( int startPos, const char *searchChars, + int *foundPos ) { + int pos = startPos; + const char *c; + char ch = 0; + + while ( pos < length() ) { + ch = char_at(pos); + for ( c = searchChars; *c != '\0'; c++ ) { + if ( ch == *c ) { + *foundPos = pos; + return 1; + } + } + pos = next_char(pos); + } + *foundPos = length(); + return 0; +} + /* Count the number of characters between two positions.