Refactoring, license, Box UI framework
This commit is contained in:
64
ui.c
Normal file
64
ui.c
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
/*
|
||||
* 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();
|
||||
nonl();
|
||||
intrflush(stdscr, FALSE);
|
||||
keypad(stdscr, TRUE);
|
||||
clear();
|
||||
refresh();
|
||||
}
|
||||
|
||||
void ui_end()
|
||||
{
|
||||
endwin();
|
||||
}
|
||||
|
||||
void ui_string(size_t x, size_t y, char *s)
|
||||
{
|
||||
mvaddstr(y, x, s);
|
||||
}
|
||||
|
||||
void ui_char(size_t x, size_t 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();
|
||||
}
|
||||
Reference in New Issue
Block a user