Ejemplo n.º 1
0
NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_DCLx int ch)
{
    int rc = OK;

    COUNT_OUTCHARS(1);

    if (HasTInfoTerminal(SP_PARM)
	&& SP_PARM != 0) {
	if (SP_PARM->out_buffer != 0) {
	    if (SP_PARM->out_inuse + 1 >= SP_PARM->out_limit)
		NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
	    SP_PARM->out_buffer[SP_PARM->out_inuse++] = (char) ch;
	} else {
	    char tmp = (char) ch;
	    /*
	     * POSIX says write() is safe in a signal handler, but the
	     * buffered I/O is not.
	     */
	    if (write(fileno(NC_OUTPUT(SP_PARM)), &tmp, (size_t) 1) == -1)
		rc = ERR;
	}
    } else {
	char tmp = (char) ch;
	if (write(fileno(stdout), &tmp, (size_t) 1) == -1)
	    rc = ERR;
    }
    return rc;
}
Ejemplo n.º 2
0
NCURSES_SP_NAME(tgetflag) (NCURSES_SP_DCLx NCURSES_CONST char *id)
{
    int result = 0;		/* Solaris returns zero for missing flag */

    T((T_CALLED("tgetflag(%p, %s)"), (void *) SP_PARM, id));
    if (HasTInfoTerminal(SP_PARM) && ValidCap(id)) {
	TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
	struct name_table_entry const *entry_ptr;
	int j = -1;

	entry_ptr = _nc_find_type_entry(id, BOOLEAN, TRUE);
	if (entry_ptr != 0) {
	    j = entry_ptr->nte_index;
	}
#if NCURSES_XNAMES
	else {
	    int i;
	    for_each_ext_boolean(i, tp) {
		const char *capname = ExtBoolname(tp, i, boolcodes);
		if (same_tcname(id, capname) && ValidExt(capname)) {
		    j = i;
		    break;
		}
	    }
	}
#endif
	if (j >= 0) {
	    /* note: setupterm forces invalid booleans to false */
	    result = tp->Booleans[j];
	}
    }
Ejemplo n.º 3
0
NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_DCLx int ch)
{
    int rc = OK;

    COUNT_OUTCHARS(1);

    if (HasTInfoTerminal(SP_PARM)
	&& SP_PARM != 0
	&& SP_PARM->_cleanup) {
	char tmp = (char) ch;
	/*
	 * POSIX says write() is safe in a signal handler, but the
	 * buffered I/O is not.
	 */
	if (write(fileno(NC_OUTPUT(SP_PARM)), &tmp, 1) == -1)
	    rc = ERR;
    } else {
	if (putc(ch, NC_OUTPUT(SP_PARM)) == EOF)
	    rc = ERR;
    }
    return rc;
}
Ejemplo n.º 4
0
NCURSES_SP_NAME(define_key) (NCURSES_SP_DCLx const char *str, int keycode)
{
    int code = ERR;

    T((T_CALLED("define_key(%p, %s,%d)"), (void *) SP_PARM, _nc_visbuf(str), keycode));
    if (SP_PARM == 0 || !HasTInfoTerminal(SP_PARM)) {
	code = ERR;
    } else if (keycode > 0) {
	unsigned ukey = (unsigned) keycode;

#ifdef USE_TERM_DRIVER
#define CallHasKey(keycode) CallDriver_1(SP_PARM, td_kyExist, keycode)
#else
#define CallHasKey(keycode) NCURSES_SP_NAME(has_key)(NCURSES_SP_ARGx keycode)
#endif

	if (str != 0) {
	    NCURSES_SP_NAME(define_key) (NCURSES_SP_ARGx str, 0);
	} else if (CallHasKey(keycode)) {
	    while (_nc_remove_key(&(SP_PARM->_keytry), ukey))
		code = OK;
	}
	if (str != 0) {
	    if (NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx str) == 0) {
		if (_nc_add_to_try(&(SP_PARM->_keytry), str, ukey) == OK) {
		    code = OK;
		} else {
		    code = ERR;
		}
	    } else {
		code = ERR;
	    }
	}
    } else {
	while (_nc_remove_string(&(SP_PARM->_keytry), str))
	    code = OK;
    }
    returnCode(code);
}
Ejemplo n.º 5
0
NCURSES_SP_NAME(delay_output) (NCURSES_SP_DCLx int ms)
{
    T((T_CALLED("delay_output(%p,%d)"), (void *) SP_PARM, ms));

    if (!HasTInfoTerminal(SP_PARM))
	returnCode(ERR);

    if (no_pad_char) {
	NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
	napms(ms);
    } else {
	NCURSES_SP_OUTC my_outch = GetOutCh();
	register int nullcount;

	nullcount = (ms * _nc_baudrate(ospeed)) / (BAUDBYTE * 1000);
	for (_nc_nulls_sent += nullcount; nullcount > 0; nullcount--)
	    my_outch(NCURSES_SP_ARGx PC);
	if (my_outch == NCURSES_SP_NAME(_nc_outch))
	    NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
    }

    returnCode(OK);
}