?? rltty.c
字號:
char *msg;{ fprintf (stderr, "readline: warning: %s\n", msg);}#endif#if defined (_AIX)voidsetopost(tp)TIOTYPE *tp;{ if ((tp->c_oflag & OPOST) == 0) { rltty_warning ("turning on OPOST for terminal\r"); tp->c_oflag |= OPOST|ONLCR; }}#endifstatic int_get_tty_settings (tty, tiop) int tty; TIOTYPE *tiop;{ int ioctl_ret; while (1) { ioctl_ret = GETATTR (tty, tiop); if (ioctl_ret < 0) { if (errno != EINTR) return -1; else continue; } if (OUTPUT_BEING_FLUSHED (tiop)) {#if defined (FLUSHO) && defined (_AIX41) rltty_warning ("turning off output flushing"); tiop->c_lflag &= ~FLUSHO; break;#else continue;#endif } break; } return 0;}static intget_tty_settings (tty, tiop) int tty; TIOTYPE *tiop;{ set_winsize (tty); if (_get_tty_settings (tty, tiop) < 0) return -1;#if defined (_AIX) setopost(tiop);#endif return 0;}static int_set_tty_settings (tty, tiop) int tty; TIOTYPE *tiop;{ while (SETATTR (tty, tiop) < 0) { if (errno != EINTR) return -1; errno = 0; } return 0;}static intset_tty_settings (tty, tiop) int tty; TIOTYPE *tiop;{ if (_set_tty_settings (tty, tiop) < 0) return -1; #if 0#if defined (TERMIOS_TTY_DRIVER)# if defined (__ksr1__) if (ksrflow) { ksrflow = 0; tcflow (tty, TCOON); }# else /* !ksr1 */ tcflow (tty, TCOON); /* Simulate a ^Q. */# endif /* !ksr1 */#else ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */#endif /* !TERMIOS_TTY_DRIVER */#endif /* 0 */ return 0;}static voidprepare_terminal_settings (meta_flag, oldtio, tiop) int meta_flag; TIOTYPE oldtio, *tiop;{ readline_echoing_p = (oldtio.c_lflag & ECHO); tiop->c_lflag &= ~(ICANON | ECHO); if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE) _rl_eof_char = oldtio.c_cc[VEOF];#if defined (USE_XON_XOFF)#if defined (IXANY) tiop->c_iflag &= ~(IXON | IXOFF | IXANY);#else /* `strict' Posix systems do not define IXANY. */ tiop->c_iflag &= ~(IXON | IXOFF);#endif /* IXANY */#endif /* USE_XON_XOFF */ /* Only turn this off if we are using all 8 bits. */ if (((tiop->c_cflag & CSIZE) == CS8) || meta_flag) tiop->c_iflag &= ~(ISTRIP | INPCK); /* Make sure we differentiate between CR and NL on input. */ tiop->c_iflag &= ~(ICRNL | INLCR);#if !defined (HANDLE_SIGNALS) tiop->c_lflag &= ~ISIG;#else tiop->c_lflag |= ISIG;#endif tiop->c_cc[VMIN] = 1; tiop->c_cc[VTIME] = 0;#if defined (FLUSHO) if (OUTPUT_BEING_FLUSHED (tiop)) { tiop->c_lflag &= ~FLUSHO; oldtio.c_lflag &= ~FLUSHO; }#endif /* Turn off characters that we need on Posix systems with job control, just to be sure. This includes ^Y and ^V. This should not really be necessary. */#if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)#if defined (VLNEXT) tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;#endif#if defined (VDSUSP) tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;#endif#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */}#endif /* NEW_TTY_DRIVER *//* Put the terminal in CBREAK mode so that we can detect key presses. */voidrl_prep_terminal (meta_flag) int meta_flag;{ int tty; TIOTYPE tio; if (terminal_prepped) return; /* Try to keep this function from being INTerrupted. */ block_sigint (); tty = fileno (rl_instream); if (get_tty_settings (tty, &tio) < 0) { release_sigint (); return; } otio = tio; save_tty_chars (&otio); prepare_terminal_settings (meta_flag, otio, &tio); if (set_tty_settings (tty, &tio) < 0) { release_sigint (); return; } if (_rl_enable_keypad) _rl_control_keypad (1); fflush (rl_outstream); terminal_prepped = 1; RL_SETSTATE(RL_STATE_TERMPREPPED); release_sigint ();}/* Restore the terminal's normal settings and modes. */voidrl_deprep_terminal (){ int tty; if (!terminal_prepped) return; /* Try to keep this function from being interrupted. */ block_sigint (); tty = fileno (rl_instream); if (_rl_enable_keypad) _rl_control_keypad (0); fflush (rl_outstream); if (set_tty_settings (tty, &otio) < 0) { release_sigint (); return; } terminal_prepped = 0; RL_UNSETSTATE(RL_STATE_TERMPREPPED); release_sigint ();}/* **************************************************************** *//* *//* Bogus Flow Control *//* *//* **************************************************************** */intrl_restart_output (count, key) int count, key;{ int fildes = fileno (rl_outstream);#if defined (TIOCSTART)#if defined (apollo) ioctl (&fildes, TIOCSTART, 0);#else ioctl (fildes, TIOCSTART, 0);#endif /* apollo */#else /* !TIOCSTART */# if defined (TERMIOS_TTY_DRIVER)# if defined (__ksr1__) if (ksrflow) { ksrflow = 0; tcflow (fildes, TCOON); }# else /* !ksr1 */ tcflow (fildes, TCOON); /* Simulate a ^Q. */# endif /* !ksr1 */# else /* !TERMIOS_TTY_DRIVER */# if defined (TCXONC) ioctl (fildes, TCXONC, TCOON);# endif /* TCXONC */# endif /* !TERMIOS_TTY_DRIVER */#endif /* !TIOCSTART */ return 0;}intrl_stop_output (count, key) int count, key;{ int fildes = fileno (rl_instream);#if defined (TIOCSTOP)# if defined (apollo) ioctl (&fildes, TIOCSTOP, 0);# else ioctl (fildes, TIOCSTOP, 0);# endif /* apollo */#else /* !TIOCSTOP */# if defined (TERMIOS_TTY_DRIVER)# if defined (__ksr1__) ksrflow = 1;# endif /* ksr1 */ tcflow (fildes, TCOOFF);# else# if defined (TCXONC) ioctl (fildes, TCXONC, TCOON);# endif /* TCXONC */# endif /* !TERMIOS_TTY_DRIVER */#endif /* !TIOCSTOP */ return 0;}/* **************************************************************** *//* *//* Default Key Bindings *//* *//* **************************************************************** *//* Set the system's default editing characters to their readline equivalents in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */voidrltty_set_default_bindings (kmap) Keymap kmap;{ TIOTYPE ttybuff; int tty = fileno (rl_instream);#if defined (NEW_TTY_DRIVER)#define SET_SPECIAL(sc, func) \ do \ { \ int ic; \ ic = sc; \ if (ic != -1 && kmap[(unsigned char)ic].type == ISFUNC) \ kmap[(unsigned char)ic].function = func; \ } \ while (0) if (get_tty_settings (tty, &ttybuff) == 0) { if (ttybuff.flags & SGTTY_SET) { SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout); SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard); }# if defined (TIOCGLTC) if (ttybuff.flags & LTCHARS_SET) { SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout); SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert); }# endif /* TIOCGLTC */ }#else /* !NEW_TTY_DRIVER */#define SET_SPECIAL(sc, func) \ do \ { \ unsigned char uc; \ uc = ttybuff.c_cc[sc]; \ if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \ kmap[uc].function = func; \ } \ while (0) if (get_tty_settings (tty, &ttybuff) == 0) { SET_SPECIAL (VERASE, rl_rubout); SET_SPECIAL (VKILL, rl_unix_line_discard);# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER) SET_SPECIAL (VLNEXT, rl_quoted_insert);# endif /* VLNEXT && TERMIOS_TTY_DRIVER */# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER) SET_SPECIAL (VWERASE, rl_unix_word_rubout);# endif /* VWERASE && TERMIOS_TTY_DRIVER */ }#endif /* !NEW_TTY_DRIVER */}/* New public way to set the system default editing chars to their readline equivalents. */voidrl_tty_set_default_bindings (kmap) Keymap kmap;{ rltty_set_default_bindings (kmap);}#if defined (HANDLE_SIGNALS)#if defined (NEW_TTY_DRIVER)int_rl_disable_tty_signals (){ return 0;}int_rl_restore_tty_signals (){ return 0;}#elsestatic TIOTYPE sigstty, nosigstty;static int tty_sigs_disabled = 0;int_rl_disable_tty_signals (){ if (tty_sigs_disabled) return 0; if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0) return -1; nosigstty = sigstty; nosigstty.c_lflag &= ~ISIG; nosigstty.c_iflag &= ~IXON; if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0) return (_set_tty_settings (fileno (rl_instream), &sigstty)); tty_sigs_disabled = 1; return 0;}int_rl_restore_tty_signals (){ int r; if (tty_sigs_disabled == 0) return 0; r = _set_tty_settings (fileno (rl_instream), &sigstty); if (r == 0) tty_sigs_disabled = 0; return r;}#endif /* !NEW_TTY_DRIVER */#endif /* HANDLE_SIGNALS */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -