vfs: check userland buffers before reading them.
[haiku.git] / src / apps / haikudepot / textview / MarkupParser.h
blobc810435dceff5fb1a6d325dc369e302f1e3f9822
1 /*
2 * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5 #ifndef MARKUP_PARSER_H
6 #define MARKUP_PARSER_H
8 #include "TextDocument.h"
11 class MarkupParser {
12 public:
13 MarkupParser();
14 MarkupParser(
15 const CharacterStyle& characterStyle,
16 const ParagraphStyle& paragraphStyle);
18 void SetStyles(
19 const CharacterStyle& characterStyle,
20 const ParagraphStyle& paragraphStyle);
22 const CharacterStyle& HeadingCharacterStyle() const
23 { return fHeadingStyle; }
24 const ParagraphStyle& HeadingParagraphStyle() const
25 { return fHeadingParagraphStyle; }
27 const CharacterStyle& NormalCharacterStyle() const
28 { return fNormalStyle; }
29 const ParagraphStyle& NormalParagraphStyle() const
30 { return fParagraphStyle; }
32 TextDocumentRef CreateDocumentFromMarkup(const BString& text);
33 void AppendMarkup(const TextDocumentRef& document,
34 const BString& text);
36 private:
37 void _InitStyles();
39 void _ParseText(const BString& text);
40 void _CopySpan(const BString& text,
41 int32& start, int32 end);
42 void _ToggleStyle(const CharacterStyle& style);
43 void _FinishParagraph(bool isLast);
45 private:
46 CharacterStyle fNormalStyle;
47 CharacterStyle fBoldStyle;
48 CharacterStyle fItalicStyle;
49 CharacterStyle fBoldItalicStyle;
50 CharacterStyle fHeadingStyle;
52 ParagraphStyle fParagraphStyle;
53 ParagraphStyle fHeadingParagraphStyle;
54 ParagraphStyle fBulletStyle;
56 const CharacterStyle* fCurrentCharacterStyle;
57 const ParagraphStyle* fCurrentParagraphStyle;
59 // while parsing:
60 TextDocumentRef fTextDocument;
61 Paragraph fCurrentParagraph;
62 int32 fSpanStartOffset;
66 #endif // MARKUP_PARSER_H