-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcurses.c
124 lines (100 loc) · 2.51 KB
/
curses.c
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
//
// Created by Nathan Flint on 12/29/19.
//
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include "curses.h"
#include "rogue.h"
#pragma code-name(push, "LC")
void wclear(struct WINDOW *window) {
unsigned char x, y;
window->y = window->x = 0;
for(y = 0; y < LINES; y++ ) {
sprintf(window->data[y], " ");
// for(x = 0; x < COLS; x++ ) {
// window->data[y][x] = ' ';
// }
}
window->end = 0;
if (window == cw) {
clrscr();
}
}
void wmove(struct WINDOW *window, unsigned char y, unsigned char x) {
window->x = x;
window->y = y;
if (window == cw)
gotoxy(x, y);
}
//put char, then move forward
void waddch(struct WINDOW *window, char character) {
unsigned char
x = window->x,
y = window->y;
if (window == cw)
putchar(character);
window->data[y][x] = character;
(window->x)++;
}
// get char at current x, y
char winch(struct WINDOW *window) {
unsigned char x, y;
getyx(window, y, x);
return window->data[y][x];
}
char mvwinch(struct WINDOW *window, unsigned char y, unsigned char x) {
wmove(window, y, x);
return winch(window);
}
void mvwaddch(struct WINDOW *window, unsigned char y, unsigned char x, char ch) {
wmove(window, y, x);
waddch(window, ch);
}
void show_window(struct WINDOW *window) {
clrscr();
cputsxy(0, 0, window->data[0]);
}
void wclrtoeol(struct WINDOW *window) {
char
//*row = window->data[window->y],
x = wherex();
while (x++ < COLS)
{
cputc(' ');
//mvwaddch(cw, y, x++, ' ');
//row[x++] = ' ';
}
// if(window == cw) {
// gotoxy(x,y);
// clrtoeol();
// }
}
void waddstr(struct WINDOW *window, char *string) {
unsigned char x = window->x, y = window->y;
strcpy(&window->data[y][x], string);
if (window == cw){
cputsxy(x, y, string);
}
}
char buffer[81];
void debug_num(char *description, int number) {
gotoxy(0,0);
cclear(80);
sprintf(buffer, "%s: %d", description, number);
cputsxy(0, 0, buffer);
cgetc();
}
void debug_coord(char *description, coord *coor) {
gotoxy(0,0);
cclear(80);
sprintf(buffer, "%s: x:%d, y:%d", description, coor->x, coor->y);
cputsxy(0, 0, buffer);
cgetc();
}
void debug_char(char *description, char ch) {
sprintf(buffer, "%s: %c", description, ch);
cputsxy(0, 0, buffer);
cgetc();
}
#pragma code-name(pop)