12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include "../include/curses.h"
- #include <termios.h>
- #include <stddef.h>
- #include <stdio.h>
-
- #define ESC 27
- #define MODE 3
-
- unsigned int _COLOUR_PAIRS = 4;
- unsigned int _COLOURS = 8;
- unsigned short _COLS = 80;
- unsigned short _LINES = 25;
-
- static struct termios original, runtime;
-
- void _init_screen( struct _curses_screen *scr __unused ) {
- tcgetattr(fileno(stdin),&original);
- tcgetattr(fileno(stdin),&runtime);
- runtime.c_lflag &= ~(ICANON|ECHO);
- tcsetattr(fileno(stdin),TCSANOW,&runtime);
-
- LINES = 25; COLS = 80;
- }
-
- void _exit_screen( struct _curses_screen *scr __unused ) {
- printf("%c[1;1H",ESC);
- printf("%c[2J",ESC);
- tcsetattr(fileno(stdin),TCSANOW,&original);
- }
-
- void _movetoyx( struct _curses_screen *scr __unused, unsigned int y, unsigned int x ) {
- printf( "%c[%d;%dH", ESC, y+1, x+1 );
- }
-
- void _putc( struct _curses_screen *scr __unused, chtype c ) {
- unsigned short pairno;
- pairno = (unsigned short)(( c & A_COLOUR ) >> CPAIR_SHIFT);
-
-
-
-
-
-
- putchar( c );
- fflush(stdout);
- }
-
- int _getc( struct _curses_screen *scr __unused ) {
- return getchar();
- }
-
- bool _peek( struct _curses_screen *scr __unused ) {
- int c;
- if ( ( c = getchar() ) != EOF ) {
- ungetc( c, stdin );
- return TRUE;
- } else { return FALSE; }
- }
-
- SCREEN _curscr = {
- .init = _init_screen,
- .exit = _exit_screen,
- .movetoyx = _movetoyx,
- .putc = _putc,
- .getc = _getc,
- .peek = _peek,
- };
|