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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#ifndef __FORMAT_H__
#define __FORMAT_H__
#include <string>
#include <vector>
#include "externs.h"
// Definitions for formatted_string
enum fs_op_type
{
FSOP_COLOUR,
FSOP_CURSOR,
FSOP_TEXT
};
class formatted_string
{
public:
formatted_string(int init_colour = 0);
formatted_string(const std::string &s, int init_colour = 0);
operator std::string() const;
void display(int start = 0, int end = -1) const;
std::string tostring(int start = 0, int end = -1) const;
void cprintf(const char *s, ...);
void cprintf(const std::string &s);
void gotoxy(int x, int y);
void movexy(int delta_x, int delta_y);
void add_glyph(const monsters *mons);
void add_glyph(const item_def *item);
void textcolor(int color);
void clear();
std::string::size_type length() const;
const formatted_string &operator += (const formatted_string &other);
public:
static formatted_string parse_string(
const std::string &s,
bool eol_ends_format = true,
bool (*process_tag)(const std::string &tag) = NULL );
static int get_colour(const std::string &tag);
private:
int find_last_colour() const;
public:
struct fs_op
{
fs_op_type type;
int x, y;
bool relative;
std::string text;
fs_op(int color)
: type(FSOP_COLOUR), x(color), y(-1), relative(false), text()
{
}
fs_op(int cx, int cy, bool rel = false)
: type(FSOP_CURSOR), x(cx), y(cy), relative(rel), text()
{
}
fs_op(const std::string &s)
: type(FSOP_TEXT), x(-1), y(-1), relative(false), text(s)
{
}
operator fs_op_type () const
{
return type;
}
void display() const;
};
std::vector<fs_op> ops;
};
#endif
|