Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

HaikuDepot: Make MarkupParser a bit more flexible...

 ... by allowing to append markup to an existing document.
  • Loading branch information...
commit cb97f2349f67162c5421f1325f0c385c3a6d3563 1 parent 97c332e
@stippi stippi authored
View
19 src/apps/haiku-depot/textview/MarkupParser.cpp
@@ -64,9 +64,20 @@ MarkupParser::SetStyles(const CharacterStyle& characterStyle,
TextDocumentRef
MarkupParser::CreateDocumentFromMarkup(const BString& text)
{
- fTextDocument.SetTo(new(std::nothrow) TextDocument(), true);
- if (fTextDocument.Get() == NULL)
- return fTextDocument;
+ TextDocumentRef document(new(std::nothrow) TextDocument(), true);
+ if (document.Get() == NULL)
+ return document;
+
+ AppendMarkup(document, text);
+
+ return document;
+}
+
+
+void
+MarkupParser::AppendMarkup(const TextDocumentRef& document, const BString& text)
+{
+ fTextDocument.SetTo(document);
fCurrentCharacterStyle = &fNormalStyle;
fCurrentParagraphStyle = &fParagraphStyle;
@@ -76,7 +87,7 @@ MarkupParser::CreateDocumentFromMarkup(const BString& text)
_ParseText(text);
- return fTextDocument;
+ fTextDocument.Unset();
}
View
7 src/apps/haiku-depot/textview/MarkupParser.h
@@ -19,7 +19,14 @@ class MarkupParser {
const CharacterStyle& characterStyle,
const ParagraphStyle& paragraphStyle);
+ const CharacterStyle& HeadingCharacterStyle() const
+ { return fHeadingStyle; }
+ const ParagraphStyle& HeadingParagraphStyle() const
+ { return fHeadingParagraphStyle; }
+
TextDocumentRef CreateDocumentFromMarkup(const BString& text);
+ void AppendMarkup(const TextDocumentRef& document,
+ const BString& text);
private:
void _InitStyles();
Please sign in to comment.
Something went wrong with that request. Please try again.