Beispiel #1
0
void binding_helper_scroll(window_t *w, int offset) {
    ncurses_window_t *n;

    if (!w || !(n = w->priv_data))
        return;

    if (offset < 0) {
        n->start += offset;
        if (n->start < 0)
            n->start = 0;

    } else {
        n->start += offset;

        if (n->start > n->lines_count - w->height + n->overflow)
            n->start = n->lines_count - w->height + n->overflow;

        if (n->start < 0)
            n->start = 0;

        /* old code from: binding_forward_page() need it */
        if (w == window_current) {
            if (ncurses_current->start == ncurses_current->lines_count - window_current->height + ncurses_current->overflow) {
                window_current->more = 0;
                update_statusbar(0);
            }
        }
    }

    ncurses_redraw(w);
    ncurses_commit();
}
Beispiel #2
0
/*
 * ncurses_input_update()
 *
 * uaktualnia zmianê rozmiaru pola wpisywania tekstu -- przesuwa okienka
 * itd. je¶li zmieniono na pojedyncze, czy¶ci dane wej¶ciowe.
 */
void ncurses_input_update(int new_line_index)
{
	if (ncurses_input_size == 1) {
		g_strfreev((char **) ncurses_lines);
		ncurses_lines = NULL;
		ncurses_line = xmalloc(LINE_MAXLEN*sizeof(CHAR_T));

		ncurses_history[0] = ncurses_line;

	} else {
		ncurses_lines = xmalloc(2 * sizeof(CHAR_T *));
		ncurses_lines[0] = xmalloc(LINE_MAXLEN*sizeof(CHAR_T));
/*		ncurses_lines[1] = NULL; */
		xwcscpy(ncurses_lines[0], ncurses_line);
		xfree(ncurses_line);
		ncurses_line = ncurses_lines[0];
		ncurses_history[0] = NULL;
	}
	line_start = 0;
	line_index = new_line_index;
	lines_start = 0;
	lines_index = 0;

	ncurses_resize();

	ncurses_redraw(window_current);
	touchwin(ncurses_current->window);

	ncurses_commit();
}
Beispiel #3
0
void ncurses_contacts_changed(const char *name) {
	window_t *w = NULL;

	if (in_autoexec)
		return;

	if (!xstrcasecmp(name, "ncurses:contacts_size"))
		config_contacts = 1;

	if (config_contacts_size < 0) 
		config_contacts_size = 0;

	if (config_contacts_size == 0)
		config_contacts = 0;

	if (config_contacts_size > 1000)
		config_contacts_size = 1000;

	if (config_contacts_margin > 10)
		config_contacts_margin = 10;

	if (config_contacts_edge > 3)
		config_contacts_edge = 2;

	contacts_edge = (1 << config_contacts_edge);
	contacts_frame = (!config_contacts_frame ? 0
			: contacts_edge & (WF_LEFT|WF_RIGHT) ? contacts_edge ^ (WF_LEFT|WF_RIGHT)
			: contacts_edge ^ (WF_TOP|WF_BOTTOM));

	if (config_contacts_order) {
		strlcpy(contacts_order, config_contacts_order, sizeof(contacts_order));
		corderlen = xstrlen(contacts_order);
	} else {
		xstrcpy(contacts_order, CONTACTS_ORDER_DEFAULT);
		corderlen = CONTACTS_ORDER_DEFAULT_LEN;	/* xstrlen(CONTACTS_ORDER_DEFAULT) eq CONTACTS_ORDER_DEFAULT_LEN */
	}

	/* XXX destroy window only if (!config_contacts) ? XXX */
	if ((w = window_find_sa(NULL, "__contacts", 1))) {
		window_kill(w);
		w = NULL;
	}

	if (config_contacts /* && !w */) {
		w = window_new("__contacts", NULL, 1000);
		ncurses_contacts_update(w, 0);
	}

	ncurses_resize();
	ncurses_commit();
}
Beispiel #4
0
/*
 * wyswietla ponownie linie wprowadzenia tekstu		(prompt + aktualnie wpisany tekst)
 *	przy okazji jesli jest aspell to sprawdza czy tekst jest poprawny.
 */
