summaryrefslogtreecommitdiff
path: root/src/gui_plainattrtext.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui_plainattrtext.cc')
-rw-r--r--src/gui_plainattrtext.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/gui_plainattrtext.cc b/src/gui_plainattrtext.cc
new file mode 100644
index 0000000..a588172
--- /dev/null
+++ b/src/gui_plainattrtext.cc
@@ -0,0 +1,45 @@
+// -*- mode: c++; c-basic-offset: 2; -*-
+
+#include "common.hh"
+
+#include "gui_plainattrtext.hh"
+
+namespace {
+
+class PlainAttributedTextImpl : public PlainAttributedText {
+public:
+ void append(const char* str, size_t len, Attribute const& UNUSED(attr),
+ size_t start, size_t length) override {
+ if (!str || start >= len) return;
+ length = std::min(len - start, length);
+ if (length == 0) return;
+ text_.append(str + start, length);
+ }
+
+ void add(Attribute const& UNUSED(attr), size_t UNUSED(start),
+ size_t UNUSED(length)) override {
+ }
+ void set(Attribute const& UNUSED(attr), size_t UNUSED(start),
+ size_t UNUSED(length)) override {
+ }
+ void clear(size_t UNUSED(start), size_t UNUSED(length)) override {
+ }
+
+ std::string text() const override {
+ return text_;
+ }
+
+ void reset() override {
+ text_.clear();
+ }
+
+private:
+ std::string text_;
+};
+
+} // namespace
+
+// static
+PlainAttributedText* PlainAttributedText::create() {
+ return new PlainAttributedTextImpl();
+}