Newer
Older
mvc / utils_curses.c
@GallaFrancesco GallaFrancesco on 20 Jun 2017 753 bytes color support, better formatting
#include "utils_curses.h"


void
init_color_pairs()
{
	if(has_colors()){
		start_color();
		use_default_colors();
		init_pair(1, COLOR_RED,     -1);
		init_pair(2, COLOR_GREEN,   -1);
        init_pair(3, COLOR_YELLOW,  -1);
        init_pair(4, COLOR_BLUE,    -1);
        init_pair(5, COLOR_CYAN,    -1);
        init_pair(6, COLOR_MAGENTA, -1);
        init_pair(7, COLOR_WHITE,   -1);		
	}
}

WINDOW*
curses_init()
{
	WINDOW *w;
	if((w = initscr()) == NULL){ //initialize curses library on current screen
		fprintf(stderr, "Error opening screen\n");
		return NULL;
	}
	init_color_pairs();
	return w;
}

void
print_col(int col, int length, int maxR)
{
	int row, l; 
	l = maxR - length;
	for(row=maxR; row>l; row--){
		mvaddch(row, col, SHARP);
	}
}