77 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
 | |
| /*
 | |
|  * Copyright (C) Artsiom D.
 | |
|  * Copyright (C) shit-co.de
 | |
|  */
 | |
| 
 | |
|  
 | |
| #include <curses.h>
 | |
| #include <stdlib.h>
 | |
| #include <time.h>
 | |
| #include "ui.h"
 | |
| 
 | |
| 
 | |
| void
 | |
| ui_init(void)
 | |
| {
 | |
|     srand(time(NULL));
 | |
|     initscr();
 | |
|     start_color();
 | |
|     init_pair(UI_GREEN, COLOR_GREEN, COLOR_BLACK);
 | |
|     init_pair(UI_RED,   COLOR_RED,   COLOR_BLACK);
 | |
|     init_pair(UI_BLUE,  COLOR_BLUE,  COLOR_BLACK);
 | |
|     cbreak();
 | |
|     noecho();
 | |
|     nodelay(stdscr, TRUE);
 | |
|     nonl();
 | |
|     intrflush(stdscr, FALSE);
 | |
|     keypad(stdscr, TRUE);
 | |
|     clear();
 | |
|     refresh();
 | |
| }
 | |
| 
 | |
| void ui_end()
 | |
| {
 | |
|     endwin();
 | |
| }
 | |
| 
 | |
| void ui_string(unsigned int x, unsigned int y, char *s)
 | |
| {
 | |
|     mvaddstr(y, x, s);
 | |
| }
 | |
| 
 | |
| void ui_char(unsigned int x, unsigned int y, char c)
 | |
| {
 | |
|     mvaddch(y, x, c);
 | |
| }
 | |
| 
 | |
| void ui_color_on(enum ui_color c)
 | |
| {
 | |
|     attron(COLOR_PAIR(c));
 | |
| }
 | |
| 
 | |
| void ui_color_off(enum ui_color c)
 | |
| {
 | |
|     attroff(COLOR_PAIR(c));
 | |
| }
 | |
| 
 | |
| void ui_refresh(void)
 | |
| {
 | |
|     refresh();
 | |
| }
 | |
| 
 | |
| void ui_clear(void)
 | |
| {
 | |
|     clear();
 | |
| }
 | |
| 
 | |
| size_t ui_width(void)
 | |
| {
 | |
|     return COLS;
 | |
| }
 | |
| 
 | |
| size_t ui_height(void)
 | |
| {
 | |
|     return LINES;
 | |
| }
 |