From c300426e4cde983c42e40ff97816c77a97a9d8f1 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 23 Oct 2002 13:21:14 +0000 Subject: [PATCH] Fix Fl_Text_Display cursor drawing bug... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2687 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 1 + src/Fl_Text_Display.cxx | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 16f90ca47..112c5edde 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ CHANGES IN FLTK 1.1.1 + - Fl_Text_Display didn't always show the cursor. - Fl_Tabs now only redraws the tabs themselves when making focus changes. This reduces flicker in tabbed interfaces. diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 12f92ffc8..b030b3ba5 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -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. // 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 ]; 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 (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; + } /* Calculate Y coordinate */ - if (!position_to_line(pos, &visLineNum)) return 0; - if (visLineNum < 0 || visLineNum >= mNBufferLines) return 0; + if (!position_to_line(pos, &visLineNum)) { +// 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; *Y = text_area.y + visLineNum * fontHeight; @@ -2878,6 +2895,7 @@ void Fl_Text_Display::draw(void) { int 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); mCursorOldY = Y; 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 $". //