/* If this is an echo of a character which is being hard-erased, set hderase. If this is a newline or tab which should not receive their normal special processing, set quoted. */ static void echo_char (char c, int hderase, int quoted) { echo_qsize++; if (echo_p (c, quoted)) { if (!hderase && (termflags & INSIDE_HDERASE)) { write_character ('/'); termflags &= ~INSIDE_HDERASE; } if (hderase && !(termflags & INSIDE_HDERASE)) { output_character ('\\'); termflags |= INSIDE_HDERASE; } /* Control characters that should use caret-letter */ if (echo_double (c, quoted)) { output_character ('^'); output_character (c ^ CTRL_BIT); } else output_character (c); } }
/* Erase a single character off the end of the rawq, and delete it from the screen appropriately. Set ERASE_CHAR if this is being done by the VERASE character, to that character. */ static void erase_1 (char erase_char) { int quoted; char c; quoted_char cq; if (qsize (rawq) == 0) return; cq = queue_erase (rawq); c = unquote_char (cq); quoted = char_quoted_p (cq); if (!echo_p (c, quoted)) return; /* The code for WERASE knows that we echo erase_char iff !ECHOPRT && !ECHO. */ if (echo_qsize--) { if (termstate.c_lflag & ECHOPRT) echo_char (c, 1, quoted); else if (!(termstate.c_lflag & ECHOE) && erase_char) echo_char (erase_char, 0, 0); else { int nerase; if (echo_double (c, quoted)) nerase = 2; else if (c == '\t') { quoted_char *cp; int loc = echo_pstart; for (cp = rawq->ce - echo_qsize; cp != rawq->ce; cp++) loc += (echo_double (unquote_char (*cp), char_quoted_p (*cp)) ? 2 : output_width (*cp, loc)); nerase = output_psize - loc; } else nerase = output_width (c, output_psize); while (nerase--) write_erase_sequence (); } if (echo_qsize == 0) assert (echo_pstart == output_psize); } else reprint_line (); }
/* * call-seq: * io.echo? -> true or false * * Returns +true+ if echo back is enabled. * * You must require 'io/console' to use this method. */ static VALUE console_echo_p(VALUE io) { conmode t; rb_io_t *fptr; int fd; GetOpenFile(io, fptr); fd = GetReadFD(fptr); if (!getattr(fd, &t)) rb_sys_fail(0); return echo_p(&t) ? Qtrue : Qfalse; }