NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf) { int result = OK; if (buf == 0 || SP_PARM == 0) { result = ERR; } else { TERMINAL *termp = TerminalOf(SP_PARM); if (0 == termp) { result = ERR; } else { #ifdef USE_TERM_DRIVER result = CallDriver_2(SP_PARM, sgmode, FALSE, buf); #else for (;;) { if (GET_TTY(termp->Filedes, buf) != 0) { if (errno == EINTR) continue; result = ERR; } break; } #endif } if (result == ERR) memset(buf, 0, sizeof(*buf)); TR(TRACE_BITS, ("_nc_get_tty_mode(%d): %s", termp ? termp->Filedes : -1, _nc_trace_ttymode(buf))); } return (result); }
NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0) { int rc = ERR; TERMINAL *termp = TerminalOf(SP_PARM); T((T_CALLED("def_shell_mode(%p)"), (void *) SP_PARM)); if (termp != 0) { #ifdef USE_TERM_DRIVER rc = CallDriver_2(SP_PARM, mode, FALSE, TRUE); #else /* * If XTABS was on, remove the tab and backtab capabilities. */ if (_nc_get_tty_mode(&termp->Ottyb) == OK) { #ifdef TERMIOS if (termp->Ottyb.c_oflag & OFLAGS_TABS) tab = back_tab = NULL; #else if (termp->Ottyb.sg_flags & XTABS) tab = back_tab = NULL; #endif rc = OK; } #endif } returnCode(rc); }
NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_DCL0) { int rc = ERR; TERMINAL *termp = TerminalOf(SP_PARM); T((T_CALLED("def_prog_mode(%p)"), (void *) SP_PARM)); if (termp != 0) { #ifdef USE_TERM_DRIVER rc = CallDriver_2(SP_PARM, mode, TRUE, TRUE); #else /* * Turn off the XTABS bit in the tty structure if it was on. */ if (_nc_get_tty_mode(&termp->Nttyb) == OK) { #ifdef TERMIOS termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS); #else termp->Nttyb.sg_flags &= (unsigned) (~XTABS); #endif rc = OK; } #endif } returnCode(rc); }
NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_DCLx int fg, int bg) { int code = ERR; T((T_CALLED("assume_default_colors(%p,%d,%d)"), (void *) SP_PARM, fg, bg)); #ifdef USE_TERM_DRIVER if (sp != 0) code = CallDriver_2(sp, defaultcolors, fg, bg); #else if ((orig_pair || orig_colors) && !initialize_pair) { SP_PARM->_default_color = isDefaultColor(fg) || isDefaultColor(bg); SP_PARM->_has_sgr_39_49 = (tigetflag("AX") == TRUE); SP_PARM->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK); SP_PARM->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK); if (SP_PARM->_color_pairs != 0) { bool save = SP_PARM->_default_color; SP_PARM->_default_color = TRUE; init_pair(0, (short) fg, (short) bg); SP_PARM->_default_color = save; } code = OK; } #endif returnCode(code); }
NCURSES_SP_NAME(_nc_mcprint) (SCREEN *sp, char *data, int len) { int code = ERR; if (0 != TerminalOf(sp)) code = CallDriver_2(sp, print, data, len); return (code); }
NCURSES_SP_NAME(keyok) (NCURSES_SP_DCLx int c, bool flag) { int code = ERR; if (HasTerminal(SP_PARM)) { T((T_CALLED("keyok(%p, %d,%d)"), (void *) SP_PARM, c, flag)); #ifdef USE_TERM_DRIVER code = CallDriver_2(sp, kyOk, c, flag); #else T((T_CALLED("keyok(%d,%d)"), c, flag)); if (c >= 0) { int count = 0; char *s; unsigned ch = (unsigned) c; if (flag) { while ((s = _nc_expand_try(SP_PARM->_key_ok, ch, &count, (size_t) 0)) != 0) { if (_nc_remove_key(&(SP_PARM->_key_ok), ch)) { code = _nc_add_to_try(&(SP_PARM->_keytry), s, ch); free(s); count = 0; if (code != OK) break; } else { free(s); } } } else { while ((s = _nc_expand_try(SP_PARM->_keytry, ch, &count, (size_t) 0)) != 0) { if (_nc_remove_key(&(SP_PARM->_keytry), ch)) { code = _nc_add_to_try(&(SP_PARM->_key_ok), s, ch); free(s); count = 0; if (code != OK) break; } else { free(s); } } } } #endif } returnCode(code); }
NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_DCL0) { int rc = ERR; TERMINAL *termp = TerminalOf(SP_PARM); T((T_CALLED("reset_shell_mode(%p)"), (void *) SP_PARM)); if (termp != 0) { #ifdef USE_TERM_DRIVER rc = CallDriver_2(SP_PARM, mode, FALSE, FALSE); #else if (SP_PARM) { _nc_keypad(SP_PARM, FALSE); _nc_flush(); NC_BUFFERED(SP_PARM, FALSE); } rc = _nc_set_tty_mode(&termp->Ottyb); #endif } returnCode(rc); }
NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_DCL0) { int rc = ERR; TERMINAL *termp = TerminalOf(SP_PARM); T((T_CALLED("reset_prog_mode(%p)"), (void *) SP_PARM)); if (termp != 0) { #ifdef USE_TERM_DRIVER rc = CallDriver_2(SP_PARM, mode, TRUE, FALSE); #else if (_nc_set_tty_mode(&termp->Nttyb) == OK) { if (SP_PARM) { if (SP_PARM->_keypad_on) _nc_keypad(SP_PARM, TRUE); NC_BUFFERED(SP_PARM, TRUE); } rc = OK; } #endif } returnCode(rc); }
NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf) { int result = OK; if (buf == 0 || SP_PARM == 0) { result = ERR; } else { TERMINAL *termp = TerminalOf(SP_PARM); if (0 == termp) { result = ERR; } else { #ifdef USE_TERM_DRIVER result = CallDriver_2(SP_PARM, sgmode, TRUE, buf); #else for (;;) { if ((SET_TTY(termp->Filedes, buf) != 0) #if USE_KLIBC_KBD && !isatty(termp->Filedes) #endif ) { if (errno == EINTR) continue; if ((errno == ENOTTY) && (SP_PARM != 0)) SP_PARM->_notty = TRUE; result = ERR; } break; } #endif } TR(TRACE_BITS, ("_nc_set_tty_mode(%d): %s", termp ? termp->Filedes : -1, _nc_trace_ttymode(buf))); } return (result); }
/* * Write the soft labels to the soft-key window. */ static void slk_intern_refresh(SCREEN *sp) { int i; int fmt; SLK *slk; int numlab; if (sp == 0) return; slk = sp->_slk; fmt = sp->slk_format; numlab = NumLabels; if (slk->hidden) return; for (i = 0; i < slk->labcnt; i++) { if (slk->dirty || slk->ent[i].dirty) { if (slk->ent[i].visible) { if (numlab > 0 && SLK_STDFMT(fmt)) { #ifdef USE_TERM_DRIVER CallDriver_2(sp, hwlabel, i + 1, slk->ent[i].form_text); #else if (i < num_labels) { TPUTS_TRACE("plab_norm"); putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text)); } #endif } else { if (fmt == 4) slk_paint_info(slk->win); wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); if (sp->_slk) { (void) wattrset(slk->win, AttrOf(sp->_slk->attr)); } waddstr(slk->win, slk->ent[i].form_text); /* if we simulate SLK's, it's looking much more natural to use the current ATTRIBUTE also for the label window */ (void) wattrset(slk->win, WINDOW_ATTRS(StdScreen(sp))); } } slk->ent[i].dirty = FALSE; } } slk->dirty = FALSE; if (numlab > 0) { #ifdef USE_TERM_DRIVER CallDriver_1(sp, hwlabelOnOff, slk->hidden ? FALSE : TRUE); #else if (slk->hidden) { TPUTS_TRACE("label_off"); putp(label_off); } else { TPUTS_TRACE("label_on"); putp(label_on); } #endif } }
NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0) { chtype *fake_map = acs_map; chtype *real_map = SP_PARM != 0 ? SP_PARM->_acs_map : fake_map; int j; T(("initializing ACS map")); /* * If we're using this from curses (rather than terminfo), we are storing * the mapping information in the SCREEN struct so we can decide how to * render it. */ if (real_map != fake_map) { for (j = 1; j < ACS_LEN; ++j) { real_map[j] = 0; fake_map[j] = A_ALTCHARSET | (chtype) j; if (SP_PARM) SP_PARM->_screen_acs_map[j] = FALSE; } } else { for (j = 1; j < ACS_LEN; ++j) { real_map[j] = 0; } } /* * Initializations for a UNIX-like multi-terminal environment. Use * ASCII chars and count on the terminfo description to do better. */ real_map['l'] = '+'; /* should be upper left corner */ real_map['m'] = '+'; /* should be lower left corner */ real_map['k'] = '+'; /* should be upper right corner */ real_map['j'] = '+'; /* should be lower right corner */ real_map['u'] = '+'; /* should be tee pointing left */ real_map['t'] = '+'; /* should be tee pointing right */ real_map['v'] = '+'; /* should be tee pointing up */ real_map['w'] = '+'; /* should be tee pointing down */ real_map['q'] = '-'; /* should be horizontal line */ real_map['x'] = '|'; /* should be vertical line */ real_map['n'] = '+'; /* should be large plus or crossover */ real_map['o'] = '~'; /* should be scan line 1 */ real_map['s'] = '_'; /* should be scan line 9 */ real_map['`'] = '+'; /* should be diamond */ real_map['a'] = ':'; /* should be checker board (stipple) */ real_map['f'] = '\''; /* should be degree symbol */ real_map['g'] = '#'; /* should be plus/minus */ real_map['~'] = 'o'; /* should be bullet */ real_map[','] = '<'; /* should be arrow pointing left */ real_map['+'] = '>'; /* should be arrow pointing right */ real_map['.'] = 'v'; /* should be arrow pointing down */ real_map['-'] = '^'; /* should be arrow pointing up */ real_map['h'] = '#'; /* should be board of squares */ real_map['i'] = '#'; /* should be lantern symbol */ real_map['0'] = '#'; /* should be solid square block */ /* these defaults were invented for ncurses */ real_map['p'] = '-'; /* should be scan line 3 */ real_map['r'] = '-'; /* should be scan line 7 */ real_map['y'] = '<'; /* should be less-than-or-equal-to */ real_map['z'] = '>'; /* should be greater-than-or-equal-to */ real_map['{'] = '*'; /* should be greek pi */ real_map['|'] = '!'; /* should be not-equal */ real_map['}'] = 'f'; /* should be pound-sterling symbol */ /* thick-line-drawing */ real_map['L'] = '+'; /* upper left corner */ real_map['M'] = '+'; /* lower left corner */ real_map['K'] = '+'; /* upper right corner */ real_map['J'] = '+'; /* lower right corner */ real_map['T'] = '+'; /* tee pointing left */ real_map['U'] = '+'; /* tee pointing right */ real_map['V'] = '+'; /* tee pointing up */ real_map['W'] = '+'; /* tee pointing down */ real_map['Q'] = '-'; /* horizontal line */ real_map['X'] = '|'; /* vertical line */ real_map['N'] = '+'; /* large plus or crossover */ /* double-line-drawing */ real_map['C'] = '+'; /* upper left corner */ real_map['D'] = '+'; /* lower left corner */ real_map['B'] = '+'; /* upper right corner */ real_map['A'] = '+'; /* lower right corner */ real_map['G'] = '+'; /* tee pointing left */ real_map['F'] = '+'; /* tee pointing right */ real_map['H'] = '+'; /* tee pointing up */ real_map['I'] = '+'; /* tee pointing down */ real_map['R'] = '-'; /* horizontal line */ real_map['Y'] = '|'; /* vertical line */ real_map['E'] = '+'; /* large plus or crossover */ #ifdef USE_TERM_DRIVER CallDriver_2(SP_PARM, initacs, real_map, fake_map); #else if (ena_acs != NULL) { NCURSES_PUTP2("ena_acs", ena_acs); } #if NCURSES_EXT_FUNCS /* * Linux console "supports" the "PC ROM" character set by the coincidence * that smpch/rmpch and smacs/rmacs have the same values. ncurses has * no codepage support (see SCO Merge for an example). Outside of the * values defined in acsc, there are no definitions for the "PC ROM" * character set (assumed by some applications to be codepage 437), but we * allow those applications to use those codepoints. * * test/blue.c uses this feature. */ #define PCH_KLUDGE(a,b) (a != 0 && b != 0 && !strcmp(a,b)) if (PCH_KLUDGE(enter_pc_charset_mode, enter_alt_charset_mode) && PCH_KLUDGE(exit_pc_charset_mode, exit_alt_charset_mode)) { size_t i; for (i = 1; i < ACS_LEN; ++i) { if (real_map[i] == 0) { real_map[i] = (chtype) i; if (real_map != fake_map) { if (SP != 0) SP->_screen_acs_map[i] = TRUE; } } } } #endif if (acs_chars != NULL) { size_t i = 0; size_t length = strlen(acs_chars); while (i + 1 < length) { if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) { real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET; if (SP != 0) SP->_screen_acs_map[UChar(acs_chars[i])] = TRUE; } i += 2; } } #ifdef TRACE /* Show the equivalent mapping, noting if it does not match the * given attribute, whether by re-ordering or duplication. */ if (USE_TRACEF(TRACE_CALLS)) { size_t n, m; char show[ACS_LEN * 2 + 1]; for (n = 1, m = 0; n < ACS_LEN; n++) { if (real_map[n] != 0) { show[m++] = (char) n; show[m++] = (char) ChCharOf(real_map[n]); } } show[m] = 0; if (acs_chars == NULL || strcmp(acs_chars, show)) _tracef("%s acs_chars %s", (acs_chars == NULL) ? "NULL" : "READ", _nc_visbuf(acs_chars)); _tracef("%s acs_chars %s", (acs_chars == NULL) ? "NULL" : (strcmp(acs_chars, show) ? "DIFF" : "SAME"), _nc_visbuf(show)); _nc_unlock_global(tracef); } #endif /* TRACE */ #endif }