MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / tty_setup

Function tty_setup

extern/editline/src/tty.c:494–562  ·  view source on GitHub ↗

tty_setup(): * Get the tty parameters and initialize the editing state */

Source from the content-addressed store, hash-verified

492 * Get the tty parameters and initialize the editing state
493 */
494private int
495tty_setup(EditLine *el)
496{
497 int rst = 1;
498
499 if (el->el_flags & EDIT_DISABLED)
500 return 0;
501
502 if (!isatty(el->el_outfd)) {
503#ifdef DEBUG_TTY
504 (void) fprintf(el->el_errfile, "%s: isatty: %s\n", __func__,
505 strerror(errno));
506#endif /* DEBUG_TTY */
507 return -1;
508 }
509 if (tty_getty(el, &el->el_tty.t_or) == -1) {
510#ifdef DEBUG_TTY
511 (void) fprintf(el->el_errfile, "%s: tty_getty: %s\n", __func__,
512 strerror(errno));
513#endif /* DEBUG_TTY */
514 return -1;
515 }
516 el->el_tty.t_ts = el->el_tty.t_ex = el->el_tty.t_ed = el->el_tty.t_or;
517
518 el->el_tty.t_speed = tty__getspeed(&el->el_tty.t_ex);
519 el->el_tty.t_tabs = tty__gettabs(&el->el_tty.t_ex);
520 el->el_tty.t_eight = tty__geteightbit(&el->el_tty.t_ex);
521
522 tty_setup_flags(el, &el->el_tty.t_ex, EX_IO);
523
524 /*
525 * Reset the tty chars to reasonable defaults
526 * If they are disabled, then enable them.
527 */
528 if (rst) {
529 if (tty__cooked_mode(&el->el_tty.t_ts)) {
530 tty__getchar(&el->el_tty.t_ts, el->el_tty.t_c[TS_IO]);
531 /*
532 * Don't affect CMIN and CTIME for the editor mode
533 */
534 for (rst = 0; rst < C_NCC - 2; rst++)
535 if (el->el_tty.t_c[TS_IO][rst] !=
536 el->el_tty.t_vdisable
537 && el->el_tty.t_c[ED_IO][rst] !=
538 el->el_tty.t_vdisable)
539 el->el_tty.t_c[ED_IO][rst] =
540 el->el_tty.t_c[TS_IO][rst];
541 for (rst = 0; rst < C_NCC; rst++)
542 if (el->el_tty.t_c[TS_IO][rst] !=
543 el->el_tty.t_vdisable)
544 el->el_tty.t_c[EX_IO][rst] =
545 el->el_tty.t_c[TS_IO][rst];
546 }
547 tty__setchar(&el->el_tty.t_ex, el->el_tty.t_c[EX_IO]);
548 if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) {
549#ifdef DEBUG_TTY
550 (void) fprintf(el->el_errfile, "%s: tty_setty: %s\n",
551 __func__, strerror(errno));

Callers 1

tty_initFunction · 0.85

Calls 7

tty_gettyFunction · 0.85
tty__getspeedFunction · 0.85
tty_setup_flagsFunction · 0.85
tty__getcharFunction · 0.85
tty__setcharFunction · 0.85
tty_settyFunction · 0.85
tty_bind_charFunction · 0.85

Tested by

no test coverage detected