Applied Stefano's patch to bug #886. Also does nothing now if startOffset is larger
than endOffset. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19169 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1484,19 +1484,35 @@ BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont* font
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
|
if (startOffset > endOffset)
|
||||||
|
return;
|
||||||
|
|
||||||
BFont newFont;
|
BFont newFont;
|
||||||
if (font != NULL) {
|
if (font != NULL) {
|
||||||
newFont = font;
|
newFont = font;
|
||||||
NormalizeFont(&newFont);
|
NormalizeFont(&newFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int32 textLength = fText->Length();
|
||||||
|
|
||||||
if (!fStylable) {
|
if (!fStylable) {
|
||||||
// When the text view is not stylable, we always set the whole text's
|
// When the text view is not stylable, we always set the whole text's
|
||||||
// style and ignore the offsets
|
// style and ignore the offsets
|
||||||
startOffset = 0;
|
startOffset = 0;
|
||||||
endOffset = fText->Length();
|
endOffset = textLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pin offsets at reasonable values
|
||||||
|
if (startOffset < 0)
|
||||||
|
startOffset = 0;
|
||||||
|
else if (startOffset > textLength)
|
||||||
|
startOffset = textLength;
|
||||||
|
|
||||||
|
if (endOffset < 0)
|
||||||
|
endOffset = 0;
|
||||||
|
else if (endOffset > textLength)
|
||||||
|
endOffset = textLength;
|
||||||
|
|
||||||
// add the style to the style buffer
|
// add the style to the style buffer
|
||||||
fStyles->SetStyleRange(startOffset, endOffset, fText->Length(),
|
fStyles->SetStyleRange(startOffset, endOffset, fText->Length(),
|
||||||
fontMode, &newFont, color);
|
fontMode, &newFont, color);
|
||||||
|
|||||||
Reference in New Issue
Block a user