Fix Fl_Text_Display cursor drawing bug...

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2687 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-10-23 13:21:14 +00:00
parent 5953e69de0
commit c300426e4c
2 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,6 @@
CHANGES IN FLTK 1.1.1 CHANGES IN FLTK 1.1.1
- Fl_Text_Display didn't always show the cursor.
- Fl_Tabs now only redraws the tabs themselves when - Fl_Tabs now only redraws the tabs themselves when
making focus changes. This reduces flicker in tabbed making focus changes. This reduces flicker in tabbed
interfaces. interfaces.

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Text_Display.cxx,v 1.12.2.32 2002/10/23 12:23:39 easysw Exp $" // "$Id: Fl_Text_Display.cxx,v 1.12.2.33 2002/10/23 13:21:14 easysw Exp $"
// //
// Copyright 2001-2002 by Bill Spitzak and others. // Copyright 2001-2002 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under // Original code Copyright Mark Edel. Permission to distribute under
@ -736,13 +736,30 @@ int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) {
char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ]; char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ];
const char *lineStr; const char *lineStr;
// printf("position_to_xy(pos=%d, X=%p, Y=%p)\n", pos, X, Y);
/* If position is not displayed, return false */ /* If position is not displayed, return false */
if (pos < mFirstChar || (pos > mLastChar && !empty_vlines())) if (pos < mFirstChar || (pos > mLastChar && !empty_vlines())) {
// printf(" returning 0\n"
// " mFirstChar=%d, mLastChar=%d, empty_vlines()=0\n",
// mFirstChar, mLastChar);
return 0; return 0;
}
/* Calculate Y coordinate */ /* Calculate Y coordinate */
if (!position_to_line(pos, &visLineNum)) return 0; if (!position_to_line(pos, &visLineNum)) {
if (visLineNum < 0 || visLineNum >= mNBufferLines) return 0; // puts(" returning 0\n"
// " position_to_line()=0");
return 0;
}
if (visLineNum < 0 || visLineNum > mNBufferLines) {
// printf(" returning 0\n"
// " visLineNum=%d, mNBufferLines=%d\n",
// visLineNum, mNBufferLines);
return 0;
}
fontHeight = mMaxsize; fontHeight = mMaxsize;
*Y = text_area.y + visLineNum * fontHeight; *Y = text_area.y + visLineNum * fontHeight;
@ -2878,6 +2895,7 @@ void Fl_Text_Display::draw(void) {
int X, Y; int X, Y;
if (position_to_xy(mCursorPos, &X, &Y)) draw_cursor(X, Y); if (position_to_xy(mCursorPos, &X, &Y)) draw_cursor(X, Y);
// else puts("position_to_xy() failed - unable to draw cursor!");
//printf("drew cursor at pos: %d (%d,%d)\n", mCursorPos, X, Y); //printf("drew cursor at pos: %d (%d,%d)\n", mCursorPos, X, Y);
mCursorOldY = Y; mCursorOldY = Y;
fl_pop_clip(); fl_pop_clip();
@ -3008,5 +3026,5 @@ int Fl_Text_Display::handle(int event) {
// //
// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.32 2002/10/23 12:23:39 easysw Exp $". // End of "$Id: Fl_Text_Display.cxx,v 1.12.2.33 2002/10/23 13:21:14 easysw Exp $".
// //