1 |
|
---|
2 | /*
|
---|
3 | *@@sourcefile ansiscrn.h:
|
---|
4 | * quick ANSI screen code macros for use with printf().
|
---|
5 | * This file does not correspond to any .C code file.
|
---|
6 | *
|
---|
7 | * Usage: Any C code on platforms which support ANSI
|
---|
8 | * escape sequences.
|
---|
9 | *
|
---|
10 | * Based on ANSISCRN.H, which was
|
---|
11 | * contributed to the public domain 12-26-91 by
|
---|
12 | * Matthew J. Glass.
|
---|
13 | *
|
---|
14 | * Note: Version numbering in this file relates to XWorkplace version
|
---|
15 | * numbering.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ANSISCRN_INCLUDED
|
---|
19 | #define ANSISCRN_INCLUDED
|
---|
20 |
|
---|
21 | #include <stdio.h>
|
---|
22 |
|
---|
23 | #define ESC 27
|
---|
24 | #define ANSI_cup(a,b) printf("%c[%d;%dH",ESC,a,b)
|
---|
25 | #define ANSI_up(a) printf("%c[%dA",ESC,a)
|
---|
26 | #define ANSI_down(a) printf("%c[%dB",ESC,a)
|
---|
27 | #define ANSI_right(a) printf("%c[%dC",ESC,a)
|
---|
28 | #define ANSI_left(a) printf("%c[%dD",ESC,a)
|
---|
29 | #define ANSI_locate(a,b) printf("%c[%d;%df",ESC,a,b)
|
---|
30 | #define ANSI_savecurs() printf("%c[S",ESC)
|
---|
31 | #define ANSI_restcurs() printf("%c[U",ESC)
|
---|
32 | #define ANSI_cls() printf("%c[2J",ESC)
|
---|
33 | #define ANSI_cleol() printf("%c[K",ESC)
|
---|
34 | #define ANSI_margins(a,b) printf("%c[%d;%dr",ESC,a,b)
|
---|
35 |
|
---|
36 | #define NORMAL 0 /* attributes for ANSI_attrib() */
|
---|
37 | #define BOLD 1
|
---|
38 | #define USCORE 2
|
---|
39 | #define BLINK 3
|
---|
40 | #define REVERSE 4
|
---|
41 | #define INVIS 5
|
---|
42 |
|
---|
43 | #define BLACK 0 /* colors for ANSI_bg_color() and */
|
---|
44 | #define RED 1 /* ANSI_fg_color. */
|
---|
45 | #define GREEN 2
|
---|
46 | #define YELLOW 3
|
---|
47 | #define BLUE 4
|
---|
48 | #define MAGENTA 5
|
---|
49 | #define CYAN 6
|
---|
50 | #define WHITE 7
|
---|
51 | #define B_BLACK 8 /* bright colors for ANSI_fg_color() */
|
---|
52 | #define B_RED 9
|
---|
53 | #define B_GREEN 10
|
---|
54 | #define B_YELLOW 11
|
---|
55 | #define B_BLUE 12
|
---|
56 | #define B_MAGENTA 13
|
---|
57 | #define B_CYAN 14
|
---|
58 | #define B_WHITE 15
|
---|
59 |
|
---|
60 | static char *_atrb_plt[] = {
|
---|
61 | "0","1","4","5","7","8"
|
---|
62 | };
|
---|
63 |
|
---|
64 | static char *_fg_plt[] = {
|
---|
65 | "0;30","0;31","0;32","0;33",
|
---|
66 | "0;34","0;35","0;36","0;37",
|
---|
67 | "1;30","1;31","1;32","1;33",
|
---|
68 | "1;34","1;35","1;36","1;37"
|
---|
69 | };
|
---|
70 |
|
---|
71 | static char *_bg_plt[] = {
|
---|
72 | "40","41","42","43",
|
---|
73 | "44","45","46","47"
|
---|
74 | };
|
---|
75 |
|
---|
76 | #define ANSI_attrib(a) printf("%c[%sm",ESC,_atrb_plt[a])
|
---|
77 | #define ANSI_fg_color(a) printf("%c[%sm",ESC, _fg_plt[a] )
|
---|
78 | #define ANSI_bg_color(a) printf("%c[%sm",ESC, _bg_plt[a] )
|
---|
79 |
|
---|
80 | #endif /* ANSISCRN */
|
---|