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
|
#ifndef ANSISCRN
#define ANSISCRN
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* ANSISCRN.H
*
* #include implementation of ANSI screen control codes
* Contributed to the public domain 12-26-91 by
* Matthew J. Glass.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#define ESC 27
#define ANSI_cup(a,b) printf("%c[%d;%dH",ESC,a,b)
#define ANSI_up(a) printf("%c[%dA",ESC,a)
#define ANSI_down(a) printf("%c[%dB",ESC,a)
#define ANSI_right(a) printf("%c[%dC",ESC,a)
#define ANSI_left(a) printf("%c[%dD",ESC,a)
#define ANSI_locate(a,b) printf("%c[%d;%df",ESC,a,b)
#define ANSI_savecurs() printf("%c[S",ESC)
#define ANSI_restcurs() printf("%c[U",ESC)
#define ANSI_cls() printf("%c[2J",ESC)
#define ANSI_cleol() printf("%c[K",ESC)
#define ANSI_margins(a,b) printf("%c[%d;%dr",ESC,a,b)
#define NORMAL 0 /* attributes for ANSI_attrib() */
#define BOLD 1
#define USCORE 2
#define BLINK 3
#define REVERSE 4
#define INVIS 5
#define BLACK 0 /* colors for ANSI_bg_color() and */
#define RED 1 /* ANSI_fg_color. */
#define GREEN 2
#define YELLOW 3
#define BLUE 4
#define MAGENTA 5
#define CYAN 6
#define WHITE 7
#define B_BLACK 8 /* bright colors for ANSI_fg_color() */
#define B_RED 9
#define B_GREEN 10
#define B_YELLOW 11
#define B_BLUE 12
#define B_MAGENTA 13
#define B_CYAN 14
#define B_WHITE 15
static char *_atrb_plt[] = {
"0","1","4","5","7","8"
};
static char *_fg_plt[] = {
"0;30","0;31","0;32","0;33",
"0;34","0;35","0;36","0;37",
"1;30","1;31","1;32","1;33",
"1;34","1;35","1;36","1;37"
};
static char *_bg_plt[] = {
"40","41","42","43",
"44","45","46","47"
};
#define ANSI_attrib(a) printf("%c[%sm",ESC,_atrb_plt[a])
#define ANSI_fg_color(a) printf("%c[%sm",ESC, _fg_plt[a] )
#define ANSI_bg_color(a) printf("%c[%sm",ESC, _bg_plt[a] )
#endif /* ANSISCRN */
|