From 6be70a0fa1b3bc73fcaf50171ae9121ae1826d90 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Thu, 23 Sep 2004 06:40:22 +0000 Subject: [PATCH] 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 --- src/kits/interface/BTextView/StyleBuffer.cpp | 13 +++++-------- src/kits/interface/BTextView/TextView.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/kits/interface/BTextView/StyleBuffer.cpp b/src/kits/interface/BTextView/StyleBuffer.cpp index b8da9f5fb8..4040c4c4bc 100644 --- a/src/kits/interface/BTextView/StyleBuffer.cpp +++ b/src/kits/interface/BTextView/StyleBuffer.cpp @@ -29,7 +29,6 @@ #include // For B_FONT_FAMILY_AND_STYLE, B_FONT_SIZE, etc. - // _BStyleRunDescBuffer_ _BStyleRunDescBuffer_::_BStyleRunDescBuffer_() @@ -67,15 +66,13 @@ _BStyleRunDescBuffer_::OffsetToRun(int32 offset) const if (offset >= fBuffer[index].offset) { if (index >= (fItemCount - 1)) { break; - } - else { + } else { if (offset < fBuffer[index + 1].offset) break; else minIndex = index + 1; } - } - else + } else maxIndex = index; } @@ -276,7 +273,7 @@ _BStyleBuffer_::SetStyleRange(int32 fromOffset, int32 toOffset, STEStyle style = fStyleRecord[runDesc.index]->style; 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) && (fStyleRunDesc[runIndex - 1]->index == styleIndex) ) { @@ -470,8 +467,8 @@ _BStyleBuffer_::SetStyle(uint32 mode, const BFont *fromFont, if (mode & B_FONT_SHEAR) toFont->SetShear(fromFont->Shear()); - //if (mode & doColor) - // *toColor = *fromColor; + if (!mode) + *toColor = *fromColor; } diff --git a/src/kits/interface/BTextView/TextView.cpp b/src/kits/interface/BTextView/TextView.cpp index 9d2b45dd1f..7253900829 100644 --- a/src/kits/interface/BTextView/TextView.cpp +++ b/src/kits/interface/BTextView/TextView.cpp @@ -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 bigtime_t clickSpeed = 0; get_click_speed(&clickSpeed); @@ -1585,7 +1589,6 @@ BTextView::SetFontAndColor(const BFont *inFont, uint32 inMode, { CALLED(); CancelInputMethod(); - // hide the caret/unhilite the selection if (fActive) { if (fSelStart != fSelEnd) @@ -1628,6 +1631,7 @@ BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const rgb_color *inColor) { CALLED(); + // hide the caret/unhilite the selection if (fActive) { if (startOffset != endOffset)