TheGNUGeneralPublicLicenseisoftenshippedwithGNUsoftware,and isgenerallykeptinafilecalledCOPYINGorLICENSE.Ifyoudonot haveacopyofthelicense,writetotheFreeSoftwareFoundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #define READLINE_LIBRARY
#ifdefined (HAVE_CONFIG_H) # include "config_readline.h" #endif
/* If non-zero, means that this process has called tcflow(fd, TCOOFF)
and output is suspended. */ #ifdefined (__ksr1__) staticint ksrflow; #endif
/* Dummy call to force a backgrounded readline to stop before it tries
to get the tty settings. */ staticvoid
set_winsize (int tty __attribute__((unused)))
{ #ifdefined (TIOCGWINSZ) struct winsize w;
/* Values for the `flags' field of a struct bsdtty. This tells which elementsofthestructbsdttyhavebeenfetchedfromthesystemand
are valid. */ #define SGTTY_SET 0x01 #define LFLAG_SET 0x02 #define TCHARS_SET 0x04 #define LTCHARS_SET 0x08
struct bsdtty { struct sgttyb sgttyb; /* Basic BSD tty driver information. */ int lflag; /* Local mode flags, like LPASS8. */ #ifdefined (TIOCGETC) struct tchars tchars; /* Terminal special characters, including ^S and ^Q. */ #endif #ifdefined (TIOCGLTC) struct ltchars ltchars; /* 4.2 BSD editing characters */ #endif int flags; /* Bitmap saying which parts of the struct are valid. */
};
/* Copy the original settings to the structure we're going to use for
our settings. */
tiop->sgttyb = oldtio.sgttyb;
tiop->lflag = oldtio.lflag; #ifdefined (TIOCGETC)
tiop->tchars = oldtio.tchars; #endif #ifdefined (TIOCGLTC)
tiop->ltchars = oldtio.ltchars; #endif
tiop->flags = oldtio.flags;
/* First, the basic settings to put us into character-at-a-time, no-echo
input mode. */
tiop->sgttyb.sg_flags &= ~(ECHO | CRMOD);
tiop->sgttyb.sg_flags |= CBREAK;
/* If this terminal doesn't care how the 8th bit is used, then we can useitforthemeta-key.Ifonlyoneofevenoroddparityis
specified, then the terminal is using parity, and we cannot. */ #if !defined (ANYP) # define ANYP (EVENP | ODDP) #endif if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
((oldtio.sgttyb.sg_flags & ANYP) == 0))
{
tiop->sgttyb.sg_flags |= ANYP;
/* Hack on local mode flags if we can. */ #ifdefined (TIOCLGET) # ifdefined (LPASS8)
tiop->lflag |= LPASS8; # endif /* LPASS8 */ #endif/* TIOCLGET */
}
#ifdefined (TIOCGETC) # ifdefined (USE_XON_XOFF) /* Get rid of terminal output start and stop characters. */
tiop->tchars.t_stopc = -1; /* C-s */
tiop->tchars.t_startc = -1; /* C-q */
/* If there is an XON character, bind it to restart the output. */ if (oldtio.tchars.t_startc != -1)
rl_bind_key (oldtio.tchars.t_startc, rl_restart_output); # endif /* USE_XON_XOFF */
/* If there is an EOF char, bind _rl_eof_char to it. */ if (oldtio.tchars.t_eofc != -1)
_rl_eof_char = oldtio.tchars.t_eofc;
#ifdefined (TIOCGLTC) /* Make the interrupt keys go away. Just enough to make people happy. */
tiop->ltchars.t_dsuspc = -1; /* C-y */
tiop->ltchars.t_lnextc = -1; /* C-v */ #endif/* TIOCGLTC */
}
#ifdefined (_AIX) || defined (_AIX41) /* Currently this is only used on AIX */ staticvoid
rltty_warning (msg) char *msg;
{
fprintf (stderr, "readline: warning: %s\n", msg);
} #endif
#ifdefined (_AIX) void
setopost(tp)
TIOTYPE *tp;
{ if ((tp->c_oflag & OPOST) == 0)
{
rltty_warning ("turning on OPOST for terminal\r");
tp->c_oflag |= OPOST|ONLCR;
}
} #endif
staticint
_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))
{ #ifdefined (FLUSHO) && defined (_AIX41)
rltty_warning ("turning off output flushing");
tiop->c_lflag &= ~FLUSHO; break; #else continue; #endif
} break;
}
/* Turn off characters that we need on Posix systems with job control, justtobesure.Thisincludes^Yand^V.Thisshouldnotreally
be necessary. */ #ifdefined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)
/* Put the terminal in CBREAK mode so that we can detect key presses. */ #ifdefined (NO_TTY_DRIVER) void
rl_prep_terminal (meta_flag) int meta_flag;
{
readline_echoing_p = 1;
}
void
rl_deprep_terminal ()
{
}
#else/* ! NO_TTY_DRIVER */ void
rl_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)
{ #ifdefined (ENOTSUP) /* MacOS X, at least, lies about the value of errno if tcgetattr fails. */ if (errno == ENOTTY || errno == ENOTSUP) #else if (errno == ENOTTY) #endif
readline_echoing_p = 1; /* XXX */
release_sigint (); return;
}
otio = tio;
if (_rl_bind_stty_chars)
{ #ifdefined (VI_MODE) /* If editing in vi mode, make sure we restore the bindings in the
insertion keymap no matter what keymap we ended up in. */ if (rl_editing_mode == vi_mode)
rl_tty_unset_default_bindings (vi_insertion_keymap); else #endif
rl_tty_unset_default_bindings (_rl_keymap);
}
save_tty_chars (&otio);
RL_SETSTATE(RL_STATE_TTYCSAVED); if (_rl_bind_stty_chars)
{ #ifdefined (VI_MODE) /* If editing in vi mode, make sure we set the bindings in the
insertion keymap no matter what keymap we ended up in. */ if (rl_editing_mode == vi_mode)
_rl_bind_tty_special_chars (vi_insertion_keymap, tio); else #endif
_rl_bind_tty_special_chars (_rl_keymap, tio);
}
/* 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. */ void
rltty_set_default_bindings (kmap)
Keymap kmap;
{ #if !defined (NO_TTY_DRIVER)
TIOTYPE ttybuff; int tty;
/* New public way to set the system default editing chars to their readline
equivalents. */ void
rl_tty_set_default_bindings (kmap)
Keymap kmap;
{
rltty_set_default_bindings (kmap);
}
/* Rebind all of the tty special chars that readline worries about back toself-insert.Callthisbeforesavingthecurrentterminalspecial charswithsave_tty_chars().ThisonlyworksonPOSIXtermiosortermio
systems. */ void
rl_tty_unset_default_bindings (kmap)
Keymap kmap;
{ /* Don't bother before we've saved the tty special chars at least once. */ if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0) return;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.