diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Text_Display.cxx | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index fc188464b..8de05f424 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -658,19 +658,28 @@ void Fl_Text_Display::wrap_mode(int wrap, int wrapMargin) { mWrapMargin = wrapMargin; mContinuousWrap = wrap; - /* wrapping can change change the total number of lines, re-count */ - mNBufferLines = count_lines(0, buffer()->length(), true); - - /* changing wrap margins wrap or changing from wrapped mode to non-wrapped - can leave the character at the top no longer at a line start, and/or - change the line number */ - mFirstChar = line_start(mFirstChar); - mTopLineNum = count_lines(0, mFirstChar, true) + 1; - reset_absolute_top_line_number(); - - /* update the line starts array */ - calc_line_starts(0, mNVisibleLines); - calc_last_char(); + if (buffer()) { + /* wrapping can change change the total number of lines, re-count */ + mNBufferLines = count_lines(0, buffer()->length(), true); + + /* changing wrap margins wrap or changing from wrapped mode to non-wrapped + can leave the character at the top no longer at a line start, and/or + change the line number */ + mFirstChar = line_start(mFirstChar); + mTopLineNum = count_lines(0, mFirstChar, true) + 1; + + reset_absolute_top_line_number(); + + /* update the line starts array */ + calc_line_starts(0, mNVisibleLines); + calc_last_char(); + } else { + // No buffer, so just clear the state info for later... + mNBufferLines = 0; + mFirstChar = 0; + mTopLineNum = 1; + mAbsTopLineNum = 0; + } resize(x(), y(), w(), h()); } |
