-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathglyph.cpp
More file actions
55 lines (47 loc) · 975 Bytes
/
glyph.cpp
File metadata and controls
55 lines (47 loc) · 975 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <sstream>
#include "glyph.h"
#include "options.h"
std::string glyph::save_data()
{
std::stringstream ret;
ret << symbol << " " << int(fg) << " " << int(bg);
return ret.str();
};
void glyph::load_data(std::istream &datastream)
{
int fgtmp, bgtmp;
datastream >> symbol >> fgtmp >> bgtmp;
fg = nc_color(fgtmp);
bg = nc_color(bgtmp);
}
glyph glyph::invert()
{
glyph ret = (*this);
nc_color tmp = ret.fg;
ret.fg = ret.bg;
ret.bg = tmp;
if (NO_BRIGHT_BG) {
ret.bg = non_bright(ret.bg);
}
return ret;
}
glyph glyph::hilite()
{
if (bg == HILITE_COLOR) {
return invert();
}
glyph ret = (*this);
ret.bg = HILITE_COLOR;
return ret;
}
std::string glyph::text_formatted()
{
std::stringstream ret;
ret << "<c=" << color_tag(fg) << "," << color_tag(bg) << ">" <<
char(symbol) << "<c=/>";
return ret.str();
}
bool glyph::operator==(const glyph &rhs)
{
return (rhs.fg == fg && rhs.bg == bg && rhs.symbol == symbol);
}