-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconioreal.c
113 lines (102 loc) · 1.64 KB
/
conioreal.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
#include "conioreal.h"
int initconio(void)
{
short f, b, p;
initscr();
start_color();
noecho();
p = 1;
for(f = 0; f < 8; f++)
for(b = 0; b < 8; b++, p++)
init_pair(p, f, b);
cur_pair = 57;
cur_bold = 0;
color_set(cur_pair, NULL);
attroff(A_BOLD);
return 0;
}
int endconio(void)
{
endwin();
return 0;
}
int clrscr(void)
{
bkgdset(COLOR_PAIR(cur_pair));
if(cur_bold == 0)
attroff(A_BOLD);
else
attron(A_BOLD);
clear();
return 0;
}
int clreol(void)
{
int cur_x, x, y, maxx;
color_set(cur_pair, NULL);
getmaxyx(stdscr, y, maxx);
cur_x = wherex();
gotoxy(1, wherey());
for(x = 1; x <= maxx; x++)
printw(" ");
gotoxy(cur_x, wherey() - 1);
return 0;
}
int textcolor(int color)
{
short x, y, f, b, p = 1;
pair_content(cur_pair, &f, &b);
for(x = 0; x < 8; x++)
for(y = 0; y < 8; y++, p++)
if((x == (color%8))&&(y == b))
cur_pair = p;
color_set(cur_pair, NULL);
if(color >= 8)
cur_bold = 1;
if(cur_bold == 0)
attroff(A_BOLD);
else
attron(A_BOLD);
return 0;
}
int textbackground(int color)
{
short x, y, f, b, p = 1;
pair_content(cur_pair, &f, &b);
for(x = 0; x < 8; x++)
for(y = 0; y < 8; y++, p++)
if((x == f)&&(y == (color%8)))
cur_pair = p;
color_set(cur_pair, NULL);
return 0;
}
int getche(void)
{
char c;
echo();
c = getch();
noecho();
return c;
}
int wherex(void)
{
int x, y;
getyx(stdscr, y, x);
return x + 1;
}
int wherey(void)
{
int x, y;
getyx(stdscr, y, x);
return y + 1;
}
int gotoxy(int x, int y)
{
move(y - 1, x - 1);
return 0;
}
int newline(void)
{
gotoxy(1, wherey() + 1);
return 0;
}