hrev48576 adds 1 changeset to branch 'master' old head: ee13e7f8ddbcc2b7f6a79a6e0fe58328c47fa81a new head: 0f45a4808764ba3bbe4b7fdc13d63c146d01edfc overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=0f45a48+%5Eee13e7f ---------------------------------------------------------------------------- 0f45a48: 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. [ Rene Gollent <rene@xxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev48576 Commit: 0f45a4808764ba3bbe4b7fdc13d63c146d01edfc URL: http://cgit.haiku-os.org/haiku/commit/?id=0f45a48 Author: Rene Gollent <rene@xxxxxxxxxxx> Date: Sun Dec 28 22:20:05 2014 UTC Ticket: https://dev.haiku-os.org/ticket/11669 ---------------------------------------------------------------------------- 1 file changed, 20 insertions(+), 4 deletions(-) .../gui/team_window/SourceView.cpp | 24 ++++++++++++++++---- ---------------------------------------------------------------------------- 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 88d8ddc..0beeaf7 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)