repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / haikudepot / textview / TextSpan.h
blobefa5d9d460f693f83d22d690f184809e39ebc75a
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 TEXT_SPAN_H
6 #define TEXT_SPAN_H
9 #include <String.h>
11 #include "CharacterStyle.h"
14 class TextSpan {
15 public:
16 TextSpan();
17 TextSpan(const BString& text,
18 const CharacterStyle& style);
19 TextSpan(const TextSpan& other);
21 TextSpan& operator=(const TextSpan& other);
22 bool operator==(const TextSpan& other) const;
23 bool operator!=(const TextSpan& other) const;
25 void SetText(const BString& text);
26 inline const BString& Text() const
27 { return fText; }
29 void SetStyle(const CharacterStyle& style);
30 inline const CharacterStyle& Style() const
31 { return fStyle; }
33 inline int32 CountChars() const
34 { return fCharCount; }
36 bool Append(const BString& text);
37 bool Insert(int32 offset, const BString& text);
38 bool Remove(int32 start, int32 count);
40 TextSpan SubSpan(int32 start, int32 count) const;
42 private:
43 void _TruncateInsert(int32& start) const;
44 void _TruncateRemove(int32& start,
45 int32& count) const;
47 private:
48 BString fText;
49 int32 fCharCount;
50 CharacterStyle fStyle;
54 #endif // TEXT_SPAN_H