All pastes #476529 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-08 04:19 UTC
rendered paste body
#include <ncurses.h>
#include <time.h>
#include <stdio.h>
#include <types.h>
void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string);
WINDOW *create_newwin(int height, int width, int starty, int startx);
//int timer_gettime(timer_t timerid, struct itimerspec *value);

int main(int argc, char *argv[])
{       initscr();
        int row,col;
        int hour;
        //tm_hour hour;
        char linefiller[255] = " ";
        //char time[255];
        //char nul;
        //nul = "";
        getmaxyx(stdscr, row, col);



        if(has_colors() == FALSE)
        {       endwin();
                printf("Your terminal does not support color\n");
                //exit(1);
        }
        start_color();
        init_pair(1, COLOR_YELLOW, COLOR_BLUE);
        init_pair(2, COLOR_BLACK, COLOR_WHITE);

        WINDOW *my_win;
        int startx, starty, width, height;
        int ch;


        initscr();
        cbreak();

        keypad(stdscr, TRUE);

        height = 25;
        width = COLS -1;
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        memset(linefiller, ' ', width);
*/
        starty = (LINES - height) / 2;
        startx = (COLS - width) / 2;
        attron(COLOR_PAIR(1) | A_BOLD);
        mvprintw(1,startx,linefiller);
        mvprintw(2,startx,linefiller);
mvprintw(1,1,"AutoIF 1.0 by ColdFyre");
        mvprintw(2,1,"http://cfyre.myip.org");
        refresh();
        attron(COLOR_PAIR(2));
        my_win = create_newwin(height - 1,width, 3, 1);
        mvprintw(LINES -2,startx,linefiller);
        //while (getc(stdin) == "") {
        mvprintw(LINES -2,startx,"SysTime: ");
        //printf(time);
        //}
        //mvprintw(LINES -2,startx,"%s",timer_gettime);
        //printf("%s\n >>", hour);


///////////////
// time_t result;


    result = time(NULL);
//    printf("%s%ju secs since the Epoch\n",
//        asctime(localtime(&result)),
//            (uintmax_t)result);
/////////
//    return(0);
        attroff(COLOR_PAIR(2));
        endwin();

        print_in_middle(stdscr, LINES - 1, 1, 1, "");
        attroff(COLOR_PAIR(1));

;


getchar();
        endwin();
}
void print_in_middle(WINDOW *win, int starty, int startx, int width, char *string)
{       int length, x, y;
        float temp;

        if(win == NULL)
                win = stdscr;
        getyx(win, y, x);
        if(startx != 0)
                x = startx;
        if(starty != 0)
                y = starty;

        if(width == 0)
                width = 80;

        length = strlen(string);
        temp = (width - length)/ 2;
        x = startx + (int)temp;
        mvwprintw(win, y, x, "%s", string);
        refresh();
}

WINDOW *create_newwin(int height, int width, int starty, int startx)
{       WINDOW *local_win;

        local_win = newwin(height, width, starty, startx);
        box(local_win, 0 , 0);


        wrefresh(local_win);

        return local_win;
}