diff options
| -rw-r--r-- | CHANGES.txt | 1 | ||||
| -rw-r--r-- | FL/Fl_Input_.H | 3 | ||||
| -rw-r--r-- | src/Fl_Input_.cxx | 24 |
3 files changed, 28 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 2fa411fd6..95464c81e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -102,6 +102,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2019 Other Improvements - (add new items here) + - Added Fl_Input_::append() method (STR #2953). - Fix for STR#3473 (and its duplicate STR#3507) to restore configure-based builds on recent Linux/Unix distributions where the freetype-config command has been replaced by pkg-config. diff --git a/FL/Fl_Input_.H b/FL/Fl_Input_.H index 99a396506..c56b802b6 100644 --- a/FL/Fl_Input_.H +++ b/FL/Fl_Input_.H @@ -359,6 +359,9 @@ public: */ int insert(const char* t, int l=0){return replace(position_, mark_, t, l);} + /* Append text at the end. */ + int append(const char* t, int l=0, char keep_selection=0); + /* Put the current selection into the clipboard. */ int copy(int clipboard); diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx index ef6900d6e..7ca8ff0f9 100644 --- a/src/Fl_Input_.cxx +++ b/src/Fl_Input_.cxx @@ -744,6 +744,30 @@ static void undobuffersize(int n) { } /** + Append text at the end. + + This function appends the string in \p t to the end of the text. + It does not moves the new position or mark. + + \param [in] t text that will be appended + \param [in] l length of text, or 0 if the string is terminated by \c nul. + \param [in] keep_selection if this is 1, the current text selection will + remain, if 0, the cursor will move to the end of the inserted text. + \return 0 if no text was appended + */ +int Fl_Input_::append(const char* t, int l, char keep_selection) +{ + int end = size(); + int om = mark_, op = position_; + int ret = replace(end, end, t, l); + if (keep_selection) { + position(op, om); + } + return ret; +} + + +/** Deletes text from \p b to \p e and inserts the new string \p text. All changes to the text buffer go through this function. |
