Update contact information and project home after server crash.
[tetris.git] / conio.h
blob8b666606554f82027e8eb4e443e4063dfaad98b4
1 /* A conio.h like implementation for VTANSI displays.
3 * Copyright (c) 2009 Joachim Nilsson <troglobit@gmail.com>
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #ifndef __CONIO_H__
19 #define __CONIO_H__
21 #include <stdio.h>
23 /* Attributes */
24 #define RESETATTR 0
25 #define BRIGHT 1
26 #define DIM 2
27 #define UNDERSCORE 4
28 #define BLINK 5 /* May not work on all displays. */
29 #define REVERSE 7
30 #define HIDDEN 8
32 /* Colors for text and background */
33 #define BLACK 0x0
34 #define RED 0x1
35 #define GREEN 0x2
36 #define BROWN 0x3
37 #define BLUE 0x4
38 #define MAGENTA 0x5
39 #define CYAN 0x6
40 #define LIGHTGREY 0x7
42 #define DARKGREY 0x10
43 #define LIGHTRED 0x11
44 #define LIGHTGREEN 0x12
45 #define YELLOW 0x13
46 #define LIGHTBLUE 0x14
47 #define LIGHTMAGENTA 0x15
48 #define LIGHTCYAN 0x16
49 #define WHITE 0x17
51 /* Esc[2JEsc[1;1H - Clear screen and move cursor to 1,1 (upper left) pos. */
52 #define clrscr() puts ("\e[2J\e[1;1H")
53 /* Esc[K - Erases from the current cursor position to the end of the current line. */
54 #define clreol() puts ("\e[K")
55 /* Esc[2K - Erases the entire current line. */
56 #define delline() puts ("\e[2K")
57 /* Esc[Line;ColumnH - Moves the cursor to the specified position (coordinates) */
58 #define gotoxy(x,y) printf("\e[%d;%dH", y, x)
59 /* Esc[?25l (lower case L) - Hide Cursor */
60 #define hidecursor() puts ("\e[?25l")
61 /* Esc[?25h (lower case H) - Show Cursor */
62 #define showcursor() puts ("\e[?25h")
64 /* Esc[Value;...;Valuem - Set Graphics Mode */
65 #define __set_gm(attr,color,val) \
66 if (!color) \
67 printf("\e[%dm", attr); \
68 else \
69 printf("\e[%d;%dm", color & 0x10 ? 1 : 0, (color & 0xF) + val)
70 #define textattr(attr) __set_gm(attr, 0, 0)
71 #define textcolor(color) __set_gm(RESETATTR, color, 30)
72 #define textbackground(color) __set_gm(RESETATTR, color, 40)
74 #endif /* __CONIO_H__ */
76 /**
77 * Local Variables:
78 * version-control: t
79 * c-file-style: "ellemtel"
80 * End: