Example #1
0
keyok(int c, bool flag)
{
    int code = ERR;
    int count = 0;
    char *s;

    T((T_CALLED("keyok(%d,%d)"), c, flag));
    if (flag) {
        while ((s = _nc_expand_try(SP->_key_ok, c, &count, 0)) != 0
                && _nc_remove_key(&(SP->_key_ok), c)) {
            _nc_add_to_try(&(SP->_keytry), s, c);
            free(s);
            code = OK;
            count = 0;
        }
    } else {
        while ((s = _nc_expand_try(SP->_keytry, c, &count, 0)) != 0
                && _nc_remove_key(&(SP->_keytry), c)) {
            _nc_add_to_try(&(SP->_key_ok), s, c);
            free(s);
            code = OK;
            count = 0;
        }
    }
    returnCode(code);
}
Example #2
0
keyok(int c, bool flag)
{
    int code = ERR;
    int count = 0;
    char *s;

    T((T_CALLED("keyok(%d,%d)"), c, flag));
    if (c >= 0) {
	unsigned ch = (unsigned) c;
	if (flag) {
	    while ((s = _nc_expand_try(SP->_key_ok, ch, &count, 0)) != 0
		   && _nc_remove_key(&(SP->_key_ok), ch)) {
		code = _nc_add_to_try(&(SP->_keytry), s, ch);
		free(s);
		count = 0;
		if (code != OK)
		    break;
	    }
	} else {
	    while ((s = _nc_expand_try(SP->_keytry, ch, &count, 0)) != 0
		   && _nc_remove_key(&(SP->_keytry), ch)) {
		code = _nc_add_to_try(&(SP->_key_ok), s, ch);
		free(s);
		count = 0;
		if (code != OK)
		    break;
	    }
	}
    }
    returnCode(code);
}
Example #3
0
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);
}
Example #4
0
keybound(int code, int count)
{
    char *result = 0;

    T((T_CALLED("keybound(%d,%d)"), code, count));
    if (SP != 0 && code >= 0) {
	result = _nc_expand_try(SP->_keytry, (unsigned) code, &count, 0);
    }
    returnPtr(result);
}
Example #5
0
NCURSES_SP_NAME(keybound) (NCURSES_SP_DCLx int code, int count)
{
    char *result = 0;

    T((T_CALLED("keybound(%p, %d,%d)"), (void *) SP_PARM, code, count));
    if (SP_PARM != 0 && code >= 0) {
	result = _nc_expand_try(SP_PARM->_keytry,
				(unsigned) code,
				&count,
				(size_t) 0);
    }
    returnPtr(result);
}