static void resize (int sig) { finish_index (); endwin (); refresh (); initscr (); keypad (stdscr, TRUE); /* enable keypad for use of arrow keys */ nonl (); /* tell curses not to do NL->CR/NL on output */ cbreak (); /* take input chars immediately */ noecho (); init_index (data_path); display_index (); refresh (); }
/** * Suspend/Resume */ static errr Term_xtra_gcu_alive(int v) { if (!v) { /* Suspend */ int x, y; /* Go to normal keymap mode */ keymap_norm(); /* Restore modes */ nocbreak(); echo(); nl(); /* Hack -- make sure the cursor is visible */ Term_xtra(TERM_XTRA_SHAPE, 1); /* Flush the curses buffer */ refresh(); /* Get current cursor position */ getyx(stdscr, y, x); /* Move the cursor to bottom right corner */ mvcur(y, x, LINES - 1, 0); /* Exit curses */ endwin(); /* Flush the output */ fflush(stdout); } else { /* Resume */ /* Restore the settings */ cbreak(); noecho(); nonl(); /* Go to angband keymap mode */ keymap_game(); } /* Success */ return 0; }
main() { int i, c; char buf[120]; initscr(); nonl(); noecho(); cbreak(); cmdwin = newwin(3, COLS, 0, 0); for (i = 0; i < LINES; i++) { mvprintw(i, 0, "this is line %d of stdscr", i); } for ( ; ; ) { refresh(); c = getch(); switch (c) { case 'c': werase(cmdwin); wprintw(cmdwin,"enter command:"); wmove(cmdwin, 2, 0); for (i = 0; i < COLS; i++) { waddch(cmdwin, '-'); } wmove(cmdwin, 1, 0); touchwin(cmdwin); wrefresh(cmdwin); wgetstr(cmdwin, buf); touchwin(stdscr); wmove(stdscr, 14, 0); wprintw(stdscr,"command: %s", buf); break; case 'q': endwin(); exit(0); } } }
static void init(void) { int x, y; #ifdef yaomoon moon_log = fopen("moon_log","w+"); #endif /* Initialize the curses library */ if (isatty(STDIN_FILENO)) { cursed = !!initscr(); } else { /* Leave stdin and stdout alone when acting as a pager. */ FILE *io = fopen("/dev/tty", "r+"); cursed = !!newterm(NULL, io, io); } if (!cursed) die("Failed to initialize curses"); nonl(); /* tell curses not to do NL->CR/NL on output */ cbreak(); /* take input chars one at a time, no wait for \n */ noecho(); /* don't echo input */ leaveok(stdscr, TRUE); if (has_colors()) { init_colors(); } getmaxyx(stdscr, y, x); #ifdef yaomoon fprintf(moon_log,"getmaxyx y=%d\n",y); fprintf(moon_log,"getmaxyx x=%d\n",x); #endif status_win = newwin(1, 0, y - 10, 0); if (!status_win) die("failed to create status window"); keypad(status_win, TRUE); wbkgdset(status_win, get_line_attr(LINE_STATUS)); }
/* * This routine handles all the necessary curses initialization. */ void pt_display_init_curses(void) { (void) initscr(); (void) atexit(pt_display_cleanup); pt_display_get_size(); (void) start_color(); /* * Enable keyboard mapping */ (void) keypad(stdscr, TRUE); /* * Tell curses not to do NL->CR/NL on output */ (void) nonl(); /* * Take input chars one at a time, no wait for \n */ (void) cbreak(); /* * Dont echo input */ (void) noecho(); /* * Turn off cursor */ (void) curs_set(0); (void) init_pair(PT_COLOR_DEFAULT, COLOR_WHITE, COLOR_BLACK); (void) init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_WHITE); (void) init_pair(PT_COLOR_ERROR, COLOR_BLACK, COLOR_RED); (void) init_pair(PT_COLOR_RED, COLOR_WHITE, COLOR_RED); (void) init_pair(PT_COLOR_YELLOW, COLOR_WHITE, COLOR_YELLOW); (void) init_pair(PT_COLOR_GREEN, COLOR_WHITE, COLOR_GREEN); (void) init_pair(PT_COLOR_BLUE, COLOR_WHITE, COLOR_BLUE); (void) init_pair(PT_COLOR_BRIGHT, COLOR_WHITE, COLOR_BLACK); }
void initialize() { int i; int numberAntennas; initscr(); #ifdef LINUX if(colorFlag) { start_color(); } nonl(); clear(); #endif /* LINES and COLS are now defined */ if (COLS > 132) COLS = 132; if ((COLS >= MINIMUM_SCREEN_WIDTH_FOR_ESMA) && FALSE){ numberAntennas = 10; } else { numberAntennas = 8; } if (LINES >= MIN_LINES_FOR_BOTTOM_2OP) { bottom2op = TRUE; } if (LINES >= MIN_LINES_FOR_BOTTOM_OPMSG) { bottomOpMsg = TRUE; } if ((COLS >= MINIMUM_SCREEN_WIDTH_FOR_ESMA) && FALSE) { numberAntennas = 10; } else { numberAntennas = 8; } /* box(stdscr, '|','-'); */ for (i = 1; i < COLS-1; i++) {move(0,i);printw("-");} for (i = 1; i < COLS-1; i++) {move(23,i);printw("-");} for (i = 1; i < 23; i++) {move(i,0);printw("|");} for (i = 1; i < 23; i++) {move(i,COLS-1);printw("|");} #if 0 move(0,0); printw("COLS=%d",COLS); #endif move(2,2); }
void init_curses(void) { int screen_size[2]; initscr(); cbreak(); nonl(); noecho(); keypad(stdscr, TRUE); curs_set(0); refresh(); getmaxyx(stdscr, screen_size[0], screen_size[1]); tree_window = newwin(screen_size[0] - 1, screen_size[1], 0, 0); info_window = newwin(1, screen_size[1], screen_size[0] - 1, 0); scrollok(tree_window, TRUE); idlok(tree_window, TRUE); }
void engine_start(void){ // start ncurses screen initscr(); start_color(); // customizations raw(); nodelay(stdscr, TRUE); noecho(); nonl(); curs_set(0); keypad(stdscr, TRUE); refresh(); // render game draw_border(); print_welcome_message(); }
void reset(int code) { endwin(); initscr(); nonl(); cbreak(); noecho(); keypad(stdscr, TRUE); nodelay(stdscr, TRUE); curs_set(FALSE); set_escdelay(10); start_color(); use_default_colors(); assume_default_colors(COLOR_WHITE, COLOR_BLACK); idlok(stdscr, TRUE); clear(); refresh(); }
void init_curses(void) { initscr(); start_color(); init_pair(PANEL,COLOR_BLUE,COLOR_WHITE); init_pair(BAR,COLOR_WHITE,COLOR_BLUE); init_pair(3,COLOR_RED,COLOR_GREEN); init_pair(4,COLOR_GREEN,COLOR_RED); init_pair(5,COLOR_GREEN,COLOR_BLUE); nonl(); cbreak(); noecho(); leaveok(stdscr, TRUE); #ifdef debug moon_log = fopen("moon_log","w+"); #endif }
int InputManager::startUp(){ GraphicsManager& graphics_manager = GraphicsManager::getInstance(); LogManager& log_manager = LogManager::getInstance(); if(!graphics_manager.isStarted()){ log_manager.writeLog("InputManager::startUp(): GraphicsManager is not started. "); return -1; } // Error checking int* flag = new int[7](); // enable keypad *(flag++) = keypad(stdscr, TRUE); // disable line buffering *(flag++) = cbreak(); // turn off newline so can detect 'enter' key *(flag++) = nonl(); // disable character echo *(flag++) = noecho(); // turn off the cursor *(flag++) = curs_set(0); // no delay for input *(flag++) = nodelay(stdscr, TRUE); // enable mouse event *flag = mousemask(BUTTON1_CLICKED, NULL); flag -= 6; for(int i = 0; i != 7; i++){ if(*(flag+i) == ERR){ log_manager.writeLog("InputManager::startUp(): curse input start fails. "); delete[] flag; return -1; } } Manager::startUp(); delete[] flag; return 0; }
void curses_init() { null = g_fopen("/dev/null", "w"); unsetenv("COLUMNS"); unsetenv("LINES"); initscr(); noecho(); nonl(); cbreak(); keypad(stdscr, TRUE); meta(stdscr, TRUE); intrflush(stdscr, FALSE); leaveok(stdscr, TRUE); if (has_colors()) { start_color(); use_default_colors(); init_pair(COLORPAIR, conf.fg, conf.bg); } else conf.color = FALSE; curs_set(false); ws = newwin(1, COLS, EL, 0); view.current = 0; view.top_x = 0; view.top_y = 0; prompt.buf = g_string_new(""); prompt.on = false; prompt.regex = NULL; grid = g_array_sized_new(FALSE, TRUE, sizeof(grid_line_t*), SL); for (glong i = 0; i < SL; i++) { grid_line_t* grid_line = g_malloc(sizeof(grid_line_t)); g_array_append_val(grid, grid_line); } regrid(); }
restartterm(NCURSES_CONST char *termp, int filenum, int *errret) { int saveecho = SP->_echo; int savecbreak = SP->_cbreak; int saveraw = SP->_raw; int savenl = SP->_nl; int result; T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret)); if (setupterm(termp, filenum, errret) != OK) { result = ERR; } else { if (saveecho) echo(); else noecho(); if (savecbreak) { cbreak(); noraw(); } else if (saveraw) { nocbreak(); raw(); } else { nocbreak(); noraw(); } if (savenl) nl(); else nonl(); reset_prog_mode(); #if USE_SIZECHANGE _nc_update_screensize(); #endif result = OK; } returnCode(result); }
void initializeDisplay() { // initscr(); mainwin = initscr(); //newwin(50, 50, 1, 1); box(mainwin, 0, 0); if (mainwin == nullptr) { getLog() << "This would seem to be a problem" << std::endl; getLog() << "Error initialising ncurses.\n" << std::endl; exit(EXIT_FAILURE); } nonl(); cbreak(); curs_set(0); // memory leak /*return*/ new std::thread{waitToDie}; }
int main() // Starts and stops curses display mode { /* Set up the console behavior: */ (void) initscr(); // Initialize the curses system keypad(stdscr, TRUE); // Enable keyboard mapping (void) nonl(); // Disable line-end translation (void) cbreak(); // Take single input characters /* Run the circle routine: */ circle(); printw( "Press any key to exit." ); refresh(); // Put the output on the screen /* Finish: */ getch(); // Wait for user to press a key endwin(); // Shut down curses console return 0; }
/******************************************************************************\ Start curses up with some useful settings, also set up all possible colors \******************************************************************************/ void startCurses() { initscr(); // initialize curses cbreak(); // don't wait for enter between input noecho(); // don't echo characters typed to the window nonl(); // makes return key readable // initialize colors if possible if ( has_colors() ) { // start colors mode start_color(); // set all possible color pairs for ( int i = 0; i < NUM_COLORS; i++ ) // background for ( int j = 0; j < NUM_COLORS; j++ ) // foreground init_pair( j+(i*NUM_COLORS), j, i ); } }
/* * Initialize screen display. */ void cursinit() { initscr(); if ((LINES < SCRNH) || (COLS < SCRNW)) { endwin(); errx(1,"Screen too small (need %dx%d)",SCRNW,SCRNH); } #ifdef KEY_MIN keypad(stdscr, TRUE); #endif /* KEY_MIN */ nonl(); noecho(); cbreak(); #ifdef NCURSES_MOUSE_VERSION mousemask(BUTTON1_CLICKED, (mmask_t *)NULL); #endif /* NCURSES_MOUSE_VERSION*/ }
int init_ncurses() { int num = 0; /* initialize your non-curses data structures here */ signal(SIGINT, finish_ncurses); /* arrange interrupts to terminate */ initscr(); /* initialize the curses library */ keypad(stdscr, TRUE); /* enable keyboard mapping */ nonl(); /* tell curses not to do NL->CR/NL on output */ cbreak(); /* take input chars one at a time, no wait for \n */ noecho(); /* echo input - in color */ if (has_colors()) { start_color(); } }
void ulDialogueBox::start() { preloadAssets(script); signal(SIGWINCH, ulDialogueBox::resize); setlocale(LC_ALL, ""); initscr(); start_color(); init_pair(1, COLOR_RED, COLOR_BLACK); cbreak(); nonl(); noecho(); keypad(stdscr, TRUE); curs_set(0); wDialogue.setBoxExtent(1, 3, 1, 3); processBranch(script); }
/* Initialize drawing with some useful defaults and hook termination to * clean up the terminal. */ void con_init() { initscr(); keypad(stdscr, TRUE); nonl(); intrflush(stdscr, FALSE); noecho(); cbreak(); if (has_colors()) { start_color(); init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK); init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK); init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK); init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK); init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); } }
void StartCurses(void) { struct termios tios; USE_CURSES = TRUE; initscr (); nonl (); if (LINES < 24 || COLS < 80) { fprintf( stderr, "Display must be at least 24 lines by 80 columns to run this tool.\n" ); EndCurses (-20); } if (tcgetattr(0, &tios) < 0) { EndCurses (-1); /* die horribly */ } tios.c_cc[VMIN] = 1; tios.c_cc[VTIME] = 0; tios.c_lflag &= ~(ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHONL); if (tcsetattr(0, TCSAFLUSH, &tios) < 0) { EndCurses (-2); /* die horribly */ } noecho (); cbreak (); keypad (stdscr, TRUE); start_color (); if (tigetstr("smul")) HasAttr |= A_UNDERLINE; if (tigetstr ("rev")) HasAttr |= A_REVERSE; if (tigetstr ("bold")) HasAttr |= A_BOLD; KEY_LINE = (LINES >= 24) ? LINES - 1 : 23; }
void tui_setup(void) { int i; for (i = 0; i < 10; i++) winstack[i] = NULL; /* From the ncurses manpage... */ initscr (); start_color (); cbreak(); noecho(); nonl (); intrflush (stdscr, FALSE); keypad (stdscr, TRUE); currwin = stdscr; if (has_colors ()) { init_pair (1, COLOR_WHITE, COLOR_BLUE); init_pair (2, COLOR_BLACK, COLOR_WHITE); wattron (currwin, COLOR_PAIR (1) | A_BOLD); wbkgd (currwin, ' ' | COLOR_PAIR (1)); } winstack[0] = stdscr; winnr = 1; }
int main(int argc, char **argv) { initscr(); keypad(stdscr, TRUE); nonl(); cbreak(); //noecho(); move(LINES/2+1, COLS-4); addstr("eye"); refresh(); sleep(2); move(LINES/2-3,COLS/2-3); addstr("bulls"); refresh(); sleep(5); finish(0); return 0; }
// Some of this ncurses code is, unfortunately, copied from // the man page without full understanding. void configureNcurses() { initscr(); cbreak(); noecho(); nonl(); intrflush(stdscr, FALSE); keypad(stdscr, TRUE); nodelay(stdscr, TRUE); curs_set(0); start_color(); init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_YELLOW, COLOR_BLACK); init_pair(4, COLOR_BLUE, COLOR_BLACK); init_pair(5, COLOR_MAGENTA, COLOR_BLACK); init_pair(6, COLOR_CYAN, COLOR_BLACK); init_pair(7, COLOR_WHITE, COLOR_BLACK); }
int josua_clear_box_and_commands(gui_t *box) { int pos; int y,x; char buf[250]; curseson(); cbreak(); noecho(); nonl(); keypad(stdscr,TRUE); getmaxyx(stdscr,y,x); attrset(A_NORMAL); attrset(COLOR_PAIR(1)); { char *commands[] = { NULL }; josua_print_command(commands, y-5, 0); } if (box->x1==-999) {} else x = box->x1; if (box->y1<0) y = y + box->y1; else y = box->y1; attrset(COLOR_PAIR(0)); for (pos=box->y0;pos<y;pos++) { snprintf(buf, 199, "%199.199s", " "); mvaddnstr(pos, box->x0, buf, x-box->x0-1); } return 0; }
/* The initialization function for this module. Calculates the various * screen coordinates and initializes curses, and parses the cmdline * option -o. */ int outputinit(char *opts[]) { struct sigaction act; int y, x; ego = opts['o'] != NULL; noacs = opts['l'] != NULL; xwords = 0; ywords = height * 2 + 1; xstatus = width * 4 + 4; ystatus = 0; if (!(mode & MM_CURSES)) return TRUE; if (!initscr()) exit(EXIT_FAILURE); nonl(); noecho(); cbreak(); getmaxyx(stdscr, y, x); if (xstatus + 1 >= x || ywords + 1 >= y) { endwin(); fputs("Screen too small\n", stderr); exit(EXIT_FAILURE); } setscrreg(ywords, y - 1); highlightattr = termattrs() & A_BOLD ? A_BOLD : A_STANDOUT; atexit(destroy); #ifdef SIGWINCH act.sa_handler = onresize; sigemptyset(&act.sa_mask); act.sa_flags = 0; sigaction(SIGWINCH, &act, NULL); #endif /* SIGWINCH */ return TRUE; }
/* Initialize curses windows */ void init_curses() { initscr(); /* Handle all keys except interrupting keys */ cbreak(); /* Do not echo the typed keys */ noecho(); /* Do not use curses NL -> CR/LF or CR -> NL translation. Use linefeed cap if possible */ nonl(); /* Handle keypad if it is supported */ #if defined(SYSV) && defined(KEYPRESS) /* PAK */ keypad(stdscr, TRUE); #endif }
main() { srand(getpid()); /* initialize random sequence */ if (!initscr()) { fprintf(stderr, "Could not initialize libcurses.\n"); exit(1); } signal(SIGINT, die); noecho(); nonl(); leaveok(stdscr, TRUE); scrollok(stdscr, FALSE); for (;;) { makeboard(); /* make the board setup */ puton('*'); /* put on '*'s */ puton(' '); /* cover up with ' 's */ } }
void CRT_init(int delay, int colorScheme) { initscr(); noecho(); CRT_delay = delay; CRT_colorScheme = colorScheme; halfdelay(CRT_delay/2); nonl(); intrflush(stdscr, false); keypad(stdscr, true); curs_set(0); if (has_colors()) { start_color(); CRT_hasColors = true; } else { CRT_hasColors = false; } CRT_termType = getenv("TERM"); if (String_eq(CRT_termType, "xterm") || String_eq(CRT_termType, "xterm-color") || String_eq(CRT_termType, "vt220")) { define_key("\033[H", KEY_HOME); define_key("\033[F", KEY_END); define_key("\033OP", KEY_F(1)); define_key("\033OQ", KEY_F(2)); define_key("\033OR", KEY_F(3)); define_key("\033OS", KEY_F(4)); define_key("\033[11~", KEY_F(1)); define_key("\033[12~", KEY_F(2)); define_key("\033[13~", KEY_F(3)); define_key("\033[14~", KEY_F(4)); define_key("\033[17;2~", KEY_F(18)); } #ifndef DEBUG signal(11, CRT_handleSIGSEGV); #endif signal(SIGTERM, CRT_handleSIGTERM); use_default_colors(); if (!has_colors()) CRT_colorScheme = 1; CRT_setColors(CRT_colorScheme); mousemask(BUTTON1_CLICKED, NULL); }
int main() { int x,y,s,c; srand (time(NULL)); keypad(initscr(),1); raw (); nodelay(stdscr,0); noecho(); curs_set(0); nonl(); start_color(); for (c=0; c<=8; c++) { init_pair(c,c,COLOR_BLACK); } mvprintw(0,0,"Eric's ASCII Arcade Demo 3\nSkee-Ball\n\nUse the spacebar to stop the direction and power timers to get the ball into the middle hole."); getch();clear(); for(y=0;y<24;y++) { for(x=0;x<15;x++) { mvaddch(y,x+2,board[y][x]); } } for(y=0;y<9;y++) { mvprintw(19,18,"-----"); for(x=1;x<24;x++) {mvaddch(x,20,'|');} s=roll(); mvprintw(13+y,15,"%d",s); score+=s; mvprintw(3,23,"Score:%d",score); getch(); } clear(); mvprintw(5,0,"Out of balls.\nYou scored:%d points",score); getch(); exit(endwin()); }