void ncurses_redraw_input(unsigned int ch) {
	int x, y;
	/* draw prompt */
	werase(input);
	wmove(input, 0, 0);
	if (!ncurses_lines) {
		gchar *tmp = ekg_recode_to_locale(format_find(
					ncurses_current->prompt ? "ncurses_prompt_query" : "ncurses_prompt_none"));
		gchar *tmp2 = format_string(tmp, "\037"); /* unit separator */
		fstring_t *prompt_f = fstring_new(tmp2);
		gchar *s = prompt_f->str, *s2;
		fstr_attr_t *a = prompt_f->attr, *a2;
		g_free(tmp2);
		g_free(tmp);

		if (ncurses_current->prompt) {
				/* find our \037 */
			for (s2 = s, a2 = a; *s2 != '\037'; s2++, a2++)
				g_assert(*s2);
			*s2 = '\0'; /* and split the original string using it */
		}

		ncurses_fstring_print(input, s, a, -1);
		
		if (ncurses_current->prompt) {
			if (!ncurses_simple_print(input, ncurses_current->prompt,
						*a2, input->_maxx / 4)) {

					/* don't change colors or anything
					 * just disable bold to distinguish */
				wattroff(input, A_BOLD); /* XXX? */
				waddstr(input, ncurses_hellip);
			}
			s2++, a2++;
			ncurses_fstring_print(input, s2, a2, -1);
		}
		fstring_free(prompt_f);
	}
	getyx(input, y, x);
	ncurses_current->prompt_len = x;

	/* XXX: cleanup, optimize */
	{
		int cur_posx = -1, cur_posy = 0;
		const int width = input->_maxx - x;

		if ((line_index - line_start >= width) || (line_index - line_start < 2))
			line_start = line_index - width/2;
		if (line_start < 0)
			line_start = 0;

		ncurses_redraw_input_already_exec = 1;

		wattrset(input, color_pair(COLOR_WHITE, COLOR_BLACK));

		if (ncurses_lines) {
			int i, x;

			cur_posy = lines_index - lines_start;
			for (i = 0; i < MULTILINE_INPUT_SIZE; i++) {
				if (!ncurses_lines[lines_start + i])
					break;

				wmove(input, i, 0);
				x = ncurses_redraw_input_line(ncurses_lines[lines_start + i]);
				if (lines_index == (lines_start + i))
					cur_posx = x;
			}
			wattrset(input, color_pair(COLOR_BLACK, COLOR_BLACK) | A_BOLD);
			if (lines_start>0)
				mvwaddch(input, 0, input->_maxx, '^');
			if (g_strv_length((char **) ncurses_lines)-lines_start > MULTILINE_INPUT_SIZE)
				mvwaddch(input, MULTILINE_INPUT_SIZE-1, input->_maxx, 'v');
			wattrset(input, A_NORMAL);
		} else {
#if 0
			if (ncurses_noecho) {
				static char *funnything	= ncurses_funnything;

				waddch(input, ' ');		/* XXX why here? If you want to add space after propt, add it in theme */
				waddch(input, *funnything);
				wmove(input, 0, getcurx(input)-1);
				if (!*(++funnything))
					funnything = ncurses_funnything;
				return;
			}
#endif

			cur_posx = ncurses_redraw_input_line(ncurses_line);

		}
		/* this mut be here if we don't want 'timeout' after pressing ^C */
		if (ch == 3) ncurses_commit();
		if (cur_posx != -1) {
			wmove(input, cur_posy, cur_posx);
			curs_set(1);
		} else {
			wmove(input, 0, 0);	// XXX ???
			curs_set(0);
		}
	}
}