libite
|
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | LIBITE_CONIO_H_ |
#define | RESETATTR 0 |
Attributes. | |
#define | BRIGHT 1 |
#define | DIM 2 |
#define | UNDERSCORE 4 |
#define | BLINK 5 /* May not work on all displays. */ |
#define | REVERSE 7 |
#define | HIDDEN 8 |
#define | BLACK 0x0 |
Colors for text and background. | |
#define | RED 0x1 |
#define | GREEN 0x2 |
#define | BROWN 0x3 |
#define | BLUE 0x4 |
#define | MAGENTA 0x5 |
#define | CYAN 0x6 |
#define | LIGHTGREY 0x7 |
#define | DARKGREY 0x10 |
#define | LIGHTRED 0x11 |
#define | LIGHTGREEN 0x12 |
#define | YELLOW 0x13 |
#define | LIGHTBLUE 0x14 |
#define | LIGHTMAGENTA 0x15 |
#define | LIGHTCYAN 0x16 |
#define | WHITE 0x17 |
#define | SCREEN_WIDTH 80 |
Fallback screen width, possible to override. More... | |
#define | clrscr() fputs("\033[2J\033[1;1H", stdout) |
Clear screen and move cursor to 1,1 (upper left) pos. More... | |
#define | clreol() fputs("\033[K", stdout) |
Erases from the current cursor position to the end of the current line. More... | |
#define | delline() fputs("\033[2K", stdout) |
Erases the entire current line. More... | |
#define | gotoxy(x, y) fprintf(stdout, "\033[%d;%dH", y, x) |
Moves the cursor to the specified position (coordinates) | |
#define | hidecursor() fputs("\033[?25l", stdout) |
Hide Cursor. | |
#define | showcursor() fputs("\033[?25h", stdout) |
Show Cursor. | |
#define | __set_gm(a, c, v) |
Set Graphics Mode (attr, color, val) More... | |
#define | textattr(attr) __set_gm(attr, 0, 0) |
Set text attribute. | |
#define | textcolor(color) __set_gm(RESETATTR, color, 30) |
Set text color. | |
#define | textbackground(color) __set_gm(RESETATTR, color, 40) |
Set text background. | |
Functions | |
void | initscr (int *row, int *col) |
Probe terminal size. More... | |
Helper macros and functions for interacting with TTY terminals.
#define __set_gm | ( | a, | |
c, | |||
v | |||
) |
Set Graphics Mode (attr, color, val)
#define clreol | ( | ) | fputs("\033[K", stdout) |
Erases from the current cursor position to the end of the current line.
#define clrscr | ( | ) | fputs("\033[2J\033[1;1H", stdout) |
Clear screen and move cursor to 1,1 (upper left) pos.
#define delline | ( | ) | fputs("\033[2K", stdout) |
Erases the entire current line.
#define SCREEN_WIDTH 80 |
Fallback screen width, possible to override.
void initscr | ( | int * | row, |
int * | col | ||
) |
Probe terminal size.
row | pointer to integer to store number of rows |
col | pointer to integer to store number of columns |
This function checks if stdin and stdout isatty() and then sets the TTY in raw mode to silently ask the size using ANSI escape sequences. This is achieved by trying to go to corner 999,999 followed by querying the cursor position. Afterwards the TTY is returned to the state if was before, e.g. cooked. The number of rows and columns is returned in the input arguments to this function.
If stdio is not a TTY, then a default 24x80 is returned.