STR #1227: Thanks to Albrecht Schlosser for commiting this patch to fix Fl_Test_Display. The little I could check seemed fine, and he's certain that he fixed the bugs that he found himself.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5194 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2006-06-13 19:08:32 +00:00
parent d625425d96
commit a0cbcf3d1d
2 changed files with 17 additions and 12 deletions
+1
View File
@@ -1,5 +1,6 @@
CHANGES IN FLTK 1.1.8 CHANGES IN FLTK 1.1.8
- Fixed line wrapping in Fl_Text_Display (STR #1227)
- New function Fl::event_original_key() returns key - New function Fl::event_original_key() returns key
code before NumLock handling. code before NumLock handling.
- Many OS X Quartz fixes (STR #1310, etc.) - Many OS X Quartz fixes (STR #1310, etc.)
+16 -12
View File
@@ -921,7 +921,7 @@ void Fl_Text_Display::display_insert() {
if (insert_position() < mFirstChar) { if (insert_position() < mFirstChar) {
topLine -= count_lines(insert_position(), mFirstChar, false); topLine -= count_lines(insert_position(), mFirstChar, false);
} else if (mLineStarts[mNVisibleLines-2] != -1) { } else if (mLineStarts[mNVisibleLines-2] != -1) {
int lastChar = buffer()->line_end(mLineStarts[mNVisibleLines-2]); int lastChar = line_end(mLineStarts[mNVisibleLines-2],true);
if (insert_position() >= lastChar) if (insert_position() >= lastChar)
topLine topLine
+= count_lines(lastChar - (wrap_uses_character(mLastChar) ? 0 : 1), += count_lines(lastChar - (wrap_uses_character(mLastChar) ? 0 : 1),
@@ -934,8 +934,12 @@ void Fl_Text_Display::display_insert() {
horizontal */ horizontal */
if (!position_to_xy( mCursorPos, &X, &Y )) { if (!position_to_xy( mCursorPos, &X, &Y )) {
scroll_(topLine, hOffset); scroll_(topLine, hOffset);
if (!position_to_xy( mCursorPos, &X, &Y )) if (!position_to_xy( mCursorPos, &X, &Y )) {
#ifdef DEBUG
printf ("*** display_insert/position_to_xy # GIVE UP !\n"); fflush(stdout);
#endif // DEBUG
return; /* Give up, it's not worth it (but why does it fail?) */ return; /* Give up, it's not worth it (but why does it fail?) */
}
} }
if (X > text_area.x + text_area.w) if (X > text_area.x + text_area.w)
hOffset += X-(text_area.x + text_area.w); hOffset += X-(text_area.x + text_area.w);
@@ -977,7 +981,7 @@ int Fl_Text_Display::move_up() {
if ( position_to_line( mCursorPos, &visLineNum ) ) if ( position_to_line( mCursorPos, &visLineNum ) )
lineStartPos = mLineStarts[ visLineNum ]; lineStartPos = mLineStarts[ visLineNum ];
else { else {
lineStartPos = buffer()->line_start( mCursorPos ); lineStartPos = line_start( mCursorPos );
visLineNum = -1; visLineNum = -1;
} }
if ( lineStartPos == 0 ) if ( lineStartPos == 0 )
@@ -991,10 +995,10 @@ int Fl_Text_Display::move_up() {
if ( visLineNum != -1 && visLineNum != 0 ) if ( visLineNum != -1 && visLineNum != 0 )
prevLineStartPos = mLineStarts[ visLineNum - 1 ]; prevLineStartPos = mLineStarts[ visLineNum - 1 ];
else else
prevLineStartPos = buffer()->rewind_lines( lineStartPos, 1 ); prevLineStartPos = rewind_lines( lineStartPos, 1 );
newPos = mBuffer->skip_displayed_characters( prevLineStartPos, column ); newPos = mBuffer->skip_displayed_characters( prevLineStartPos, column );
if (mContinuousWrap) if (mContinuousWrap)
newPos = min(newPos, line_end(prevLineStartPos, true)); newPos = min(newPos, line_end(prevLineStartPos, true));
/* move the cursor */ /* move the cursor */
insert_position( newPos ); insert_position( newPos );
@@ -1012,7 +1016,7 @@ int Fl_Text_Display::move_down() {
if ( position_to_line( mCursorPos, &visLineNum ) ) if ( position_to_line( mCursorPos, &visLineNum ) )
lineStartPos = mLineStarts[ visLineNum ]; lineStartPos = mLineStarts[ visLineNum ];
else { else {
lineStartPos = buffer()->line_start( mCursorPos ); lineStartPos = line_start( mCursorPos );
visLineNum = -1; visLineNum = -1;
} }
column = mCursorPreferredCol >= 0 ? mCursorPreferredCol : column = mCursorPreferredCol >= 0 ? mCursorPreferredCol :
@@ -1038,7 +1042,7 @@ int Fl_Text_Display::count_lines(int startPos, int endPos,
int retLines, retPos, retLineStart, retLineEnd; int retLines, retPos, retLineStart, retLineEnd;
#ifdef DEBUG #ifdef DEBUG
printf("Fl_Text_Display::count_line(startPos=%d, endPos=%d, startPosIsLineStart=%d\n", printf("Fl_Text_Display::count_lines(startPos=%d, endPos=%d, startPosIsLineStart=%d\n",
startPos, endPos, startPosIsLineStart); startPos, endPos, startPosIsLineStart);
#endif // DEBUG #endif // DEBUG
@@ -1051,7 +1055,7 @@ int Fl_Text_Display::count_lines(int startPos, int endPos,
&retLineEnd); &retLineEnd);
#ifdef DEBUG #ifdef DEBUG
printf("retPos=%d, retLines=%d, retLineStart=%d, retLineEnd=%d\n", printf(" # after WLC: retPos=%d, retLines=%d, retLineStart=%d, retLineEnd=%d\n",
retPos, retLines, retLineStart, retLineEnd); retPos, retLines, retLineStart, retLineEnd);
#endif // DEBUG #endif // DEBUG
@@ -1973,14 +1977,14 @@ void Fl_Text_Display::offset_line_starts( int newTopLineNum ) {
if ( newTopLineNum < oldTopLineNum && newTopLineNum < -lineDelta ) { if ( newTopLineNum < oldTopLineNum && newTopLineNum < -lineDelta ) {
mFirstChar = skip_lines( 0, newTopLineNum - 1, true ); mFirstChar = skip_lines( 0, newTopLineNum - 1, true );
} else if ( newTopLineNum < oldTopLineNum ) { } else if ( newTopLineNum < oldTopLineNum ) {
mFirstChar = buffer()->rewind_lines( mFirstChar, -lineDelta ); mFirstChar = rewind_lines( mFirstChar, -lineDelta );
} else if ( newTopLineNum < lastLineNum ) { } else if ( newTopLineNum < lastLineNum ) {
mFirstChar = lineStarts[ newTopLineNum - oldTopLineNum ]; mFirstChar = lineStarts[ newTopLineNum - oldTopLineNum ];
} else if ( newTopLineNum - lastLineNum < mNBufferLines - newTopLineNum ) { } else if ( newTopLineNum - lastLineNum < mNBufferLines - newTopLineNum ) {
mFirstChar = skip_lines( lineStarts[ nVisLines - 1 ], mFirstChar = skip_lines( lineStarts[ nVisLines - 1 ],
newTopLineNum - lastLineNum, true ); newTopLineNum - lastLineNum, true );
} else { } else {
mFirstChar = buffer()->rewind_lines( buf->length(), mNBufferLines - newTopLineNum + 1 ); mFirstChar = rewind_lines( buf->length(), mNBufferLines - newTopLineNum + 1 );
} }
/* Fill in the line starts array */ /* Fill in the line starts array */
@@ -2037,7 +2041,7 @@ void Fl_Text_Display::update_line_starts( int pos, int charsInserted,
if ( position_to_line( pos + charsDeleted, &lineOfEnd ) && if ( position_to_line( pos + charsDeleted, &lineOfEnd ) &&
++lineOfEnd < nVisLines && lineStarts[ lineOfEnd ] != -1 ) { ++lineOfEnd < nVisLines && lineStarts[ lineOfEnd ] != -1 ) {
mTopLineNum = max( 1, mTopLineNum + lineDelta ); mTopLineNum = max( 1, mTopLineNum + lineDelta );
mFirstChar = buffer()->rewind_lines( mFirstChar = rewind_lines(
lineStarts[ lineOfEnd ] + charDelta, lineOfEnd ); lineStarts[ lineOfEnd ] + charDelta, lineOfEnd );
/* Otherwise anchor on original line number and recount everything */ /* Otherwise anchor on original line number and recount everything */
} else { } else {