Added Fl_Input_::append() method (STR #2953).

This commit is contained in:
Matthias Melcher 2019-02-02 22:04:15 +01:00
parent 5062b5a010
commit 30733d2d8d
3 changed files with 28 additions and 0 deletions

View File

@ -102,6 +102,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2019
Other Improvements Other Improvements
- (add new items here) - (add new items here)
- Added Fl_Input_::append() method (STR #2953).
- Fix for STR#3473 (and its duplicate STR#3507) to restore configure-based - Fix for STR#3473 (and its duplicate STR#3507) to restore configure-based
builds on recent Linux/Unix distributions where the freetype-config builds on recent Linux/Unix distributions where the freetype-config
command has been replaced by pkg-config. command has been replaced by pkg-config.

View File

@ -359,6 +359,9 @@ public:
*/ */
int insert(const char* t, int l=0){return replace(position_, mark_, t, l);} 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. */ /* Put the current selection into the clipboard. */
int copy(int clipboard); int copy(int clipboard);

View File

@ -743,6 +743,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. Deletes text from \p b to \p e and inserts the new string \p text.