From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONTRIB/SNIP/ansiscrn.h | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 reference/C/CONTRIB/SNIP/ansiscrn.h (limited to 'reference/C/CONTRIB/SNIP/ansiscrn.h') diff --git a/reference/C/CONTRIB/SNIP/ansiscrn.h b/reference/C/CONTRIB/SNIP/ansiscrn.h new file mode 100755 index 0000000..9338b68 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/ansiscrn.h @@ -0,0 +1,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 + +#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 */ -- cgit v1.2.3-54-g00ecf