diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Text_Display.cxx | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index fa1f6fe1f..03be48e60 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -803,25 +803,21 @@ void Fl_Text_Display::overstrike(const char* text) { \param pos character index \param[out] X, Y pixel position of character on screen - \return 0 if character vertically out of view, X position otherwise + \return 0 if character vertically out of view, X & Y positions otherwise */ int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) const { IS_UTF8_ALIGNED2(buffer(), pos) int lineStartPos, fontHeight; int visLineNum; - /* If position is not displayed, return false */ if (pos < mFirstChar || (pos > mLastChar && !empty_vlines())) { - return 0; + return (*X=*Y=0); // make sure X & Y are set when it is out of view } /* Calculate Y coordinate */ - if (!position_to_line(pos, &visLineNum)) { - return 0; - } - if (visLineNum < 0 || visLineNum > mNBufferLines) { - return 0; + if (!position_to_line(pos, &visLineNum) || visLineNum < 0 || visLineNum > mNBufferLines) { + return (*X=*Y=0); // make sure X & Y are set when it is out of view } fontHeight = mMaxsize; @@ -3469,10 +3465,12 @@ void Fl_Text_Display::draw(void) { text_area.h); 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); + mCursorOldY = 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(); } fl_pop_clip(); |
