Exemplo n.º 1
0
tview_t* html_tv_init(const char *fn, const char *fn_fa, const char *samples)
	{
	char* colstr=getenv("COLUMNS");
	html_tview_t *tv = (html_tview_t*)calloc(1, sizeof(html_tview_t));
	tview_t* base=(tview_t*)tv;
	if(tv==0)
		{
		fprintf(stderr,"Calloc failed\n");
		return 0;
		}
	tv->row_count=0;
	tv->screen=NULL;
	tv->out=stdout;
	tv->attributes=0;
	base_tv_init(base,fn,fn_fa,samples);
	/* initialize callbacks */
#define SET_CALLBACK(fun) base->my_##fun=html_##fun;
	SET_CALLBACK(destroy);
	SET_CALLBACK(mvprintw);
	SET_CALLBACK(mvaddch);
	SET_CALLBACK(attron);
	SET_CALLBACK(attroff);
	SET_CALLBACK(clear);
	SET_CALLBACK(colorpair);
	SET_CALLBACK(drawaln);
	SET_CALLBACK(loop);
	SET_CALLBACK(underline);
#undef SET_CALLBACK

	
	if(colstr!=0)
		{
		base->mcol=atoi(colstr);
		if(base->mcol<10) base->mcol=80;
		}
	base->mrow=99999;
	
/*
	init_pair(tv,1, "blue", "white");
	init_pair(tv,2, "green", "white");
	init_pair(tv,3, "yellow", "white");
	init_pair(tv,4, "white", "white");
	init_pair(tv,5, "green", "white");
	init_pair(tv,6, "cyan", "white");
	init_pair(tv,7, "yellow", "white");
	init_pair(tv,8, "red", "white");
	init_pair(tv,9, "blue", "white");
	*/
	return base;
	}
Exemplo n.º 2
0
tview_t* curses_tv_init(const char *fn, const char *fn_fa, const char *samples,
                        const htsFormat *fmt)
    {
    curses_tview_t *tv = (curses_tview_t*)calloc(1, sizeof(curses_tview_t));
    tview_t* base=(tview_t*)tv;
    if(tv==0)
        {
        fprintf(stderr,"Calloc failed\n");
        return 0;
        }

    base_tv_init(base,fn,fn_fa,samples,fmt);
    /* initialize callbacks */
#define SET_CALLBACK(fun) base->my_##fun=curses_##fun;
    SET_CALLBACK(destroy);
    SET_CALLBACK(mvprintw);
    SET_CALLBACK(mvaddch);
    SET_CALLBACK(attron);
    SET_CALLBACK(attroff);
    SET_CALLBACK(clear);
    SET_CALLBACK(colorpair);
    SET_CALLBACK(drawaln);
    SET_CALLBACK(loop);
    SET_CALLBACK(underline);
#undef SET_CALLBACK

    initscr();
    keypad(stdscr, TRUE);
    clear();
    noecho();
    cbreak();

    getmaxyx(stdscr, base->mrow, base->mcol);
    tv->wgoto = newwin(3, TV_MAX_GOTO + 10, 10, 5);
    tv->whelp = newwin(30, 40, 5, 5);

    start_color();
    curses_init_colors(0);
    return base;
    }