diff --git a/src/apps/haiku-depot/textview/TextDocument.cpp b/src/apps/haiku-depot/textview/TextDocument.cpp index 7bb089fa50..e77d51b7b2 100644 --- a/src/apps/haiku-depot/textview/TextDocument.cpp +++ b/src/apps/haiku-depot/textview/TextDocument.cpp @@ -10,17 +10,17 @@ TextDocument::TextDocument() : fParagraphs(), fEmptyLastParagraph(), - fDefaultTextStyle() + fDefaultCharacterStyle() { } -TextDocument::TextDocument(const TextStyle& textStyle, +TextDocument::TextDocument(const CharacterStyle& CharacterStyle, const ParagraphStyle& paragraphStyle) : fParagraphs(), fEmptyLastParagraph(paragraphStyle), - fDefaultTextStyle(textStyle) + fDefaultCharacterStyle(CharacterStyle) { } @@ -29,7 +29,7 @@ TextDocument::TextDocument(const TextDocument& other) : fParagraphs(other.fParagraphs), fEmptyLastParagraph(other.fEmptyLastParagraph), - fDefaultTextStyle(other.fDefaultTextStyle) + fDefaultCharacterStyle(other.fDefaultCharacterStyle) { } @@ -39,7 +39,7 @@ TextDocument::operator=(const TextDocument& other) { fParagraphs = other.fParagraphs; fEmptyLastParagraph = other.fEmptyLastParagraph; - fDefaultTextStyle = other.fDefaultTextStyle; + fDefaultCharacterStyle = other.fDefaultCharacterStyle; return *this; } @@ -52,7 +52,7 @@ TextDocument::operator==(const TextDocument& other) const return true; return fEmptyLastParagraph == other.fEmptyLastParagraph - && fDefaultTextStyle == other.fDefaultTextStyle + && fDefaultCharacterStyle == other.fDefaultCharacterStyle && fParagraphs == other.fParagraphs; } @@ -70,12 +70,12 @@ TextDocument::operator!=(const TextDocument& other) const status_t TextDocument::Insert(int32 offset, const BString& text) { - return Insert(offset, text, TextStyleAt(offset)); + return Insert(offset, text, CharacterStyleAt(offset)); } status_t -TextDocument::Insert(int32 offset, const BString& text, const TextStyle& style) +TextDocument::Insert(int32 offset, const BString& text, const CharacterStyle& style) { return Insert(offset, text, style, ParagraphStyleAt(offset)); } @@ -83,9 +83,9 @@ TextDocument::Insert(int32 offset, const BString& text, const TextStyle& style) status_t TextDocument::Insert(int32 offset, const BString& text, - const TextStyle& textStyle, const ParagraphStyle& paragraphStyle) + const CharacterStyle& CharacterStyle, const ParagraphStyle& paragraphStyle) { - return Replace(offset, 0, text, textStyle, paragraphStyle); + return Replace(offset, 0, text, CharacterStyle, paragraphStyle); } @@ -106,13 +106,13 @@ TextDocument::Remove(int32 offset, int32 length) status_t TextDocument::Replace(int32 offset, int32 length, const BString& text) { - return Replace(offset, length, text, TextStyleAt(offset)); + return Replace(offset, length, text, CharacterStyleAt(offset)); } status_t TextDocument::Replace(int32 offset, int32 length, const BString& text, - const TextStyle& style) + const CharacterStyle& style) { return Replace(offset, length, text, style, ParagraphStyleAt(offset)); } @@ -120,7 +120,7 @@ TextDocument::Replace(int32 offset, int32 length, const BString& text, status_t TextDocument::Replace(int32 offset, int32 length, const BString& text, - const TextStyle& textStyle, const ParagraphStyle& paragraphStyle) + const CharacterStyle& CharacterStyle, const ParagraphStyle& paragraphStyle) { // TODO: Implement return B_ERROR; @@ -130,8 +130,8 @@ TextDocument::Replace(int32 offset, int32 length, const BString& text, // #pragma mark - -const TextStyle& -TextDocument::TextStyleAt(int32 textOffset) const +const CharacterStyle& +TextDocument::CharacterStyleAt(int32 textOffset) const { int32 paragraphOffset; const Paragraph& paragraph = ParagraphAt(textOffset, paragraphOffset); @@ -147,8 +147,7 @@ TextDocument::TextStyleAt(int32 textOffset) const textOffset -= span.CharCount(); } - // TODO: Document should have a default TextStyle? - return fDefaultTextStyle; + return fDefaultCharacterStyle; } diff --git a/src/apps/haiku-depot/textview/TextDocument.h b/src/apps/haiku-depot/textview/TextDocument.h index 542daa3fb4..0dbe42e254 100644 --- a/src/apps/haiku-depot/textview/TextDocument.h +++ b/src/apps/haiku-depot/textview/TextDocument.h @@ -5,6 +5,7 @@ #ifndef TEXT_DOCUMENT_H #define TEXT_DOCUMENT_H +#include "CharacterStyle.h" #include "List.h" #include "Paragraph.h" @@ -15,7 +16,8 @@ typedef List ParagraphList; class TextDocument { public: TextDocument(); - TextDocument(const TextStyle& textStyle, + TextDocument( + const CharacterStyle& characterStyle, const ParagraphStyle& paragraphStyle); TextDocument(const TextDocument& other); @@ -26,9 +28,9 @@ public: // Text insertion and removing status_t Insert(int32 offset, const BString& text); status_t Insert(int32 offset, const BString& text, - const TextStyle& style); + const CharacterStyle& style); status_t Insert(int32 offset, const BString& text, - const TextStyle& textStyle, + const CharacterStyle& characterStyle, const ParagraphStyle& paragraphStyle); status_t Remove(int32 offset, int32 length); @@ -37,14 +39,14 @@ public: const BString& text); status_t Replace(int32 offset, int32 length, const BString& text, - const TextStyle& style); + const CharacterStyle& style); status_t Replace(int32 offset, int32 length, const BString& text, - const TextStyle& textStyle, + const CharacterStyle& characterStyle, const ParagraphStyle& paragraphStyle); // Style access - const TextStyle& TextStyleAt(int32 textOffset) const; + const CharacterStyle& CharacterStyleAt(int32 textOffset) const; const ParagraphStyle& ParagraphStyleAt(int32 textOffset) const; // Paragraph access @@ -59,7 +61,7 @@ public: private: ParagraphList fParagraphs; Paragraph fEmptyLastParagraph; - TextStyle fDefaultTextStyle; + CharacterStyle fDefaultCharacterStyle; }; diff --git a/src/apps/haiku-depot/textview/TextSpan.cpp b/src/apps/haiku-depot/textview/TextSpan.cpp index daa0e69256..e13d84db14 100644 --- a/src/apps/haiku-depot/textview/TextSpan.cpp +++ b/src/apps/haiku-depot/textview/TextSpan.cpp @@ -15,7 +15,7 @@ TextSpan::TextSpan() } -TextSpan::TextSpan(const BString& text, const TextStyle& style) +TextSpan::TextSpan(const BString& text, const CharacterStyle& style) : fText(text), fCharCount(text.CountChars()), @@ -69,7 +69,7 @@ TextSpan::SetText(const BString& text) void -TextSpan::SetStyle(const TextStyle& style) +TextSpan::SetStyle(const CharacterStyle& style) { fStyle = style; } diff --git a/src/apps/haiku-depot/textview/TextSpan.h b/src/apps/haiku-depot/textview/TextSpan.h index 88bbddcee8..b6625256d5 100644 --- a/src/apps/haiku-depot/textview/TextSpan.h +++ b/src/apps/haiku-depot/textview/TextSpan.h @@ -8,14 +8,14 @@ #include -#include "TextStyle.h" +#include "CharacterStyle.h" class TextSpan { public: TextSpan(); TextSpan(const BString& text, - const TextStyle& style); + const CharacterStyle& style); TextSpan(const TextSpan& other); TextSpan& operator=(const TextSpan& other); @@ -26,8 +26,8 @@ public: inline const BString& Text() const { return fText; } - void SetStyle(const TextStyle& style); - inline const TextStyle& Style() const + void SetStyle(const CharacterStyle& style); + inline const CharacterStyle& Style() const { return fStyle; } inline int32 CharCount() const @@ -46,7 +46,7 @@ private: private: BString fText; int32 fCharCount; - TextStyle fStyle; + CharacterStyle fStyle; };