blob: 14128bf63e96f9691c7e5f0382c2e27113282fe7 (
plain)
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
|
#include <cursesw.h>
struct Window {
int width;
int height;
char *view;
int *line_ends;
Window() {
initscr();
cbreak();
noecho();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
getmaxyx(stdscr, height, width);
view = new char[width * height];
for (int i = 0; i < width * height; view[i++] = 0);
line_ends = new int[height];
for (int i = 0; i < height; line_ends[i++] = 0);
}
~Window() {
delete[] view;
delete[] line_ends;
endwin();
}
int get_input() {
return getch();
}
void set_cursor(int x, int y) {
move(y, x);
}
void update() {
clear();
for (int i = 0; i < width * height; i++) {
printw("%c", view[i]);
}
}
};
|