From 965e7208ad8a22c2e203e94258ec1dc42ee531ef Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sat, 29 Jul 2017 01:36:05 +0200 Subject: Reuse HexDump in monitor-cmd --- src/gui_plainattrtext.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/gui_plainattrtext.cc (limited to 'src/gui_plainattrtext.cc') 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(); +} -- cgit v1.2.3-70-g09d2