Esempio n. 1
0
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);
}
Esempio n. 2
0
int ungetch(int ch)
{
	if (tail == -1)
		return ERR;
	if (head == -1) {
		head = 0;
		t_inc()
		peek = tail; /* no raw keys */
	} else
		h_dec();

	SP->_fifo[head] = ch;
	T(("ungetch %#x ok", ch));
#ifdef TRACE
	if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump();
#endif
	return OK;
}