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.
28 #define BLINK 5 /* May not work on all displays. */
32 /* Colors for text and background */
44 #define LIGHTGREEN 0x12
46 #define LIGHTBLUE 0x14
47 #define LIGHTMAGENTA 0x15
48 #define LIGHTCYAN 0x16
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) \
67 printf("\e[%dm", attr); \
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__ */
79 * c-file-style: "ellemtel"