示例#1
0
slk_label(int n)
{
    T((T_CALLED("slk_label(%d)"), n));

    if (SP == NULL || SP->_slk == NULL || n < 1 || n > SP->_slk->labcnt)
        returnPtr(0);
    returnPtr(SP->_slk->ent[n - 1].text);
}
示例#2
0
longname(void)
{
    char *ptr;

    T((T_CALLED("longname()")));

    for (ptr = ttytype + strlen(ttytype); ptr > ttytype; ptr--)
	if (*ptr == '|')
	    returnPtr(ptr + 1);

    returnPtr(ttytype);
}
示例#3
0
文件: lib_ti.c 项目: 2asoft/freebsd
NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx NCURSES_CONST char *str)
{
    char *result = CANCELLED_STRING;
    int j = -1;

    T((T_CALLED("tigetstr(%p, %s)"), (void *) SP_PARM, str));

    if (HasTInfoTerminal(SP_PARM)) {
	TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
	struct name_table_entry const *entry_ptr;

	entry_ptr = _nc_find_type_entry(str, STRING, FALSE);
	if (entry_ptr != 0) {
	    j = entry_ptr->nte_index;
	}
#if NCURSES_XNAMES
	else {
	    int i;
	    for_each_ext_string(i, tp) {
		const char *capname = ExtStrname(tp, i, strnames);
		if (same_name(str, capname)) {
		    j = i;
		    break;
		}
	    }
	}
#endif
	if (j >= 0) {
	    /* note: setupterm forces cancelled strings to null */
	    result = tp->Strings[j];
	}
    }

    returnPtr(result);
}
示例#4
0
menu_pattern(const MENU * menu)
{
  static char empty[] = "";

  T((T_CALLED("menu_pattern(%p)"), menu));
  returnPtr(menu ? (menu->pattern ? menu->pattern : empty) : 0);
}
示例#5
0
文件: w32pipe.c 项目: jrmiddle/vile
static HANDLE
exec_shell(char *cmd, HANDLE *handles, int hide_child)
{
    W32_CHAR             *w32_cmdstr = 0;
    char                 *cmdstr;
    int                  freestr;
    PROCESS_INFORMATION  pi;
    STARTUPINFO          si;

    proc_handle = BAD_PROC_HANDLE;  /* in case of failure */
    TRACE((T_CALLED "exec_shell %s\n", cmd));
    if ((cmdstr = mk_shell_cmd_str(cmd, &freestr, TRUE)) == NULL)
    {
        /* heap exhausted! */

        no_memory("exec_shell");

        /* Give user a chance to read message--more will surely follow. */
        Sleep(3000);
    } else if ((w32_cmdstr = w32_charstring(cmdstr)) == 0) {
        no_memory("exec_shell");
    } else {

        memset(&si, 0, sizeof(si));
        si.cb          = sizeof(si);
        si.dwFlags     = STARTF_USESTDHANDLES;
        si.hStdInput   = handles[0];
        si.hStdOutput  = handles[1];
        si.hStdError   = handles[2];
#if DISP_NTWIN
        if (hide_child)
        {
            si.dwFlags     |= STARTF_USESHOWWINDOW;
            si.wShowWindow  = SW_HIDE;
        }
#endif
        TRACE(("CreateProcess %s (pipe)\n", cmdstr));
        if (CreateProcess(NULL,
                          w32_cmdstr,
                          NULL,
                          NULL,
                          TRUE,       /* Inherit handles */
                          0,
                          NULL,
                          NULL,
                          &si,
                          &pi))
        {
            /* Success */

            w32_close_handle(pi.hThread);
            proc_handle = pi.hProcess;
            TRACE(("...created proc_handle %#x\n", proc_handle));
        }
    }
    FreeIfNeeded(cmdstr);
    FreeIfNeeded(w32_cmdstr);
    returnPtr(proc_handle);
}
示例#6
0
NCURSES_SP_NAME(longname) (NCURSES_SP_DCL0)
{
    static char empty[] =
    {'\0'};
    char *ptr;

    T((T_CALLED("longname(%p)"), (void *) SP_PARM));

    if (SP_PARM) {
	for (ptr = SP_PARM->_ttytype + strlen(SP_PARM->_ttytype);
	     ptr > SP_PARM->_ttytype;
	     ptr--)
	    if (*ptr == '|')
		returnPtr(ptr + 1);
	returnPtr(SP_PARM->_ttytype);
    }
    return empty;
}
示例#7
0
curses_version(void)
{
    static char my_version[80];

    T((T_CALLED("curses_version()")));
    sprintf(my_version, "ncurses %s.%d",
	    NCURSES_VERSION,
	    NCURSES_VERSION_PATCH);
    returnPtr(my_version);
}
示例#8
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);
}
示例#9
0
termname(void)
{
    char *name = 0;

    T((T_CALLED("termname()")));

    if (cur_term != 0)
	name = cur_term->_termname;

    returnPtr(name);
}
示例#10
0
文件: keybound.c 项目: 2asoft/freebsd
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);
}
示例#11
0
tgoto
(const char *string, int x, int y)
{
    char *result;

    T((T_CALLED("tgoto(%s, %d, %d)"), _nc_visbuf(string), x, y));
#if !PURE_TERMINFO
    if (is_termcap(string))
	result = tgoto_internal(string, x, y);
    else
#endif
	result = tparm((NCURSES_CONST char *) string, y, x);
    returnPtr(result);
}
示例#12
0
termname(void)
{
    char *name = getenv("TERM");
    static char ret[MAX_ALIAS + 1];

    T((T_CALLED("termname()")));

    if (name != 0) {
	ret[0] = '\0';
	(void) strncat(ret, name, sizeof(ret) - 1);
	name = ret;
    }
    returnPtr(name);
}
示例#13
0
NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx NCURSES_CONST char *id, char **area)
{
    char *result = NULL;
    int i, j;

    T((T_CALLED("tgetstr(%s,%p)"), id, (void *) area));
    if (HasTInfoTerminal(SP_PARM)) {
	TERMTYPE *tp = &(TerminalOf(SP_PARM)->type);
	struct name_table_entry const *entry_ptr;

	entry_ptr = _nc_find_type_entry(id, STRING, TRUE);
	if (entry_ptr != 0) {
	    j = entry_ptr->nte_index;
	}
#if NCURSES_XNAMES
	else {
	    j = -1;
	    for_each_ext_string(i, tp) {
		const char *capname = ExtStrname(tp, i, strcodes);
		if (same_tcname(id, capname)) {
		    j = i;
		    break;
		}
	    }
	}
#endif
	if (j >= 0) {
	    result = tp->Strings[j];
	    TR(TRACE_DATABASE, ("found match : %s", _nc_visbuf(result)));
	    /* setupterm forces canceled strings to null */
	    if (VALID_STRING(result)) {
		if (result == exit_attribute_mode
		    && FIX_SGR0 != 0) {
		    result = FIX_SGR0;
		    TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result)));
		}
		if (area != 0
		    && *area != 0) {
		    (void) strcpy(*area, result);
		    result = *area;
		    *area += strlen(*area) + 1;
		}
	    }
	}
    }
    returnPtr(result);
}
NCURSES_SP_NAME(termname) (NCURSES_SP_DCL0)
{
    char *name = 0;

    T((T_CALLED("termname()")));

#if NCURSES_SP_FUNCS
    if (TerminalOf(SP_PARM) != 0) {
	name = TerminalOf(SP_PARM)->_termname;
    }
#else
    if (cur_term != 0)
	name = cur_term->_termname;
#endif

    returnPtr(name);
}
示例#15
0
_nc_trim_sgr0(TERMTYPE *tp)
{
    char *result = exit_attribute_mode;

    T((T_CALLED("_nc_trim_sgr0()")));

    if (PRESENT(exit_attribute_mode)
	&& PRESENT(set_attributes)) {
	bool found = FALSE;
	char *on = set_attribute_9(tp, 1);
	char *off = set_attribute_9(tp, 0);
	char *end = strdup(exit_attribute_mode);
	char *tmp;
	size_t i, j, k;

	TR(TRACE_DATABASE, ("checking if we can trim sgr0 based on sgr"));
	TR(TRACE_DATABASE, ("sgr0       %s", _nc_visbuf(end)));
	TR(TRACE_DATABASE, ("sgr(9:off) %s", _nc_visbuf(off)));
	TR(TRACE_DATABASE, ("sgr(9:on)  %s", _nc_visbuf(on)));

	if (!rewrite_sgr(on, enter_alt_charset_mode)
	    || !rewrite_sgr(off, exit_alt_charset_mode)
	    || !rewrite_sgr(end, exit_alt_charset_mode)) {
	    FreeIfNeeded(off);
	} else if (similar_sgr(off, end)
		   && !similar_sgr(off, on)) {
	    TR(TRACE_DATABASE, ("adjusting sgr(9:off) : %s", _nc_visbuf(off)));
	    result = off;
	    /*
	     * If rmacs is a substring of sgr(0), remove that chunk.
	     */
	    if (exit_alt_charset_mode != 0) {
		TR(TRACE_DATABASE, ("scan for rmacs %s", _nc_visbuf(exit_alt_charset_mode)));
		j = strlen(off);
		k = strlen(exit_alt_charset_mode);
		if (j > k) {
		    for (i = 0; i <= (j - k); ++i) {
			unsigned k2 = compare_part(exit_alt_charset_mode,
						   off + i);
			if (k2 != 0) {
			    found = TRUE;
			    chop_out(off, (unsigned) i, (unsigned) (i + k2));
			    break;
			}
		    }
		}
	    }
	    /*
	     * SGR 10 would reset to normal font.
	     */
	    if (!found) {
		if ((i = (size_t) is_csi(off)) != 0
		    && off[strlen(off) - 1] == 'm') {
		    TR(TRACE_DATABASE, ("looking for SGR 10 in %s",
					_nc_visbuf(off)));
		    tmp = skip_zero(off + i);
		    if (tmp[0] == '1'
			&& skip_zero(tmp + 1) != tmp + 1) {
			i = (size_t) (tmp - off);
			if (off[i - 1] == ';')
			    i--;
			j = (size_t) (skip_zero(tmp + 1) - off);
			(void) chop_out(off, (unsigned) i, (unsigned) j);
			found = TRUE;
		    }
		}
	    }
	    if (!found
		&& (tmp = strstr(end, off)) != 0
		&& strcmp(end, off) != 0) {
		i = (size_t) (tmp - end);
		j = strlen(off);
		tmp = strdup(end);
		chop_out(tmp, (unsigned) i, (unsigned) j);
		free(off);
		result = tmp;
	    }
	    TR(TRACE_DATABASE, ("...adjusted sgr0 : %s", _nc_visbuf(result)));
	    if (!strcmp(result, exit_attribute_mode)) {
		TR(TRACE_DATABASE, ("...same result, discard"));
		free(result);
		result = exit_attribute_mode;
	    }
	} else {
	    /*
	     * Either the sgr does not reference alternate character set,
	     * or it is incorrect.  That's too hard to decide right now.
	     */
	    free(off);
	}
	FreeIfNeeded(end);
	FreeIfNeeded(on);
    } else {
	/*
	 * Possibly some applications are confused if sgr0 contains rmacs,
	 * but that would be a different bug report -TD
	 */
    }

    returnPtr(result);
}