Marked some more issues with Fl_Text_...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7462 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
b24875d8cd
commit
29317e7b2d
@ -196,17 +196,15 @@ public:
|
|||||||
/**
|
/**
|
||||||
Create an empty text buffer of a pre-determined size.
|
Create an empty text buffer of a pre-determined size.
|
||||||
\param requestedSize use this to avoid unnecessary re-allocation
|
\param requestedSize use this to avoid unnecessary re-allocation
|
||||||
if you know exactly how much the buffer will need to hold
|
if you know exactly how much the buffer will need to hold
|
||||||
\param preferredGapSize Initial size for the buffer gap (empty space
|
\param preferredGapSize Initial size for the buffer gap (empty space
|
||||||
in the buffer where text might be inserted
|
in the buffer where text might be inserted
|
||||||
if the user is typing sequential chars)
|
if the user is typing sequential chars)
|
||||||
\todo unicode check
|
|
||||||
*/
|
*/
|
||||||
Fl_Text_Buffer(int requestedSize = 0, int preferredGapSize = 1024);
|
Fl_Text_Buffer(int requestedSize = 0, int preferredGapSize = 1024);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Frees a text buffer
|
Frees a text buffer
|
||||||
\todo unicode check
|
|
||||||
*/
|
*/
|
||||||
~Fl_Text_Buffer();
|
~Fl_Text_Buffer();
|
||||||
|
|
||||||
@ -239,15 +237,16 @@ public:
|
|||||||
\param start byte offset to first character
|
\param start byte offset to first character
|
||||||
\param end byte offset after last character in range
|
\param end byte offset after last character in range
|
||||||
\return newly allocated text buffer - must be free'd
|
\return newly allocated text buffer - must be free'd
|
||||||
*/
|
*/
|
||||||
char* text_range(int start, int end) const;
|
char* text_range(int start, int end) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the character at the specified position pos in the buffer.
|
Returns the character at the specified position pos in the buffer.
|
||||||
Positions start at 0
|
Positions start at 0
|
||||||
\todo unicode check
|
\param pos byte offset into buffer
|
||||||
|
\return Unicode UCS-4 encoded character
|
||||||
*/
|
*/
|
||||||
char character(int pos) const;
|
unsigned int character(int pos) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the text from the given rectangle. When you are done
|
Returns the text from the given rectangle. When you are done
|
||||||
@ -258,7 +257,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Inserts null-terminated string \p text at position \p pos.
|
Inserts null-terminated string \p text at position \p pos.
|
||||||
\todo unicode check
|
\param pos insertion position as byte offset (must be utf-8 character aligned)
|
||||||
|
\param text utf-8 encoded and nul terminated text
|
||||||
*/
|
*/
|
||||||
void insert(int pos, const char* text);
|
void insert(int pos, const char* text);
|
||||||
|
|
||||||
@ -270,13 +270,16 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Deletes a range of characters in the buffer.
|
Deletes a range of characters in the buffer.
|
||||||
\todo unicode check
|
\param start byte offset to first character to be removed
|
||||||
|
\param end byte offset to charcatre after last character to be removed
|
||||||
*/
|
*/
|
||||||
void remove(int start, int end);
|
void remove(int start, int end);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Deletes the characters between \p start and \p end, and inserts the null-terminated string \p text in their place in the buffer.
|
Deletes the characters between \p start and \p end, and inserts the null-terminated string \p text in their place in the buffer.
|
||||||
\todo unicode check
|
\param start byte offset to first character to be removed and new insert position
|
||||||
|
\param end byte offset to charcatre after last character to be removed
|
||||||
|
\param text utf-8 encoded and nul terminated text
|
||||||
*/
|
*/
|
||||||
void replace(int start, int end, const char *text);
|
void replace(int start, int end, const char *text);
|
||||||
|
|
||||||
@ -296,7 +299,6 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Lets the undo system know if we can undo changes
|
Lets the undo system know if we can undo changes
|
||||||
\todo unicode check
|
|
||||||
*/
|
*/
|
||||||
void canUndo(char flag=1);
|
void canUndo(char flag=1);
|
||||||
|
|
||||||
|
@ -161,6 +161,8 @@ static void undobuffersize(int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unicode ok
|
||||||
Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize)
|
Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize)
|
||||||
{
|
{
|
||||||
mLength = 0;
|
mLength = 0;
|
||||||
@ -196,6 +198,8 @@ Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unicode ok
|
||||||
Fl_Text_Buffer::~Fl_Text_Buffer()
|
Fl_Text_Buffer::~Fl_Text_Buffer()
|
||||||
{
|
{
|
||||||
free(mBuf);
|
free(mBuf);
|
||||||
@ -221,6 +225,8 @@ char *Fl_Text_Buffer::text() const {
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unicode ok, functions called have not been verified yet
|
||||||
void Fl_Text_Buffer::text(const char *t)
|
void Fl_Text_Buffer::text(const char *t)
|
||||||
{
|
{
|
||||||
call_predelete_callbacks(0, length());
|
call_predelete_callbacks(0, length());
|
||||||
@ -230,14 +236,13 @@ void Fl_Text_Buffer::text(const char *t)
|
|||||||
int deletedLength = mLength;
|
int deletedLength = mLength;
|
||||||
free((void *) mBuf);
|
free((void *) mBuf);
|
||||||
|
|
||||||
/* Start a new buffer with a gap of mPreferredGapSize in the center */
|
/* Start a new buffer with a gap of mPreferredGapSize at the end */
|
||||||
int insertedLength = strlen(t);
|
int insertedLength = strlen(t);
|
||||||
mBuf = (char *) malloc(insertedLength + mPreferredGapSize);
|
mBuf = (char *) malloc(insertedLength + mPreferredGapSize);
|
||||||
mLength = insertedLength;
|
mLength = insertedLength;
|
||||||
mGapStart = insertedLength / 2;
|
mGapStart = insertedLength;
|
||||||
mGapEnd = mGapStart + mPreferredGapSize;
|
mGapEnd = mGapStart + mPreferredGapSize;
|
||||||
memcpy(mBuf, t, mGapStart);
|
memcpy(mBuf, t, insertedLength);
|
||||||
memcpy(&mBuf[mGapEnd], &t[mGapStart], insertedLength - mGapStart);
|
|
||||||
#ifdef PURIFY
|
#ifdef PURIFY
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -293,17 +298,17 @@ char *Fl_Text_Buffer::text_range(int start, int end) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME: a character must be UCS-4 encoded
|
// TODO: we will need the same signature function to get bytes (style buffer)
|
||||||
char Fl_Text_Buffer::character(int pos) const {
|
// unicode ok
|
||||||
|
unsigned int Fl_Text_Buffer::character(int pos) const {
|
||||||
if (pos < 0 || pos >= mLength)
|
if (pos < 0 || pos >= mLength)
|
||||||
return '\0';
|
return '\0';
|
||||||
if (pos < mGapStart)
|
const char *src = address(pos);
|
||||||
return mBuf[pos];
|
return fl_utf8decode(src, 0, 0);
|
||||||
else
|
|
||||||
return mBuf[pos + mGapEnd - mGapStart];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unicode ok, dependents not tested
|
||||||
void Fl_Text_Buffer::insert(int pos, const char *text)
|
void Fl_Text_Buffer::insert(int pos, const char *text)
|
||||||
{
|
{
|
||||||
/* if pos is not contiguous to existing text, make it */
|
/* if pos is not contiguous to existing text, make it */
|
||||||
@ -321,6 +326,8 @@ void Fl_Text_Buffer::insert(int pos, const char *text)
|
|||||||
call_modify_callbacks(pos, 0, nInserted, 0, NULL);
|
call_modify_callbacks(pos, 0, nInserted, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unicode ok, dependents not tested
|
||||||
void Fl_Text_Buffer::replace(int start, int end, const char *text)
|
void Fl_Text_Buffer::replace(int start, int end, const char *text)
|
||||||
{
|
{
|
||||||
// Range check...
|
// Range check...
|
||||||
@ -334,13 +341,14 @@ void Fl_Text_Buffer::replace(int start, int end, const char *text)
|
|||||||
call_predelete_callbacks(start, end - start);
|
call_predelete_callbacks(start, end - start);
|
||||||
const char *deletedText = text_range(start, end);
|
const char *deletedText = text_range(start, end);
|
||||||
remove_(start, end);
|
remove_(start, end);
|
||||||
//undoyankcut = undocut;
|
|
||||||
int nInserted = insert_(start, text);
|
int nInserted = insert_(start, text);
|
||||||
mCursorPosHint = start + nInserted;
|
mCursorPosHint = start + nInserted;
|
||||||
call_modify_callbacks(start, end - start, nInserted, 0, deletedText);
|
call_modify_callbacks(start, end - start, nInserted, 0, deletedText);
|
||||||
free((void *) deletedText);
|
free((void *) deletedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unicode ok, dependents not tested
|
||||||
void Fl_Text_Buffer::remove(int start, int end)
|
void Fl_Text_Buffer::remove(int start, int end)
|
||||||
{
|
{
|
||||||
/* Make sure the arguments make sense */
|
/* Make sure the arguments make sense */
|
||||||
@ -441,6 +449,8 @@ int Fl_Text_Buffer::undo(int *cursorPos)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// unicode ok
|
||||||
void Fl_Text_Buffer::canUndo(char flag)
|
void Fl_Text_Buffer::canUndo(char flag)
|
||||||
{
|
{
|
||||||
mCanUndo = flag;
|
mCanUndo = flag;
|
||||||
@ -918,26 +928,34 @@ remove_predelete_callback(Fl_Text_Predelete_Cb bufPreDeleteCB, void *cbArg)
|
|||||||
|
|
||||||
char *Fl_Text_Buffer::line_text(int pos) const {
|
char *Fl_Text_Buffer::line_text(int pos) const {
|
||||||
return text_range(line_start(pos), line_end(pos));
|
return text_range(line_start(pos), line_end(pos));
|
||||||
} int Fl_Text_Buffer::line_start(int pos) const {
|
}
|
||||||
|
|
||||||
|
int Fl_Text_Buffer::line_start(int pos) const {
|
||||||
if (!findchar_backward(pos, '\n', &pos))
|
if (!findchar_backward(pos, '\n', &pos))
|
||||||
return 0;
|
return 0;
|
||||||
return pos + 1;
|
return pos + 1;
|
||||||
} int Fl_Text_Buffer::line_end(int pos) const {
|
}
|
||||||
|
|
||||||
|
int Fl_Text_Buffer::line_end(int pos) const {
|
||||||
if (!findchar_forward(pos, '\n', &pos))
|
if (!findchar_forward(pos, '\n', &pos))
|
||||||
pos = mLength;
|
pos = mLength;
|
||||||
return pos;
|
return pos;
|
||||||
} int Fl_Text_Buffer::word_start(int pos) const {
|
}
|
||||||
while (pos && (isalnum(character(pos)) || character(pos) == '_'))
|
|
||||||
{
|
int Fl_Text_Buffer::word_start(int pos) const {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
|
while (pos && (isalnum(character(pos)) || character(pos) == '_')) {
|
||||||
pos--;
|
pos--;
|
||||||
} if (!(isalnum(character(pos)) || character(pos) == '_'))
|
}
|
||||||
|
// FIXME: character is ucs-4
|
||||||
|
if (!(isalnum(character(pos)) || character(pos) == '_'))
|
||||||
pos++;
|
pos++;
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Fl_Text_Buffer::word_end(int pos) const {
|
int Fl_Text_Buffer::word_end(int pos) const {
|
||||||
while (pos < length()
|
// FIXME: character is ucs-4
|
||||||
&& (isalnum(character(pos)) || character(pos) == '_'))
|
while (pos < length() && (isalnum(character(pos)) || character(pos) == '_'))
|
||||||
{
|
{
|
||||||
pos++;
|
pos++;
|
||||||
} return pos;
|
} return pos;
|
||||||
@ -1121,13 +1139,13 @@ int Fl_Text_Buffer::rewind_lines(int startPos, int nLines)
|
|||||||
|
|
||||||
int Fl_Text_Buffer::search_forward(int startPos, const char *searchString,
|
int Fl_Text_Buffer::search_forward(int startPos, const char *searchString,
|
||||||
int *foundPos,
|
int *foundPos,
|
||||||
int matchCase) const {
|
int matchCase) const
|
||||||
|
{
|
||||||
if (!searchString)
|
if (!searchString)
|
||||||
return 0;
|
return 0;
|
||||||
int bp;
|
int bp;
|
||||||
const char *sp;
|
const char *sp;
|
||||||
while (startPos < length())
|
while (startPos < length()) {
|
||||||
{
|
|
||||||
bp = startPos;
|
bp = startPos;
|
||||||
sp = searchString;
|
sp = searchString;
|
||||||
do {
|
do {
|
||||||
@ -1135,6 +1153,7 @@ int Fl_Text_Buffer::search_forward(int startPos, const char *searchString,
|
|||||||
*foundPos = startPos;
|
*foundPos = startPos;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
// FIXME: character is ucs-4
|
||||||
} while ((matchCase ? character(bp++) == *sp++ :
|
} while ((matchCase ? character(bp++) == *sp++ :
|
||||||
toupper(character(bp++)) == toupper(*sp++))
|
toupper(character(bp++)) == toupper(*sp++))
|
||||||
&& bp < length());
|
&& bp < length());
|
||||||
@ -1159,6 +1178,7 @@ int Fl_Text_Buffer::search_backward(int startPos, const char *searchString,
|
|||||||
*foundPos = bp + 1;
|
*foundPos = bp + 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
// FIXME: character is ucs-4
|
||||||
} while ((matchCase ? character(bp--) == *sp-- :
|
} while ((matchCase ? character(bp--) == *sp-- :
|
||||||
toupper(character(bp--)) == toupper(*sp--))
|
toupper(character(bp--)) == toupper(*sp--))
|
||||||
&& bp >= 0);
|
&& bp >= 0);
|
||||||
@ -1331,7 +1351,7 @@ void Fl_Text_Buffer::insert_column_(int column, int startPos,
|
|||||||
is counted with the length of insText) */
|
is counted with the length of insText) */
|
||||||
int start = line_start(startPos);
|
int start = line_start(startPos);
|
||||||
int nLines = countLines(insText) + 1;
|
int nLines = countLines(insText) + 1;
|
||||||
int insWidth = textWidth(insText, mTabDist);
|
int insWidth = textWidth(insText, mTabDist); // this function probably returns a useless value
|
||||||
int end = line_end(skip_lines(start, nLines - 1));
|
int end = line_end(skip_lines(start, nLines - 1));
|
||||||
int expReplLen, expInsLen, len, endOffset;
|
int expReplLen, expInsLen, len, endOffset;
|
||||||
const char *replText = text_range(start, end);
|
const char *replText = text_range(start, end);
|
||||||
@ -2137,14 +2157,15 @@ static int textWidth(const char *text, int tabDist)
|
|||||||
{
|
{
|
||||||
int width = 0, maxWidth = 0;
|
int width = 0, maxWidth = 0;
|
||||||
|
|
||||||
for (const char *c = text; *c != '\0'; c++) { // FIXME: increment is wrong!
|
// HUH? Why is "c" incremented? Shouldn't "text" be incrmented?
|
||||||
|
// FIXME: increment is wrong!
|
||||||
|
for (const char *c = text; *c != '\0'; c++) {
|
||||||
if (*c == '\n') {
|
if (*c == '\n') {
|
||||||
if (width > maxWidth)
|
if (width > maxWidth)
|
||||||
maxWidth = width;
|
maxWidth = width;
|
||||||
width = 0;
|
width = 0;
|
||||||
} else
|
} else
|
||||||
width +=
|
width += Fl_Text_Buffer::character_width(c, width, tabDist);
|
||||||
Fl_Text_Buffer::character_width(c, width, tabDist);
|
|
||||||
}
|
}
|
||||||
if (width > maxWidth)
|
if (width > maxWidth)
|
||||||
return width;
|
return width;
|
||||||
@ -2163,11 +2184,12 @@ void Fl_Text_Buffer::rectangular_selection_boundaries(int lineStartPos,
|
|||||||
/* find the start of the selection */
|
/* find the start of the selection */
|
||||||
for (pos = lineStartPos; pos < mLength; pos++)
|
for (pos = lineStartPos; pos < mLength; pos++)
|
||||||
{
|
{
|
||||||
|
// FIXME: character is ucs-4
|
||||||
c = character(pos);
|
c = character(pos);
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
width =
|
width =
|
||||||
Fl_Text_Buffer::character_width(&c, indent, mTabDist); // FIXME: c si not unicode
|
Fl_Text_Buffer::character_width(&c, indent, mTabDist); // FIXME: c is not unicode
|
||||||
if (indent + width > rectStart) {
|
if (indent + width > rectStart) {
|
||||||
if (indent != rectStart && c != '\t') {
|
if (indent != rectStart && c != '\t') {
|
||||||
pos++;
|
pos++;
|
||||||
@ -2181,6 +2203,7 @@ void Fl_Text_Buffer::rectangular_selection_boundaries(int lineStartPos,
|
|||||||
|
|
||||||
/* find the end */
|
/* find the end */
|
||||||
for (; pos < mLength; pos++) {
|
for (; pos < mLength; pos++) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
c = character(pos);
|
c = character(pos);
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
@ -2338,7 +2361,7 @@ int Fl_Text_Buffer::outputfile(const char *file, int start, int end,
|
|||||||
int buflen)
|
int buflen)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
if (!(fp = fl_fopen(file, "w")))
|
if (!(fp = fl_fopen(file, "wb")))
|
||||||
return 1;
|
return 1;
|
||||||
for (int n; (n = min(end - start, buflen)); start += n) {
|
for (int n; (n = min(end - start, buflen)); start += n) {
|
||||||
const char *p = text_range(start, start + n);
|
const char *p = text_range(start, start + n);
|
||||||
|
@ -426,6 +426,7 @@ void Fl_Text_Display::draw_text( int left, int top, int width, int height ) {
|
|||||||
void Fl_Text_Display::redisplay_range(int startpos, int endpos) {
|
void Fl_Text_Display::redisplay_range(int startpos, int endpos) {
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
while (!ok && startpos > 0) {
|
while (!ok && startpos > 0) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( startpos );
|
char c = buffer()->character( startpos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) {
|
if (!((c & 0x80) && !(c & 0x40))) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
@ -434,6 +435,7 @@ void Fl_Text_Display::redisplay_range(int startpos, int endpos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (!ok && endpos < buffer()->length()) {
|
while (!ok && endpos < buffer()->length()) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( endpos );
|
char c = buffer()->character( endpos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) {
|
if (!((c & 0x80) && !(c & 0x40))) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
@ -638,6 +640,7 @@ void Fl_Text_Display::overstrike(const char* text) {
|
|||||||
for ( p = startPos; ; p++ ) {
|
for ( p = startPos; ; p++ ) {
|
||||||
if ( p == buf->length() )
|
if ( p == buf->length() )
|
||||||
break;
|
break;
|
||||||
|
// FIXME: character is ucs-4
|
||||||
ch = buf->character( p );
|
ch = buf->character( p );
|
||||||
if ( ch == '\n' )
|
if ( ch == '\n' )
|
||||||
break;
|
break;
|
||||||
@ -779,6 +782,7 @@ int Fl_Text_Display::in_selection( int X, int Y ) const {
|
|||||||
Fl_Text_Buffer *buf = mBuffer;
|
Fl_Text_Buffer *buf = mBuffer;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
while (!ok) {
|
while (!ok) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( pos );
|
char c = buffer()->character( pos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) {
|
if (!((c & 0x80) && !(c & 0x40))) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
@ -894,6 +898,7 @@ int Fl_Text_Display::move_right() {
|
|||||||
return 0;
|
return 0;
|
||||||
insert_position( mCursorPos + 1 );
|
insert_position( mCursorPos + 1 );
|
||||||
int pos = insert_position();
|
int pos = insert_position();
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( pos );
|
char c = buffer()->character( pos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) ok = 1;
|
if (!((c & 0x80) && !(c & 0x40))) ok = 1;
|
||||||
}
|
}
|
||||||
@ -907,6 +912,7 @@ int Fl_Text_Display::move_left() {
|
|||||||
return 0;
|
return 0;
|
||||||
insert_position( mCursorPos - 1 );
|
insert_position( mCursorPos - 1 );
|
||||||
int pos = insert_position();
|
int pos = insert_position();
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( pos );
|
char c = buffer()->character( pos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) ok = 1;
|
if (!((c & 0x80) && !(c & 0x40))) ok = 1;
|
||||||
}
|
}
|
||||||
@ -947,6 +953,7 @@ int Fl_Text_Display::move_up() {
|
|||||||
int ok = 0;
|
int ok = 0;
|
||||||
while (!ok) {
|
while (!ok) {
|
||||||
int pos = insert_position();
|
int pos = insert_position();
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( pos );
|
char c = buffer()->character( pos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) {
|
if (!((c & 0x80) && !(c & 0x40))) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
@ -983,6 +990,7 @@ int Fl_Text_Display::move_down() {
|
|||||||
int ok = 0;
|
int ok = 0;
|
||||||
while (!ok) {
|
while (!ok) {
|
||||||
int pos = insert_position();
|
int pos = insert_position();
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( pos );
|
char c = buffer()->character( pos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) {
|
if (!((c & 0x80) && !(c & 0x40))) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
@ -1132,9 +1140,11 @@ static inline int fl_isseparator(int c) {
|
|||||||
/** Moves the current insert position right one word.*/
|
/** Moves the current insert position right one word.*/
|
||||||
void Fl_Text_Display::next_word() {
|
void Fl_Text_Display::next_word() {
|
||||||
int pos = insert_position();
|
int pos = insert_position();
|
||||||
|
// FIXME: character is ucs-4
|
||||||
while (pos < buffer()->length() && !fl_isseparator(buffer()->character(pos))) {
|
while (pos < buffer()->length() && !fl_isseparator(buffer()->character(pos))) {
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
// FIXME: character is ucs-4
|
||||||
while (pos < buffer()->length() && fl_isseparator(buffer()->character(pos))) {
|
while (pos < buffer()->length() && fl_isseparator(buffer()->character(pos))) {
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
@ -1147,12 +1157,15 @@ void Fl_Text_Display::previous_word() {
|
|||||||
int pos = insert_position();
|
int pos = insert_position();
|
||||||
if (pos==0) return;
|
if (pos==0) return;
|
||||||
pos--;
|
pos--;
|
||||||
|
// FIXME: character is ucs-4
|
||||||
while (pos && fl_isseparator(buffer()->character(pos))) {
|
while (pos && fl_isseparator(buffer()->character(pos))) {
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
|
// FIXME: character is ucs-4
|
||||||
while (pos && !fl_isseparator(buffer()->character(pos))) {
|
while (pos && !fl_isseparator(buffer()->character(pos))) {
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
|
// FIXME: character is ucs-4
|
||||||
if (fl_isseparator(buffer()->character(pos))) pos++;
|
if (fl_isseparator(buffer()->character(pos))) pos++;
|
||||||
|
|
||||||
insert_position( pos );
|
insert_position( pos );
|
||||||
@ -1820,10 +1833,12 @@ int Fl_Text_Display::position_style( int lineStartPos,
|
|||||||
if ( lineIndex >= lineLen )
|
if ( lineIndex >= lineLen )
|
||||||
style = FILL_MASK;
|
style = FILL_MASK;
|
||||||
else if ( styleBuf != NULL ) {
|
else if ( styleBuf != NULL ) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
style = ( unsigned char ) styleBuf->character( pos );
|
style = ( unsigned char ) styleBuf->character( pos );
|
||||||
if (style == mUnfinishedStyle && mUnfinishedHighlightCB) {
|
if (style == mUnfinishedStyle && mUnfinishedHighlightCB) {
|
||||||
/* encountered "unfinished" style, trigger parsing */
|
/* encountered "unfinished" style, trigger parsing */
|
||||||
(mUnfinishedHighlightCB)( pos, mHighlightCBArg);
|
(mUnfinishedHighlightCB)( pos, mHighlightCBArg);
|
||||||
|
// FIXME: character is ucs-4
|
||||||
style = (unsigned char) styleBuf->character( pos);
|
style = (unsigned char) styleBuf->character( pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2344,6 +2359,7 @@ int Fl_Text_Display::measure_vline( int visLineNum ) const {
|
|||||||
for ( i = 0; i < lineLen; i++ ) {
|
for ( i = 0; i < lineLen; i++ ) {
|
||||||
len = mBuffer->expand_character( lineStartPos + i,
|
len = mBuffer->expand_character( lineStartPos + i,
|
||||||
charCount, expandedChar );
|
charCount, expandedChar );
|
||||||
|
// FIXME: character is ucs-4
|
||||||
style = ( unsigned char ) mStyleBuffer->character(
|
style = ( unsigned char ) mStyleBuffer->character(
|
||||||
lineStartPos + i ) - 'A';
|
lineStartPos + i ) - 'A';
|
||||||
|
|
||||||
@ -2452,6 +2468,7 @@ void Fl_Text_Display::find_wrap_range(const char *deletedText, int pos,
|
|||||||
lineStart = retPos;
|
lineStart = retPos;
|
||||||
nLines++;
|
nLines++;
|
||||||
if (lineStart > pos + nInserted &&
|
if (lineStart > pos + nInserted &&
|
||||||
|
// FIXME: character is ucs-4
|
||||||
buf->character(lineStart-1) == '\n') {
|
buf->character(lineStart-1) == '\n') {
|
||||||
countTo = lineStart;
|
countTo = lineStart;
|
||||||
*modRangeEnd = lineStart;
|
*modRangeEnd = lineStart;
|
||||||
@ -2597,6 +2614,7 @@ void Fl_Text_Display::measure_deleted_lines(int pos, int nDeleted) {
|
|||||||
lineStart = retPos;
|
lineStart = retPos;
|
||||||
nLines++;
|
nLines++;
|
||||||
if (lineStart > pos + nDeleted &&
|
if (lineStart > pos + nDeleted &&
|
||||||
|
// FIXME: character is ucs-4
|
||||||
buf->character(lineStart-1) == '\n') {
|
buf->character(lineStart-1) == '\n') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2674,6 +2692,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
|
|||||||
colNum = 0;
|
colNum = 0;
|
||||||
width = 0;
|
width = 0;
|
||||||
for (p=lineStart; p<buf->length(); p++) {
|
for (p=lineStart; p<buf->length(); p++) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
c = (unsigned char)buf->character(p);
|
c = (unsigned char)buf->character(p);
|
||||||
|
|
||||||
/* If the character was a newline, count the line and start over,
|
/* If the character was a newline, count the line and start over,
|
||||||
@ -2708,6 +2727,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
|
|||||||
if (colNum > wrapMargin || width > maxWidth) {
|
if (colNum > wrapMargin || width > maxWidth) {
|
||||||
foundBreak = false;
|
foundBreak = false;
|
||||||
for (b=p; b>=lineStart; b--) {
|
for (b=p; b>=lineStart; b--) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
c = (unsigned char)buf->character(b);
|
c = (unsigned char)buf->character(b);
|
||||||
if (c == '\t' || c == ' ') {
|
if (c == '\t' || c == ' ') {
|
||||||
newLineStart = b + 1;
|
newLineStart = b + 1;
|
||||||
@ -2716,6 +2736,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos,
|
|||||||
width = 0;
|
width = 0;
|
||||||
for (i=b+1; i<p+1; i++) {
|
for (i=b+1; i<p+1; i++) {
|
||||||
width += measure_proportional_character(
|
width += measure_proportional_character(
|
||||||
|
// FIXME: character is ucs-4
|
||||||
buf->character(i), colNum,
|
buf->character(i), colNum,
|
||||||
i+styleBufOffset);
|
i+styleBufOffset);
|
||||||
colNum++;
|
colNum++;
|
||||||
@ -2784,10 +2805,12 @@ int Fl_Text_Display::measure_proportional_character(char c, int colNum, int pos)
|
|||||||
if (styleBuf == 0) {
|
if (styleBuf == 0) {
|
||||||
style = 0;
|
style = 0;
|
||||||
} else {
|
} else {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
style = (unsigned char)styleBuf->character(pos);
|
style = (unsigned char)styleBuf->character(pos);
|
||||||
if (style == mUnfinishedStyle && mUnfinishedHighlightCB) {
|
if (style == mUnfinishedStyle && mUnfinishedHighlightCB) {
|
||||||
/* encountered "unfinished" style, trigger parsing */
|
/* encountered "unfinished" style, trigger parsing */
|
||||||
(mUnfinishedHighlightCB)(pos, mHighlightCBArg);
|
(mUnfinishedHighlightCB)(pos, mHighlightCBArg);
|
||||||
|
// FIXME: character is ucs-4
|
||||||
style = (unsigned char)styleBuf->character(pos);
|
style = (unsigned char)styleBuf->character(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2844,6 +2867,7 @@ int Fl_Text_Display::wrap_uses_character(int lineEndPos) const {
|
|||||||
if (!mContinuousWrap || lineEndPos == buffer()->length())
|
if (!mContinuousWrap || lineEndPos == buffer()->length())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
// FIXME: character is ucs-4
|
||||||
c = buffer()->character(lineEndPos);
|
c = buffer()->character(lineEndPos);
|
||||||
return c == '\n' || ((c == '\t' || c == ' ') &&
|
return c == '\n' || ((c == '\t' || c == ' ') &&
|
||||||
lineEndPos + 1 != buffer()->length());
|
lineEndPos + 1 != buffer()->length());
|
||||||
@ -3123,6 +3147,7 @@ int Fl_Text_Display::handle(int event) {
|
|||||||
int pos = xy_to_position(Fl::event_x(), Fl::event_y(), CURSOR_POS);
|
int pos = xy_to_position(Fl::event_x(), Fl::event_y(), CURSOR_POS);
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
while (!ok) {
|
while (!ok) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( pos );
|
char c = buffer()->character( pos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) {
|
if (!((c & 0x80) && !(c & 0x40))) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
@ -3188,6 +3213,7 @@ int Fl_Text_Display::handle(int event) {
|
|||||||
pos = xy_to_position(X, Y, CURSOR_POS);
|
pos = xy_to_position(X, Y, CURSOR_POS);
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
while (!ok) {
|
while (!ok) {
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = buffer()->character( pos );
|
char c = buffer()->character( pos );
|
||||||
if (!((c & 0x80) && !(c & 0x40))) {
|
if (!((c & 0x80) && !(c & 0x40))) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
|
@ -254,6 +254,7 @@ int Fl_Text_Editor::kf_ignore(int, Fl_Text_Editor*) {
|
|||||||
int Fl_Text_Editor::kf_backspace(int, Fl_Text_Editor* e) {
|
int Fl_Text_Editor::kf_backspace(int, Fl_Text_Editor* e) {
|
||||||
if (!e->buffer()->selected() && e->move_left()) {
|
if (!e->buffer()->selected() && e->move_left()) {
|
||||||
int l = 1;
|
int l = 1;
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = e->buffer()->character(e->insert_position());
|
char c = e->buffer()->character(e->insert_position());
|
||||||
if (c & 0x80 && c & 0x40) {
|
if (c & 0x80 && c & 0x40) {
|
||||||
l = fl_utf8len(c);
|
l = fl_utf8len(c);
|
||||||
@ -449,6 +450,7 @@ int Fl_Text_Editor::kf_insert(int, Fl_Text_Editor* e) {
|
|||||||
int Fl_Text_Editor::kf_delete(int, Fl_Text_Editor* e) {
|
int Fl_Text_Editor::kf_delete(int, Fl_Text_Editor* e) {
|
||||||
if (!e->buffer()->selected()) {
|
if (!e->buffer()->selected()) {
|
||||||
int l = 1;
|
int l = 1;
|
||||||
|
// FIXME: character is ucs-4
|
||||||
char c = e->buffer()->character(e->insert_position());
|
char c = e->buffer()->character(e->insert_position());
|
||||||
if (c & 0x80 && c & 0x40) {
|
if (c & 0x80 && c & 0x40) {
|
||||||
l = fl_utf8len(c);
|
l = fl_utf8len(c);
|
||||||
|
Loading…
Reference in New Issue
Block a user