|
|
|
@ -380,7 +380,7 @@ char Fl_Text_Buffer::byte_at(int pos) const {
@@ -380,7 +380,7 @@ char Fl_Text_Buffer::byte_at(int pos) const {
|
|
|
|
|
Insert some text at the given index. |
|
|
|
|
Pos must be at a character boundary. |
|
|
|
|
*/ |
|
|
|
|
void Fl_Text_Buffer::insert(int pos, const char *text) |
|
|
|
|
void Fl_Text_Buffer::insert(int pos, const char *text, int insertedLength) |
|
|
|
|
{ |
|
|
|
|
IS_UTF8_ALIGNED2(this, (pos)) |
|
|
|
|
IS_UTF8_ALIGNED(text) |
|
|
|
@ -399,7 +399,7 @@ void Fl_Text_Buffer::insert(int pos, const char *text)
@@ -399,7 +399,7 @@ void Fl_Text_Buffer::insert(int pos, const char *text)
|
|
|
|
|
call_predelete_callbacks(pos, 0); |
|
|
|
|
|
|
|
|
|
/* insert and redisplay */ |
|
|
|
|
int nInserted = insert_(pos, text); |
|
|
|
|
int nInserted = insert_(pos, text, insertedLength); |
|
|
|
|
mCursorPosHint = pos + nInserted; |
|
|
|
|
IS_UTF8_ALIGNED2(this, (mCursorPosHint)) |
|
|
|
|
call_modify_callbacks(pos, 0, nInserted, 0, NULL); |
|
|
|
@ -454,7 +454,7 @@ void Fl_Text_Buffer::printf(const char *fmt, ...) {
@@ -454,7 +454,7 @@ void Fl_Text_Buffer::printf(const char *fmt, ...) {
|
|
|
|
|
Replace a range of text with new text. |
|
|
|
|
Start and end must be at a character boundary. |
|
|
|
|
*/ |
|
|
|
|
void Fl_Text_Buffer::replace(int start, int end, const char *text) |
|
|
|
|
void Fl_Text_Buffer::replace(int start, int end, const char *text, int insertedLength) |
|
|
|
|
{ |
|
|
|
|
// Range check...
|
|
|
|
|
if (!text) |
|
|
|
@ -471,7 +471,7 @@ void Fl_Text_Buffer::replace(int start, int end, const char *text)
@@ -471,7 +471,7 @@ void Fl_Text_Buffer::replace(int start, int end, const char *text)
|
|
|
|
|
call_predelete_callbacks(start, end - start); |
|
|
|
|
const char *deletedText = text_range(start, end); |
|
|
|
|
remove_(start, end); |
|
|
|
|
int nInserted = insert_(start, text); |
|
|
|
|
int nInserted = insert_(start, text, insertedLength); |
|
|
|
|
mCursorPosHint = start + nInserted; |
|
|
|
|
call_modify_callbacks(start, end - start, nInserted, 0, deletedText); |
|
|
|
|
free((void *) deletedText); |
|
|
|
@ -1355,12 +1355,12 @@ int Fl_Text_Buffer::search_backward(int startPos, const char *searchString,
@@ -1355,12 +1355,12 @@ int Fl_Text_Buffer::search_backward(int startPos, const char *searchString,
|
|
|
|
|
Insert a string into the buffer. |
|
|
|
|
Pos must be at a character boundary. Text must be a correct UTF-8 string. |
|
|
|
|
*/ |
|
|
|
|
int Fl_Text_Buffer::insert_(int pos, const char *text) |
|
|
|
|
int Fl_Text_Buffer::insert_(int pos, const char *text, int insertedLength) |
|
|
|
|
{ |
|
|
|
|
if (!text || !*text) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
int insertedLength = (int) strlen(text); |
|
|
|
|
if (insertedLength == -1) insertedLength = (int) strlen(text); |
|
|
|
|
|
|
|
|
|
/* Prepare the buffer to receive the new text. If the new text fits in
|
|
|
|
|
the current buffer, just move the gap (if necessary) to where |
|
|
|
|