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.
This commit is contained in:
Rene Gollent
2014-12-28 17:20:05 -05:00
parent ee13e7f8dd
commit 0f45a48087
@@ -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)