Exemplo n.º 1
0
inline CHAR_T *wcs_array_join(CHAR_T **array, const CHAR_T *sep) {
	char **arr;
	char *sp = wcs_to_normal(sep);
	char *tmp;
	CHAR_T *ret;
	int i;

	arr = xmalloc( (g_strv_length((char **) array)+1) * sizeof(char *));
	for (i = 0; array[i]; i++)
		arr[i] = wcs_to_normal(array[i]);
	
	tmp = g_strjoinv(sp, arr);
	ret = normal_to_wcs(tmp);
	g_strfreev(arr);
	xfree(tmp);
	xfree(sp);
	return ret;
}
Exemplo n.º 2
0
static BINDING_FUNCTION(binding_toggle_input)
{
    if (input_size == 1) {
        input_size = MULTILINE_INPUT_SIZE;
        ncurses_input_update(line_index);
    } else {
        string_t s = string_init((""));
        char *p, *tmp;
        int i;

        for (i = 0; lines[i]; i++) {
            char *tmp;

            string_append(s, (tmp = wcs_to_normal(lines[i])));
            free_utf(tmp);
            if (lines[i + 1])
                string_append(s, ("\r\n"));
        }

        tmp = string_free(s, 0);

        add_to_history();

        input_size = 1;
        ncurses_input_update(0);

        for (p=tmp; *p && isspace(*p); p++);
        if (*p || config_send_white_lines)
            command_exec(window_current->target, window_current->session, tmp, 0);

        if (!tmp[0] || tmp[0] == '/' || !window_current->target)
            ncurses_typing_mod		= 1;
        else {
            ncurses_typing_win		= NULL;
            window_current->out_active	= 1;
        }

        curs_set(1);
        xfree(tmp);
    }
}
Exemplo n.º 3
0
static BINDING_FUNCTION(binding_accept_line)
{
    char *p, *txt;

    if (ncurses_noecho) { /* we are running ui-password-input */
        ncurses_noecho = 0;
        ncurses_passbuf = xwcsdup(line);
        line[0] = 0;
        line_adjust();
        return;
    }

    if (lines) {
        int i;

        lines = xrealloc(lines, (array_count((char **) lines) + 2) * sizeof(CHAR_T *));

        for (i = array_count((char **) lines); i > lines_index; i--)
            lines[i + 1] = lines[i];

        lines[lines_index + 1] = xmalloc(LINE_MAXLEN*sizeof(CHAR_T));
        xwcscpy(lines[lines_index + 1], line + line_index);
        line[line_index] = 0;

        line_index = 0;
        line_start = 0;
        lines_index++;

        lines_adjust();

        return;
    }
    if (arg != BINDING_HISTORY_NOEXEC) {
        txt = wcs_to_normal(line);
        for (p=txt; *p && isspace(*p); p++);
        if (*p || config_send_white_lines)
            command_exec(window_current->target, window_current->session, txt, 0);
        free_utf(txt);
    }

    if (ncurses_plugin_destroyed)
        return;
    if (!line[0] || line[0] == '/' || !window_current->target) /* if empty or command, just mark as modified */
        ncurses_typing_mod		= 1;
    else { /* if message, assume that its' handler has already disabled <composing/> */
        ncurses_typing_win		= NULL;
        window_current->out_active	= 1; /* but also remember that it should have set <active/> chatstate */
    }

    if (xwcscmp(line, TEXT(""))) {
        if (config_history_savedups || xwcscmp(line, history[1]))
            add_to_history();
    } else {
        if (config_enter_scrolls)
            print("none", "");
    }

    history[0] = line;
    history_index = 0;
    *line = 0;
    line_adjust();
}