int nonl(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "nonl()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); if (_cursesi_screen->notty == TRUE) return OK; _cursesi_screen->rawt.c_iflag &= ~ICRNL; _cursesi_screen->rawt.c_oflag &= ~ONLCR; _cursesi_screen->cbreakt.c_iflag &= ~ICRNL; _cursesi_screen->cbreakt.c_oflag &= ~ONLCR; _cursesi_screen->baset.c_iflag &= ~ICRNL; _cursesi_screen->baset.c_oflag &= ~ONLCR; _cursesi_screen->nl = 0; __pfast = 1; return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? TCSASOFT | TCSADRAIN : TCSADRAIN, _cursesi_screen->curt) ? ERR : OK); }
int __nodelay(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "__nodelay()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); if (_cursesi_screen->notty == TRUE) return OK; _cursesi_screen->rawt.c_cc[VMIN] = 0; _cursesi_screen->rawt.c_cc[VTIME] = 0; _cursesi_screen->cbreakt.c_cc[VMIN] = 0; _cursesi_screen->cbreakt.c_cc[VTIME] = 0; _cursesi_screen->baset.c_cc[VMIN] = 0; _cursesi_screen->baset.c_cc[VTIME] = 0; if (tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSANOW, _cursesi_screen->curt)) { __restore_termios(); return ERR; } return OK; }
int __timeout(int delay) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "__timeout()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); if (_cursesi_screen->notty == TRUE) return OK; _cursesi_screen->ovmin = _cursesi_screen->cbreakt.c_cc[VMIN]; _cursesi_screen->ovtime = _cursesi_screen->cbreakt.c_cc[VTIME]; _cursesi_screen->rawt.c_cc[VMIN] = 0; _cursesi_screen->rawt.c_cc[VTIME] = delay; _cursesi_screen->cbreakt.c_cc[VMIN] = 0; _cursesi_screen->cbreakt.c_cc[VTIME] = delay; _cursesi_screen->baset.c_cc[VMIN] = 0; _cursesi_screen->baset.c_cc[VTIME] = delay; if (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? TCSASOFT | TCSANOW : TCSANOW, _cursesi_screen->curt)) { __restore_termios(); return ERR; } return OK; }
/* * nocbreak -- * Disable cbreak mode */ int nocbreak(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "nocbreak()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); __rawmode = 0; if (_cursesi_screen->notty == TRUE) return OK; /* if we were in halfdelay mode then nuke the timeout */ if ((_cursesi_screen->half_delay == TRUE) && (__notimeout() == ERR)) return ERR; _cursesi_screen->half_delay = FALSE; _cursesi_screen->curt = _cursesi_screen->useraw ? &_cursesi_screen->rawt : &_cursesi_screen->baset; return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? TCSASOFT | TCSADRAIN : TCSADRAIN, _cursesi_screen->curt) ? ERR : OK); }
void __save_termios(void) { /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); if (_cursesi_screen->notty == TRUE) return; _cursesi_screen->ovmin = _cursesi_screen->cbreakt.c_cc[VMIN]; _cursesi_screen->ovtime = _cursesi_screen->cbreakt.c_cc[VTIME]; }
int noecho(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "noecho()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); __echoit = 0; return (OK); }
/* * noraw -- * Put the terminal into cooked mode */ int noraw(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "noraw()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); _cursesi_screen->useraw = __pfast = __rawmode = 0; if (_cursesi_screen->notty == TRUE) return OK; _cursesi_screen->curt = &_cursesi_screen->baset; return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, _cursesi_screen->curt) ? ERR : OK; }
/* * raw -- * Put the terminal into raw mode */ int raw(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "raw()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); _cursesi_screen->useraw = __pfast = __rawmode = 1; _cursesi_screen->curt = &_cursesi_screen->rawt; if (_cursesi_screen->notty == TRUE) return OK; return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? TCSASOFT | TCSADRAIN : TCSADRAIN, _cursesi_screen->curt) ? ERR : OK); }
/* * cbreak -- * Enable cbreak mode */ int cbreak(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "cbreak()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); __rawmode = 1; if (_cursesi_screen->notty == TRUE) return OK; _cursesi_screen->curt = _cursesi_screen->useraw ? &_cursesi_screen->rawt : &_cursesi_screen->cbreakt; return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, _cursesi_screen->curt) ? ERR : OK; }
int __notimeout(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "__notimeout()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); if (_cursesi_screen->notty == TRUE) return OK; _cursesi_screen->rawt.c_cc[VMIN] = 1; _cursesi_screen->rawt.c_cc[VTIME] = 0; _cursesi_screen->cbreakt.c_cc[VMIN] = 1; _cursesi_screen->cbreakt.c_cc[VTIME] = 0; _cursesi_screen->baset.c_cc[VMIN] = 1; _cursesi_screen->baset.c_cc[VTIME] = 0; return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? TCSASOFT | TCSANOW : TCSANOW, _cursesi_screen->curt) ? ERR : OK); }
int intrflush(WINDOW *win, bool bf) /*ARGSUSED*/ { /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); if (_cursesi_screen->notty == TRUE) return OK; if (bf) { _cursesi_screen->rawt.c_lflag &= ~NOFLSH; _cursesi_screen->cbreakt.c_lflag &= ~NOFLSH; _cursesi_screen->baset.c_lflag &= ~NOFLSH; } else { _cursesi_screen->rawt.c_lflag |= NOFLSH; _cursesi_screen->cbreakt.c_lflag |= NOFLSH; _cursesi_screen->baset.c_lflag |= NOFLSH; } __pfast = 1; return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, _cursesi_screen->curt) ? ERR : OK; }
/* * stop_signal_handler -- * Handle stop signals. */ void __stop_signal_handler(/*ARGSUSED*/int signo) { sigset_t oset, set; /* * Block window change and timer signals. The latter is because * applications use timers to decide when to repaint the screen. */ (void) sigemptyset(&set); (void) sigaddset(&set, SIGALRM); (void) sigaddset(&set, SIGWINCH); (void) sigprocmask(SIG_BLOCK, &set, &oset); /* * End the window, which also resets the terminal state to the * original modes. */ __stopwin(); /* Unblock SIGTSTP. */ (void) sigemptyset(&set); (void) sigaddset(&set, SIGTSTP); (void) sigprocmask(SIG_UNBLOCK, &set, NULL); /* Stop ourselves. */ (void) kill(0, SIGTSTP); /* Time passes ... */ /* restart things */ __restartwin(); /* Reset the signals. */ (void) sigprocmask(SIG_SETMASK, &oset, NULL); }
int nl(void) { #ifdef DEBUG __CTRACE(__CTRACE_MISC, "nl()\n"); #endif /* Check if we need to restart ... */ if (_cursesi_screen->endwin) __restartwin(); if (_cursesi_screen->notty == TRUE) return OK; _cursesi_screen->rawt.c_iflag |= ICRNL; _cursesi_screen->rawt.c_oflag |= ONLCR; _cursesi_screen->cbreakt.c_iflag |= ICRNL; _cursesi_screen->cbreakt.c_oflag |= ONLCR; _cursesi_screen->baset.c_iflag |= ICRNL; _cursesi_screen->baset.c_oflag |= ONLCR; _cursesi_screen->nl = 1; _cursesi_screen->pfast = _cursesi_screen->rawmode; return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, _cursesi_screen->curt) ? ERR : OK; }