-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen.h
134 lines (111 loc) · 2.92 KB
/
screen.h
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// vim: set ft=cpp:
#ifndef ZTERP_SCREEN_H
#define ZTERP_SCREEN_H
#include <bitset>
#include <string>
#ifdef ZTERP_GLK
extern "C" {
#include <glk.h>
}
#endif
#include "iff.h"
#include "io.h"
#include "types.h"
#include "util.h"
// Represents a Z-machine color.
//
// If mode is ANSI, value is a color in the range [1, 12], representing
// the colors as described in §8.3.1.
//
// If mode is True, value is a 15-bit color as described in §8.3.7 and
// §15.
struct Color {
enum class Mode { ANSI, True } mode;
uint16_t value;
explicit Color() : mode(Mode::ANSI), value(1) {
}
Color(Mode mode_, uint16_t value_) : mode(mode_), value(value_) {
}
};
void init_screen(bool first_run);
bool create_mainwin();
bool create_statuswin();
bool create_upperwin();
void get_screen_size(unsigned int &width, unsigned int &height);
void close_upper_window();
uint32_t screen_convert_color(uint16_t color);
// Text styles.
using Style = std::bitset<4>;
enum StyleBit {
STYLE_REVERSE = 0,
STYLE_BOLD = 1,
STYLE_ITALIC = 2,
STYLE_FIXED = 3,
};
zprintflike(1, 2)
void show_message(const char *fmt, ...);
void screen_print(const std::string &s);
zprintflike(1, 2)
void screen_printf(const char *fmt, ...);
void screen_puts(const std::string &s);
void screen_message_prompt(const std::string &message);
void screen_flush();
#ifdef ZTERP_GLK
void term_keys_reset();
void term_keys_add(uint8_t key);
#endif
#ifdef GLK_MODULE_GARGLKTEXT
void update_color(int which, unsigned long color);
#endif
// Output streams.
constexpr uint16_t OSTREAM_SCREEN = 1;
constexpr uint16_t OSTREAM_SCRIPT = 2;
constexpr uint16_t OSTREAM_MEMORY = 3;
constexpr uint16_t OSTREAM_RECORD = 4;
// Input streams.
constexpr int ISTREAM_KEYBOARD = 0;
constexpr int ISTREAM_FILE = 1;
void screen_set_header_bit(bool set);
bool output_stream(int16_t number, uint16_t table);
bool input_stream(int which);
int print_handler(uint32_t addr, void (*outc)(uint8_t));
void put_char(uint8_t c);
std::string screen_format_time(long hours, long minutes);
void screen_read_scrn(IO &io, uint32_t size);
IFF::TypeID screen_write_scrn(IO &io);
void screen_read_bfhs(IO &io, bool autosave);
IFF::TypeID screen_write_bfhs(IO &io);
void screen_read_bfts(IO &io, uint32_t size);
IFF::TypeID screen_write_bfts(IO &io);
void screen_save_persistent_transcript();
void zoutput_stream();
void zinput_stream();
void zprint();
void znew_line();
void zprint_ret();
void zerase_window();
void zerase_line();
void zset_cursor();
void zget_cursor();
void zset_colour();
void zset_true_colour();
void zset_text_style();
void zset_font();
void zprint_table();
void zprint_char();
void zprint_num();
void zprint_addr();
void zprint_paddr();
void zsplit_window();
void zset_window();
void zread_char();
void zshow_status();
void zread();
void zprint_unicode();
void zcheck_unicode();
void zpicture_data();
void zget_wind_prop();
void zprint_form();
void zmake_menu();
void zbuffer_screen();
#endif