int main(int argc, char *argv[]) { tty_mode(0); // save tty mode set_cr_noecho_mode(); int response = get_response(QUESTION); tty_mode(1); // reload tty mode return response; }
int main(int argc, char *argv[]) { tty_mode(0); set_cr_noecho_mode(); initscr(); clear(); signal(SIGINT, sigint_handler); signal(SIGIO, on_input); /* install input handler */ setup_aio_buffer(); /* initialize aio ctrl buff */ aio_read(&kbcbuf); /* place a read request */ signal(SIGALRM, on_alarm); /* install alarm handler */ set_ticker(delay); /* start ticking */ move(row, col); addstr(MSG); while (!done) { pause(); } tty_mode(1); endwin(); return 0; }
int main(void) { tty_mode(0); // save tty mode set_timeout_mode(); set_cr_noecho_mode(); int response = get_response(QUESTION); tty_mode(1); // reload tty mode return response; }
int main(void) { int response; tty_mode(0); set_cr_noecho_mode(); set_nodelay_mode(); response = get_response(ASK, TRIES); tty_mode(1); return response; }
main() { int response; tty_mode(0); set_cr_noecho_mode(); /* set -icanon, -echo */ set_nodelay_mode(); /* noinput => EOF */ response = get_response(ASK, 3); /* get some answer */ tty_mode(1); /* restore tty state */ return response; }
int main(void) { tty_mode(0); // save tty mode signal(SIGINT, signal_handler); signal(SIGQUIT, signal_handler); signal(SIGTERM, signal_handler); set_cr_noecho_mode(); int c; int line_len = 0; struct termios term; tcgetattr(0, &term); char erase_c = term.c_cc[VERASE]; char line_erase_c = term.c_cc[VKILL]; while ((c = getchar()) != EOF) { if (c == ' ') { putchar(' '); line_len++; } if (c == '\n') { puts("\r"); line_len = 0; } if (c == erase_c) { fputs("\b \b", stdout); line_len--; } if (c == line_erase_c) { while (line_len != 0) { fputs("\b \b", stdout); line_len--; } } if (c == 'Q') { tty_mode(1); exit(EXIT_SUCCESS); } if (islower(c)) { if (c == 'z') c = 'a'; else c++; putchar(c); line_len++; } } tty_mode(1); return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { int response; tty_mode(0); set_cr_noecho_mode(); set_nodelay_mode(); signal(SIGINT, ctrl_c_handler); signal(SIGQUIT, SIG_IGN); response = get_response(ASK, TRIES); tty_mode(1); return response; }
main() { int response; void ctrl_c_handler(int); tty_mode(0); set_cr_noecho_mode(); set_nodelay_mode(); signal(SIGINT, ctrl_c_handler); response = get_response(ASK, TRIES); tty_mode(1); return response; }
int main() { int response; tty_mode(0); set_cr_noecho_mode(); set_nodelay_mode(); signal( SIGINT, ctrl_c_handler ); signal( SIGQUIT, SIG_IGN ); response = get_response( QUESTION, TRIES ); tty_mode(1); return response; }
int main(int argc, char *argv[]) { int res; tty_mode(0); /* save tty mode */ set_cr_noecho_mode(); /* set -icanon, -echo */ set_nodelay_mode(); /* no input == EOF */ res = get_response(QUESTION, TRIES); tty_mode(1); /* restore tty mode */ return res; }
main() { int response; void ctrl_c_handler(int); tty_mode(0); /* save current mode */ set_cr_noecho_mode(); /* set -icanon, -echo */ set_nodelay_mode(); /* noinput => EOF */ signal( SIGINT, ctrl_c_handler ); /* handle INT */ signal( SIGQUIT, SIG_IGN ); /* ignore QUIT signals */ response = get_response(ASK, TRIES); /* get some answer */ tty_mode(1); /* reset orig mode */ return response; }
int main() { int c; tty_mode(0); /* store it */ set_cr_noecho_mode(); /* set -icanon, -echo */ while ( ( c=getchar() ) != EOF && c != 'Q' ){ if ( c == 'z' ) c = 'a'; else if (islower(c)) c++; putchar(c); } tty_mode(1); /* restore it */ return 0; }
int main(int argc, char **argv) { FILE *fp; tty_mode(0); rowCol(); if (argc == 1){ do_more(stdin); }else{ set_cr_noecho_mode(); while(--argc){ if ((fp = fopen(*++argv,"r")) != NULL){ do_more(fp); fclose(fp); }else{ exit(1); }//if }//while } tty_mode(1); return 0; }