HaikuDepot: Text stuff: Switched from TextStyle to CharacterStyle
This commit is contained in:
parent
036fabe903
commit
f668e7dd19
@ -10,17 +10,17 @@ TextDocument::TextDocument()
|
|||||||
:
|
:
|
||||||
fParagraphs(),
|
fParagraphs(),
|
||||||
fEmptyLastParagraph(),
|
fEmptyLastParagraph(),
|
||||||
fDefaultTextStyle()
|
fDefaultCharacterStyle()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextDocument::TextDocument(const TextStyle& textStyle,
|
TextDocument::TextDocument(const CharacterStyle& CharacterStyle,
|
||||||
const ParagraphStyle& paragraphStyle)
|
const ParagraphStyle& paragraphStyle)
|
||||||
:
|
:
|
||||||
fParagraphs(),
|
fParagraphs(),
|
||||||
fEmptyLastParagraph(paragraphStyle),
|
fEmptyLastParagraph(paragraphStyle),
|
||||||
fDefaultTextStyle(textStyle)
|
fDefaultCharacterStyle(CharacterStyle)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ TextDocument::TextDocument(const TextDocument& other)
|
|||||||
:
|
:
|
||||||
fParagraphs(other.fParagraphs),
|
fParagraphs(other.fParagraphs),
|
||||||
fEmptyLastParagraph(other.fEmptyLastParagraph),
|
fEmptyLastParagraph(other.fEmptyLastParagraph),
|
||||||
fDefaultTextStyle(other.fDefaultTextStyle)
|
fDefaultCharacterStyle(other.fDefaultCharacterStyle)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ TextDocument::operator=(const TextDocument& other)
|
|||||||
{
|
{
|
||||||
fParagraphs = other.fParagraphs;
|
fParagraphs = other.fParagraphs;
|
||||||
fEmptyLastParagraph = other.fEmptyLastParagraph;
|
fEmptyLastParagraph = other.fEmptyLastParagraph;
|
||||||
fDefaultTextStyle = other.fDefaultTextStyle;
|
fDefaultCharacterStyle = other.fDefaultCharacterStyle;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ TextDocument::operator==(const TextDocument& other) const
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
return fEmptyLastParagraph == other.fEmptyLastParagraph
|
return fEmptyLastParagraph == other.fEmptyLastParagraph
|
||||||
&& fDefaultTextStyle == other.fDefaultTextStyle
|
&& fDefaultCharacterStyle == other.fDefaultCharacterStyle
|
||||||
&& fParagraphs == other.fParagraphs;
|
&& fParagraphs == other.fParagraphs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,12 +70,12 @@ TextDocument::operator!=(const TextDocument& other) const
|
|||||||
status_t
|
status_t
|
||||||
TextDocument::Insert(int32 offset, const BString& text)
|
TextDocument::Insert(int32 offset, const BString& text)
|
||||||
{
|
{
|
||||||
return Insert(offset, text, TextStyleAt(offset));
|
return Insert(offset, text, CharacterStyleAt(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
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));
|
return Insert(offset, text, style, ParagraphStyleAt(offset));
|
||||||
}
|
}
|
||||||
@ -83,9 +83,9 @@ TextDocument::Insert(int32 offset, const BString& text, const TextStyle& style)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
TextDocument::Insert(int32 offset, const BString& text,
|
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
|
status_t
|
||||||
TextDocument::Replace(int32 offset, int32 length, const BString& text)
|
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
|
status_t
|
||||||
TextDocument::Replace(int32 offset, int32 length, const BString& text,
|
TextDocument::Replace(int32 offset, int32 length, const BString& text,
|
||||||
const TextStyle& style)
|
const CharacterStyle& style)
|
||||||
{
|
{
|
||||||
return Replace(offset, length, text, style, ParagraphStyleAt(offset));
|
return Replace(offset, length, text, style, ParagraphStyleAt(offset));
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ TextDocument::Replace(int32 offset, int32 length, const BString& text,
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
TextDocument::Replace(int32 offset, int32 length, const BString& text,
|
TextDocument::Replace(int32 offset, int32 length, const BString& text,
|
||||||
const TextStyle& textStyle, const ParagraphStyle& paragraphStyle)
|
const CharacterStyle& CharacterStyle, const ParagraphStyle& paragraphStyle)
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@ -130,8 +130,8 @@ TextDocument::Replace(int32 offset, int32 length, const BString& text,
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
const TextStyle&
|
const CharacterStyle&
|
||||||
TextDocument::TextStyleAt(int32 textOffset) const
|
TextDocument::CharacterStyleAt(int32 textOffset) const
|
||||||
{
|
{
|
||||||
int32 paragraphOffset;
|
int32 paragraphOffset;
|
||||||
const Paragraph& paragraph = ParagraphAt(textOffset, paragraphOffset);
|
const Paragraph& paragraph = ParagraphAt(textOffset, paragraphOffset);
|
||||||
@ -147,8 +147,7 @@ TextDocument::TextStyleAt(int32 textOffset) const
|
|||||||
textOffset -= span.CharCount();
|
textOffset -= span.CharCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Document should have a default TextStyle?
|
return fDefaultCharacterStyle;
|
||||||
return fDefaultTextStyle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#ifndef TEXT_DOCUMENT_H
|
#ifndef TEXT_DOCUMENT_H
|
||||||
#define TEXT_DOCUMENT_H
|
#define TEXT_DOCUMENT_H
|
||||||
|
|
||||||
|
#include "CharacterStyle.h"
|
||||||
#include "List.h"
|
#include "List.h"
|
||||||
#include "Paragraph.h"
|
#include "Paragraph.h"
|
||||||
|
|
||||||
@ -15,7 +16,8 @@ typedef List<Paragraph, false> ParagraphList;
|
|||||||
class TextDocument {
|
class TextDocument {
|
||||||
public:
|
public:
|
||||||
TextDocument();
|
TextDocument();
|
||||||
TextDocument(const TextStyle& textStyle,
|
TextDocument(
|
||||||
|
const CharacterStyle& characterStyle,
|
||||||
const ParagraphStyle& paragraphStyle);
|
const ParagraphStyle& paragraphStyle);
|
||||||
TextDocument(const TextDocument& other);
|
TextDocument(const TextDocument& other);
|
||||||
|
|
||||||
@ -26,9 +28,9 @@ public:
|
|||||||
// Text insertion and removing
|
// Text insertion and removing
|
||||||
status_t Insert(int32 offset, const BString& text);
|
status_t Insert(int32 offset, const BString& text);
|
||||||
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,
|
status_t Insert(int32 offset, const BString& text,
|
||||||
const TextStyle& textStyle,
|
const CharacterStyle& characterStyle,
|
||||||
const ParagraphStyle& paragraphStyle);
|
const ParagraphStyle& paragraphStyle);
|
||||||
|
|
||||||
status_t Remove(int32 offset, int32 length);
|
status_t Remove(int32 offset, int32 length);
|
||||||
@ -37,14 +39,14 @@ public:
|
|||||||
const BString& text);
|
const BString& text);
|
||||||
status_t Replace(int32 offset, int32 length,
|
status_t Replace(int32 offset, int32 length,
|
||||||
const BString& text,
|
const BString& text,
|
||||||
const TextStyle& style);
|
const CharacterStyle& style);
|
||||||
status_t Replace(int32 offset, int32 length,
|
status_t Replace(int32 offset, int32 length,
|
||||||
const BString& text,
|
const BString& text,
|
||||||
const TextStyle& textStyle,
|
const CharacterStyle& characterStyle,
|
||||||
const ParagraphStyle& paragraphStyle);
|
const ParagraphStyle& paragraphStyle);
|
||||||
|
|
||||||
// Style access
|
// Style access
|
||||||
const TextStyle& TextStyleAt(int32 textOffset) const;
|
const CharacterStyle& CharacterStyleAt(int32 textOffset) const;
|
||||||
const ParagraphStyle& ParagraphStyleAt(int32 textOffset) const;
|
const ParagraphStyle& ParagraphStyleAt(int32 textOffset) const;
|
||||||
|
|
||||||
// Paragraph access
|
// Paragraph access
|
||||||
@ -59,7 +61,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
ParagraphList fParagraphs;
|
ParagraphList fParagraphs;
|
||||||
Paragraph fEmptyLastParagraph;
|
Paragraph fEmptyLastParagraph;
|
||||||
TextStyle fDefaultTextStyle;
|
CharacterStyle fDefaultCharacterStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ TextSpan::TextSpan()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextSpan::TextSpan(const BString& text, const TextStyle& style)
|
TextSpan::TextSpan(const BString& text, const CharacterStyle& style)
|
||||||
:
|
:
|
||||||
fText(text),
|
fText(text),
|
||||||
fCharCount(text.CountChars()),
|
fCharCount(text.CountChars()),
|
||||||
@ -69,7 +69,7 @@ TextSpan::SetText(const BString& text)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextSpan::SetStyle(const TextStyle& style)
|
TextSpan::SetStyle(const CharacterStyle& style)
|
||||||
{
|
{
|
||||||
fStyle = style;
|
fStyle = style;
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include "TextStyle.h"
|
#include "CharacterStyle.h"
|
||||||
|
|
||||||
|
|
||||||
class TextSpan {
|
class TextSpan {
|
||||||
public:
|
public:
|
||||||
TextSpan();
|
TextSpan();
|
||||||
TextSpan(const BString& text,
|
TextSpan(const BString& text,
|
||||||
const TextStyle& style);
|
const CharacterStyle& style);
|
||||||
TextSpan(const TextSpan& other);
|
TextSpan(const TextSpan& other);
|
||||||
|
|
||||||
TextSpan& operator=(const TextSpan& other);
|
TextSpan& operator=(const TextSpan& other);
|
||||||
@ -26,8 +26,8 @@ public:
|
|||||||
inline const BString& Text() const
|
inline const BString& Text() const
|
||||||
{ return fText; }
|
{ return fText; }
|
||||||
|
|
||||||
void SetStyle(const TextStyle& style);
|
void SetStyle(const CharacterStyle& style);
|
||||||
inline const TextStyle& Style() const
|
inline const CharacterStyle& Style() const
|
||||||
{ return fStyle; }
|
{ return fStyle; }
|
||||||
|
|
||||||
inline int32 CharCount() const
|
inline int32 CharCount() const
|
||||||
@ -46,7 +46,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
BString fText;
|
BString fText;
|
||||||
int32 fCharCount;
|
int32 fCharCount;
|
||||||
TextStyle fStyle;
|
CharacterStyle fStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user