summaryrefslogtreecommitdiff
path: root/src/gui_attrtext.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-06-15 23:20:00 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-22 22:08:54 +0200
commitcb17c3035bbd80bd8ea6718bae4c57cfb2555653 (patch)
treef454181a2f58071f5f2ba4408e7e179838ed3fb4 /src/gui_attrtext.cc
parentface8e0a7d5f530ee3e5e63ab1e3d6ecd497326b (diff)
Initial monitor GUI
Basic monitor functionality, GTK-3.0 and QT5 backends
Diffstat (limited to 'src/gui_attrtext.cc')
-rw-r--r--src/gui_attrtext.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gui_attrtext.cc b/src/gui_attrtext.cc
new file mode 100644
index 0000000..ebb2f32
--- /dev/null
+++ b/src/gui_attrtext.cc
@@ -0,0 +1,37 @@
+// -*- mode: c++; c-basic-offset: 2; -*-
+
+#include "common.hh"
+
+#include <string.h>
+
+#include "gui_attrtext.hh"
+
+void AttributedText::Attribute::add(Attribute const& attr) {
+ flags_ |= attr.flags_;
+ if (attr.has_foreground()) fg_ = attr.foreground();
+ if (attr.has_background()) bg_ = attr.background();
+}
+
+void AttributedText::append(std::string const& str, Attribute const& attr, size_t start, size_t length) {
+ append(str.data(), str.size(), attr, start, length);
+}
+
+void AttributedText::append(const char* str, Attribute const& attr, size_t start, size_t length) {
+ if (!str) {
+ assert(false);
+ return;
+ }
+ append(str, strlen(str), attr, start, length);
+}
+
+// static
+const uint8_t AttributedText::Attribute::BOLD = 1 << 0;
+// static
+const uint8_t AttributedText::Attribute::ITALIC = 1 << 1;
+// static
+const uint8_t AttributedText::Attribute::UNDERLINE = 1 << 2;
+// static
+const uint8_t AttributedText::Attribute::STRIKE = 1 << 3;
+
+// static
+const AttributedText::Attribute AttributedText::EMPTY;