Finally fixed the problem with the styling code: now selecting two sections of text
with a different color and change the font size works correctly. Fixed a problem with mouse selection (a regression introduced when I fixed selection with keyboard). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9031 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#include <View.h> // For B_FONT_FAMILY_AND_STYLE, B_FONT_SIZE, etc.
|
#include <View.h> // For B_FONT_FAMILY_AND_STYLE, B_FONT_SIZE, etc.
|
||||||
|
|
||||||
|
|
||||||
// _BStyleRunDescBuffer_
|
// _BStyleRunDescBuffer_
|
||||||
|
|
||||||
_BStyleRunDescBuffer_::_BStyleRunDescBuffer_()
|
_BStyleRunDescBuffer_::_BStyleRunDescBuffer_()
|
||||||
@@ -67,15 +66,13 @@ _BStyleRunDescBuffer_::OffsetToRun(int32 offset) const
|
|||||||
if (offset >= fBuffer[index].offset) {
|
if (offset >= fBuffer[index].offset) {
|
||||||
if (index >= (fItemCount - 1)) {
|
if (index >= (fItemCount - 1)) {
|
||||||
break;
|
break;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (offset < fBuffer[index + 1].offset)
|
if (offset < fBuffer[index + 1].offset)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
minIndex = index + 1;
|
minIndex = index + 1;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
maxIndex = index;
|
maxIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +273,7 @@ _BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset,
|
|||||||
STEStyle style = fStyleRecord[runDesc.index]->style;
|
STEStyle style = fStyleRecord[runDesc.index]->style;
|
||||||
SetStyle(inMode, inFont, &style.font, inColor, &style.color);
|
SetStyle(inMode, inFont, &style.font, inColor, &style.color);
|
||||||
|
|
||||||
styleIndex = fStyleRecord.InsertRecord(inFont, inColor);
|
styleIndex = fStyleRecord.InsertRecord(&style.font, &style.color);
|
||||||
|
|
||||||
if ( (runDesc.offset == offset) && (runIndex > 0) &&
|
if ( (runDesc.offset == offset) && (runIndex > 0) &&
|
||||||
(fStyleRunDesc[runIndex - 1]->index == styleIndex) ) {
|
(fStyleRunDesc[runIndex - 1]->index == styleIndex) ) {
|
||||||
@@ -470,8 +467,8 @@ _BStyleBuffer_::SetStyle(uint32 mode, const BFont *fromFont,
|
|||||||
if (mode & B_FONT_SHEAR)
|
if (mode & B_FONT_SHEAR)
|
||||||
toFont->SetShear(fromFont->Shear());
|
toFont->SetShear(fromFont->Shear());
|
||||||
|
|
||||||
//if (mode & doColor)
|
if (!mode)
|
||||||
// *toColor = *fromColor;
|
*toColor = *fromColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -471,7 +471,11 @@ BTextView::MouseDown(BPoint where)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unhighlights the selection if needed
|
||||||
|
if (fSelStart != fSelEnd)
|
||||||
|
Select(fSelStart, fSelEnd);
|
||||||
|
|
||||||
// get the system-wide click speed
|
// get the system-wide click speed
|
||||||
bigtime_t clickSpeed = 0;
|
bigtime_t clickSpeed = 0;
|
||||||
get_click_speed(&clickSpeed);
|
get_click_speed(&clickSpeed);
|
||||||
@@ -1585,7 +1589,6 @@ BTextView::SetFontAndColor(const BFont *inFont, uint32 inMode,
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
CancelInputMethod();
|
CancelInputMethod();
|
||||||
|
|
||||||
// hide the caret/unhilite the selection
|
// hide the caret/unhilite the selection
|
||||||
if (fActive) {
|
if (fActive) {
|
||||||
if (fSelStart != fSelEnd)
|
if (fSelStart != fSelEnd)
|
||||||
@@ -1628,6 +1631,7 @@ BTextView::SetFontAndColor(int32 startOffset, int32 endOffset,
|
|||||||
const rgb_color *inColor)
|
const rgb_color *inColor)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
// hide the caret/unhilite the selection
|
// hide the caret/unhilite the selection
|
||||||
if (fActive) {
|
if (fActive) {
|
||||||
if (startOffset != endOffset)
|
if (startOffset != endOffset)
|
||||||
|
|||||||
Reference in New Issue
Block a user