Annotation of embedaddon/pimd/libite/conio.h, revision 1.1

1.1     ! misho       1: /* A conio.h like implementation for VTANSI displays.
        !             2:  *
        !             3:  * Copyright (c) 2009-2013  Joachim Nilsson <troglobit@gmail.com>
        !             4:  *
        !             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.
        !             8:  *
        !             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.
        !            16:  */
        !            17: 
        !            18: #ifndef CONIO_H_
        !            19: #define CONIO_H_
        !            20: 
        !            21: #include <stdio.h>
        !            22: 
        !            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
        !            31: 
        !            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
        !            41: 
        !            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
        !            50: 
        !            51: /* Esc[2JEsc[1;1H             - Clear screen and move cursor to 1,1 (upper left) pos. */
        !            52: #define clrscr()              fputs ("\e[2J\e[1;1H", stdout)
        !            53: /* Esc[K                      - Erases from the current cursor position to the end of the current line. */
        !            54: #define clreol()              fputs ("\e[K", stdout)
        !            55: /* Esc[2K                     - Erases the entire current line. */
        !            56: #define delline()             fputs ("\e[2K", stdout)
        !            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()          fputs ("\e[?25l", stdout)
        !            61: /* Esc[?25h (lower case H)    - Show Cursor */
        !            62: #define showcursor()          fputs ("\e[?25h", stdout)
        !            63: 
        !            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)
        !            73: 
        !            74: #endif /* CONIO_H_ */
        !            75: 
        !            76: /**
        !            77:  * Local Variables:
        !            78:  *  version-control: t
        !            79:  *  indent-tabs-mode: t
        !            80:  *  c-file-style: "linux"
        !            81:  * End:
        !            82:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>