Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <curses.h>
- #include <signal.h>
- static void finish(int sig);
- int main(int argc, char *argv[]){
- int num = 0;
- // our data structures should go here
- (void) signal(SIGINT,finish); //arrange interrupts to terminate
- (void) initscr(); //initialize curses
- keypad(stdscr, TRUE); //enable keyboard
- (void) nonl(); //don't do newlines and whatnot
- //(void) cbreak(); //take input chars one at a time
- (void) echo(); //echo input in color
- //going to make our windows, first we have to get the size of the current terminal
- //TODO: resize windows when term is resized
- int termwidth = getmaxy(stdscr);
- int termheight = getmaxx(stdscr);
- int chanheight = termheight - 1;
- WINDOW *channel = newwin(termwidth, chanheight, 0, 0);
- scrollok(channel, TRUE);
- WINDOW *input = newwin(termwidth, 1, termheight + 1, 0);
- scrollok(input, TRUE);
- wmove(channel, 0, 0);
- wrefresh(input);
- wrefresh(channel);
- printw("proportions: %i %i", termwidth, termheight);
- wmove(input, 0, 0);
- if (has_colors()){
- start_color(); //i assume this initializes colors
- //we're setting the various colorset IDs here, I'm planning on
- //using pair 0 for channel text and pair 1 for OOC. pair 2 should
- //be for menus.
- init_pair(1, COLOR_RED, COLOR_BLACK);
- init_pair(2, COLOR_GREEN, COLOR_BLACK);
- init_pair(3, COLOR_BLACK, COLOR_WHITE);
- }
- //main loop
- for (;;) {
- int c = getch(); //on refresh, we get the single keystroke of input
- //wmove(channel, 0, 0);
- if (c == 101) {
- printw("\nyou pressed e!\n> ");
- } else {
- wprintw(channel, "%c (%i)\n", c, c);
- wprintw(input, "CLAMSAUCE%c", c);
- }
- wmove(input, 0, 0);
- wrefresh(channel);
- wrefresh(input);
- }
- finish(0); //done
- }
- static void finish(int sig){
- endwin();
- //our wrapup goes here
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment