From 0f45a4808764ba3bbe4b7fdc13d63c146d01edfc Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 28 Dec 2014 17:20:05 -0500 Subject: [PATCH] Debugger: Fix #11669. SourceView: - When calculating line widths for scrollbar calculation purposes, tabstop offsets weren't being correctly taken into account, which would result in lines being computed as shorter than they actually were. Depending on the content of the file, the horizontal scrollbar would consequently be configured improperly in some cases. --- .../gui/team_window/SourceView.cpp | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp b/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp index 88d8ddc1b1..0beeaf7347 100644 --- a/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp @@ -330,6 +330,8 @@ private: }; float _MaxLineWidth(); + inline float _FormattedLineWidth(const char* line) const; + void _DrawLineSyntaxSection(const char* line, int32 length, int32& _column, BPoint& _offset); @@ -1523,16 +1525,30 @@ SourceView::TextView::_MaxLineWidth() fMaxLineWidth = 0; if (fSourceCode != NULL) { - for (int32 i = 0; const char* line = fSourceCode->LineAt(i); i++) { - fMaxLineWidth = std::max(fMaxLineWidth, - fFontInfo->font.StringWidth(line)); - } + for (int32 i = 0; const char* line = fSourceCode->LineAt(i); i++) + fMaxLineWidth = std::max(fMaxLineWidth, _FormattedLineWidth(line)); } return fMaxLineWidth; } +float +SourceView::TextView::_FormattedLineWidth(const char* line) const +{ + int32 column = 0; + int32 i = 0; + for (; line[i] != '\0'; i++) { + if (line[i] == '\t') + column = _NextTabStop(column); + else + ++column; + } + + return column * fCharacterWidth; +} + + void SourceView::TextView::_DrawLineSyntaxSection(const char* line, int32 length, int32& _column, BPoint& _offset)