Files
gambling-curses/ui.c

76 lines
977 B
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();
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();
}
size_t ui_width(void)
{
return COLS;
}
size_t ui_height(void)
{
return LINES;
}