1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
|