/* * Restore tty modes, moves the cursor to the lower left hand * corner of the screen and resets the terminal into proper non-visual * mode. Calling doupdate()/wrefresh() will resume visual mode. */ int endwin(void) { if (!(__m_screen->_flags & S_ENDWIN)) { (void) __m_mvcur(-1, -1, lines-1, 0, __m_outc); if (exit_ca_mode != NULL) (void) TPUTS(exit_ca_mode, 1, __m_outc); if (keypad_local != NULL) (void) TPUTS(keypad_local, 1, __m_outc); if (orig_colors != NULL) (void) TPUTS(orig_colors, 1, __m_outc); /* Make sure the current attribute state is normal. */ if (ATTR_STATE != WA_NORMAL) { (void) vid_puts(WA_NORMAL, 0, (void *) 0, __m_outc); if (ceol_standout_glitch) curscr->_line[curscr->_maxx-1][0]._at |= WA_COOKIE; } (void) signal(SIGTSTP, SIG_DFL); __m_screen->_flags = S_ENDWIN; } (void) fflush(__m_screen->_of); (void) reset_shell_mode(); return (OK); }
static void tfini(void) { #ifdef TERMINFO TPUTS(reset_1string); resetterm(); #endif #ifdef __unix__ tcsetattr(0, TCSAFLUSH, &save_tty); #endif tflush(); }
int start_color(void) { COLORS = max_colors; COLOR_PAIRS = max_pairs; if (orig_colors != (char *) 0) (void) TPUTS(orig_colors, 1, __m_outc); if (orig_pair != (char *) 0) (void) TPUTS(orig_pair, 1, __m_outc); if (0 < max_colors) { cur_term->_color = calloc(max_colors, sizeof (*cur_term->_color)); if (cur_term->_color == (short (*)[3]) 0) goto error1; } if (0 < max_pairs) { cur_term->_pair = calloc(max_pairs, sizeof (*cur_term->_pair)); if (cur_term->_pair == (short (*)[2]) 0) goto error2; } (void) init_color(COLOR_BLACK, 0, 0, 0); (void) init_color(COLOR_RED, 1000, 0, 0); (void) init_color(COLOR_GREEN, 0, 1000, 0); (void) init_color(COLOR_BLUE, 0, 0, 1000); (void) init_color(COLOR_YELLOW, 1000, 1000, 0); (void) init_color(COLOR_MAGENTA, 1000, 0, 1000); (void) init_color(COLOR_CYAN, 0, 1000, 1000); (void) init_color(COLOR_WHITE, 1000, 1000, 1000); return (OK); error2: if (cur_term->_color != (short (*)[3]) 0) free(cur_term->_color); error1: return (ERR); }
/* ARGSUSED */ int meta(WINDOW *w, bool bf) { PTERMIOS(_prog)->c_cflag &= ~CSIZE; PTERMIOS(_prog)->c_cflag |= bf ? CS8 : CS7; if (__m_tty_set_prog_mode() == ERR) return (ERR); __m_screen->_flags &= ~S_USE_META; if (bf) { if (meta_on != NULL) (void) TPUTS(meta_on, 1, __m_outc); __m_screen->_flags |= S_USE_META; } else if (meta_off != NULL) { (void) TPUTS(meta_off, 1, __m_outc); } return (OK); }
static void tlinit(void) { static const char * const names[] = { "cm", "ce", "cl", "me", "so", "vb", "md" }; char *key, *was = area, *end = area, *term = getenv("TERM"); int i; if (term == NULL) { terror("ERROR: environment variable TERM not set.\n"); exit(1); } if (tgetent(bp, term) != 1) { terror("ERROR: Unable to get termcap entry.\n"); exit(1); } /* get the initialization string and send to stdout */ tgetstr("is", &end); if (end != was) TPUTS(was); /* get the termcap strings needed - must be done last */ for (i = 0; i < NUMCM; ++i) { cm[i] = end; tgetstr(names[i], &end); if (cm[i] == end) { if (i < MUST) { Dbg("Missing termcap entry for %s\n", names[i]); exit(1); } else cm[i] = ""; } } termcap_end = end; /* get the cursor and function key defines */ for (i = 0; i < 22; ++i) { key = termcap_end; tgetstr(key_names[i], &termcap_end); if (key != termcap_end) set_tkey(i, key); } }
static void tlinit(void) { int rc, i; char *Term = getenv("TERM"); if (Term == NULL) { printf("FATAL ERROR: environment variable TERM not set.\n"); exit(1); } setupterm(Term, 1, &rc); if (rc != 1) { printf("FATAL ERROR: Unable to get terminfo entry for %s.\n", Term); exit(1); } if (!clear_screen || !clr_eol || !cursor_address) { printf("FATAL ERROR: Terminfo entry for %s incomplete.\n", Term); exit(1); } if (!exit_attribute_mode) enter_reverse_mode = enter_standout_mode = enter_bold_mode = NULL; /* initialize the terminal */ TPUTS(init_1string); TPUTS(init_2string); TPUTS(init_3string); set_tkey(0, key_up); set_tkey(1, key_down); set_tkey(2, key_right); set_tkey(3, key_left); set_tkey(4, key_ic); set_tkey(5, key_dc); set_tkey(6, key_ppage); set_tkey(7, key_npage); set_tkey(8, key_home); set_tkey(9, key_end); if (key_f0) { /* old school */ set_tkey(10, key_f0); set_tkey(11, key_f1); i = 12; } else { set_tkey(10, key_f1); set_tkey(21, key_f12); i = 11; } set_tkey(i++, key_f2); set_tkey(i++, key_f3); set_tkey(i++, key_f4); set_tkey(i++, key_f5); set_tkey(i++, key_f6); set_tkey(i++, key_f7); set_tkey(i++, key_f8); set_tkey(i++, key_f9); set_tkey(i++, key_f10); set_tkey(i++, key_f11); #ifdef SAM_NO Key_mask = 0x00c00000; /* C-Home and C-End not in terminfo */ for (k = 0; k < i; ++k) if (Tkeys[k] && *Tkeys[k]) Key_mask |= 1 << k; if (verbose) { for (k = 0; k < i; ++k) dump_key(k, Tkeys[k], NULL); Dbg("Key Mask %x\n", Key_mask); } #endif }