STR 2630: added bounds check for very narrow text editing widgets, wishing that Valgrind was available for OS X

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8659 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2011-05-13 07:58:26 +00:00
parent b588a8d399
commit 6892d8a265

View File

@ -420,7 +420,8 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) {
/* if empty lines become visible, there may be an opportunity to /* if empty lines become visible, there may be an opportunity to
display more text by scrolling down */ display more text by scrolling down */
} else { } else {
while ( (mLineStarts[mNVisibleLines-2]==-1) while ( mNVisibleLines>=2
&& (mLineStarts[mNVisibleLines-2]==-1)
&& scroll_(mTopLineNum-1, mHorizOffset)) && scroll_(mTopLineNum-1, mHorizOffset))
{ } { }
} }
@ -974,7 +975,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 (mNVisibleLines>=2 && mLineStarts[mNVisibleLines-2] != -1) {
int lastChar = line_end(mLineStarts[mNVisibleLines-2],true); int lastChar = line_end(mLineStarts[mNVisibleLines-2],true);
if (insert_position() >= lastChar) if (insert_position() >= lastChar)
topLine += count_lines(lastChar - (wrap_uses_character(mLastChar) ? 0 : 1), topLine += count_lines(lastChar - (wrap_uses_character(mLastChar) ? 0 : 1),