summaryrefslogtreecommitdiff
path: root/src/gui_plainattrtext.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-29 01:36:05 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-29 01:36:05 +0200
commit965e7208ad8a22c2e203e94258ec1dc42ee531ef (patch)
tree6787b732ca77975ab0e966d0a18f1f14c104a2c6 /src/gui_plainattrtext.cc
parentee34164a6c1c4f905332cfcfef938a0ccb48333b (diff)
Reuse HexDump in monitor-cmd
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();
+}