safe_ungetch(SCREEN *sp, int ch) { int rc = ERR; T((T_CALLED("ungetch(%p,%s)"), (void *) sp, _nc_tracechar(sp, ch))); if (tail != -1) { if (head == -1) { head = 0; t_inc(); peek = tail; /* no raw keys */ } else h_dec(); sp->_fifo[head] = ch; T(("ungetch %s ok", _nc_tracechar(sp, ch))); #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { _nc_fifo_dump(sp); _nc_unlock_global(tracef); } #endif rc = OK; } returnCode(rc); }
_tracecchar_t2(int bufnum, const cchar_t *ch) { char *result = _nc_trace_buf(bufnum, BUFSIZ); attr_t attr; const char *found; if (result != 0) { strcpy(result, l_brace); if (ch != 0) { attr = AttrOfD(ch); if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) { (void) _nc_trace_bufcat(bufnum, found); attr &= ~A_ALTCHARSET; } else if (isWidecExt(CHDEREF(ch))) { (void) _nc_trace_bufcat(bufnum, "{NAC}"); attr &= ~A_CHARTEXT; } else { PUTC_DATA; int n; PUTC_INIT; (void) _nc_trace_bufcat(bufnum, "{ "); for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { PUTC_ch = ch->chars[PUTC_i]; if (PUTC_ch == L'\0') { if (PUTC_i == 0) result = _nc_trace_bufcat(bufnum, "\\000"); break; } PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st); if (PUTC_n <= 0) { if (PUTC_ch != L'\0') { /* it could not be a multibyte sequence */ (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, UChar(ch->chars[PUTC_i]))); } break; } for (n = 0; n < PUTC_n; n++) { if (n) (void) _nc_trace_bufcat(bufnum, ", "); (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, UChar(PUTC_buf[n]))); } } (void) _nc_trace_bufcat(bufnum, " }"); } if (attr != A_NORMAL) { (void) _nc_trace_bufcat(bufnum, " | "); (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); } } result = _nc_trace_bufcat(bufnum, r_brace); } return result; }
_nc_fifo_dump(SCREEN *sp) { int i; T(("head = %d, tail = %d, peek = %d", head, tail, peek)); for (i = 0; i < 10; i++) T(("char %d = %s", i, _nc_tracechar(sp, sp->_fifo[i]))); }
_tracechtype2(int bufnum, chtype ch) { char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ); if (result != 0) { const char *found; attr_t attr = ChAttrOf(ch); _nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum)); if ((found = _nc_altcharset_name(attr, ch)) != 0) { (void) _nc_trace_bufcat(bufnum, found); attr &= ~A_ALTCHARSET; } else (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, (int) ChCharOf(ch))); if (attr != A_NORMAL) { (void) _nc_trace_bufcat(bufnum, " | "); (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); } result = _nc_trace_bufcat(bufnum, r_brace); } return result; }
static NCURSES_INLINE int fifo_pull(SCREEN *sp) { int ch; ch = sp->_fifo[head]; TR(TRACE_IEVENT, ("pulling %s from %d", _nc_tracechar(sp, ch), head)); if (peek == head) { h_inc(); peek = head; } else h_inc(); #ifdef TRACE if (USE_TRACEF(TRACE_IEVENT)) { _nc_fifo_dump(sp); _nc_unlock_global(tracef); } #endif return ch; }
_tracechtype2(int bufnum, chtype ch) { const char *found; char *result = _nc_trace_buf(bufnum, BUFSIZ); if (result != 0) { strcpy(result, l_brace); if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) { (void) _nc_trace_bufcat(bufnum, found); } else (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, (int) ChCharOf(ch))); if (ChAttrOf(ch) != A_NORMAL) { (void) _nc_trace_bufcat(bufnum, " | "); (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, ChAttrOf(ch))); } result = _nc_trace_bufcat(bufnum, r_brace); } return result; }
_tracechar(int ch) { return _nc_tracechar(SP, ch); }
_tracechar(int ch) { return _nc_tracechar(CURRENT_SCREEN, ch); }
NCURSES_SP_NAME(ungetch) (NCURSES_SP_DCLx int ch) { T((T_CALLED("ungetch(%s)"), _nc_tracechar(SP_PARM, ch))); returnCode(_nc_ungetch(SP_PARM, ch)); }
_tracecchar_t2(int bufnum, const cchar_t *ch) { char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ); if (result != 0) { _nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum)); if (ch != 0) { const char *found; attr_t attr = AttrOfD(ch); if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) { (void) _nc_trace_bufcat(bufnum, found); attr &= ~A_ALTCHARSET; } else if (isWidecExt(CHDEREF(ch))) { (void) _nc_trace_bufcat(bufnum, "{NAC}"); attr &= ~A_CHARTEXT; } else { PUTC_DATA; int n; (void) _nc_trace_bufcat(bufnum, "{ "); for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { PUTC_ch = ch->chars[PUTC_i]; if (PUTC_ch == L'\0') { if (PUTC_i == 0) (void) _nc_trace_bufcat(bufnum, "\\000"); break; } PUTC_INIT; PUTC_n = (int) wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st); if (PUTC_n <= 0) { if (PUTC_ch != L'\0') { /* it could not be a multibyte sequence */ (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, UChar(ch->chars[PUTC_i]))); } break; } else if (ch->chars[PUTC_i] > 255) { char temp[80]; _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "{%d:\\u%lx}", wcwidth(ch->chars[PUTC_i]), (unsigned long) ch->chars[PUTC_i]); (void) _nc_trace_bufcat(bufnum, temp); break; } for (n = 0; n < PUTC_n; n++) { if (n) (void) _nc_trace_bufcat(bufnum, ", "); (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, UChar(PUTC_buf[n]))); } } (void) _nc_trace_bufcat(bufnum, " }"); } if (attr != A_NORMAL) { (void) _nc_trace_bufcat(bufnum, " | "); (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); } #if NCURSES_EXT_COLORS /* * Just in case the extended color is different from the chtype * value, trace both. */ if (ch->ext_color != PairNumber(attr)) { char temp[80]; _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) " X_COLOR{%d:%d}", ch->ext_color, PairNumber(attr)); (void) _nc_trace_bufcat(bufnum, temp); } #endif } result = _nc_trace_bufcat(bufnum, r_brace); } return result; }
ungetch(int ch) { T((T_CALLED("ungetch(%s)"), _nc_tracechar(SP, ch))); returnCode(_nc_ungetch(SP, ch)); }