summaryrefslogtreecommitdiff
path: root/src/Fl_Text_Display.cxx
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2012-04-21 03:02:25 +0000
committerFabien Costantini <fabien@onepost.net>2012-04-21 03:02:25 +0000
commit226f425443d9983a96c66909df2323928328c8a9 (patch)
treedeee53c668b0e904261c5a24b1102f5456371964 /src/Fl_Text_Display.cxx
parent526efe8a137206878995cc9308b57c939ae586c1 (diff)
STR2731 fixing: potential use of unassigned (Y) value
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9362 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Text_Display.cxx')
-rw-r--r--src/Fl_Text_Display.cxx18
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();