Paragraph: Added Prepend(TextSpan).
This commit is contained in:
@@ -66,6 +66,22 @@ Paragraph::SetStyle(const ParagraphStyle& style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Paragraph::Prepend(const TextSpan& span)
|
||||||
|
{
|
||||||
|
// Try to merge with first span if the TextStyles are equal
|
||||||
|
if (fTextSpans.CountItems() > 0) {
|
||||||
|
const TextSpan& firstSpan = fTextSpans.ItemAtFast(0);
|
||||||
|
if (firstSpan.Style() == span.Style()) {
|
||||||
|
BString text(span.Text());
|
||||||
|
text.Append(firstSpan.Text());
|
||||||
|
return fTextSpans.Replace(0, TextSpan(text, span.Style()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fTextSpans.Add(span, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Paragraph::Append(const TextSpan& span)
|
Paragraph::Append(const TextSpan& span)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public:
|
|||||||
inline const TextSpanList& TextSpans() const
|
inline const TextSpanList& TextSpans() const
|
||||||
{ return fTextSpans; }
|
{ return fTextSpans; }
|
||||||
|
|
||||||
|
bool Prepend(const TextSpan& span);
|
||||||
bool Append(const TextSpan& span);
|
bool Append(const TextSpan& span);
|
||||||
bool Insert(int32 offset, const TextSpan& span);
|
bool Insert(int32 offset, const TextSpan& span);
|
||||||
bool Remove(int32 offset, int32 length);
|
bool Remove(int32 offset, int32 length);
|
||||||
|
|||||||
Reference in New Issue
Block a user