Exemple #1
0
static VALUE ruby_print_window(int argc, VALUE *argv, VALUE self) {
#if 0
	window_t *w = NULL;
	char *args[9] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
	int i;

	if (type(argv[0]) == T_FIXNUM) {	/* id of window. */
		if (argc < 1 || argv > 10) {
			rb_raise(rb_eArgError, "print_window(): accepts 1-10 params, but %d given", argc);
			return Qnil;
		}

		if (!(w = window_exist(FIX2INT(argv[0])))) {
			rb_raise(rb_eIndexError, "print_window(): window_exist(%d) failed\n", FIX2INT(argv[0]));
			return Qnil;
		}

	} else if (TYPE(argv[0]) == T_STRING) {	/* target */

		if (TYPE(argv[1]) == T_STRING) 


	}

	if (TYPE(obj) == T_STRING)	query_name = RSTRING(argv[0])->ptr;
	else if (TYPE(obj) == T_FIXNUM); /* XXX ? */

	Check_Type(argv[0], T_STRING);

	for (i = 1; i < argc; i++) {
		Check_Type(argv[i], T_STRING);
		args[i-1] = RSTRING(argv[i])->ptr;
	}

	tmp = str = xstrdup(RSTRING(argv[0])->ptr);

	while ((line = split_line(&str))) {
		char *tmp = format_string(line);
		window_print(window_exist(dest), fstring_new(tmp));
		xfree(tmp);
	}
	xfree(tmp);
#endif
	return Qnil;
}
Exemple #2
0
/*
 * backlog_split()
 *
 * dzieli linie tekstu w buforze na linie ekranowe.
 *
 *  - w - okno do podzielenia
 *
 * XXX function uses n->x0, y0, width, height !!! call calc_window_dimension(). !!!
 */
static int backlog_split(window_t *w, backlog_line_t *b, gboolean show, int y) {
	ncurses_window_t *n = w->priv_data;
	int rows_count = 0;
	/* timestamp */
	int ts_width		= 0;
	gchar *ts_str		= NULL;
	fstr_attr_t *ts_attr	= NULL;
	/* prompt */
	int prompt_width	= b->line->prompt_empty ? 0 : xmbswidth(b->line->str, b->line->prompt_len);
	/* text */
	char *str		= b->line->str  + b->line->prompt_len;
	fstr_attr_t *attr	= b->line->attr + b->line->prompt_len;

	/* set timestamp */
	if (b->line->ts && formated_config_timestamp && config_timestamp_show &&
	    (!w->floating || w->id == WINDOW_LASTLOG_ID))
	{
		fstring_t *s = fstring_new(timestamp_time(formated_config_timestamp, b->line->ts));
		ts_str	 = s->str;
		ts_attr	 = s->attr;
		xfree(s);
		ts_width = xmbswidth(ts_str, xstrlen(ts_str));
	}

	while (*str || rows_count==0) {
		int len, last_space = 0;
		int width = n->width - prompt_width;

		if ((rows_count==0) || !(config_display_indent==1 && prompt_width==0))
			width -= ts_width;

		len = wrap_line(w, width, str, attr, &last_space);

		if (show && (0 <= y && y < n->height)) {
			wmove(n->window, n->y0 + y, n->x0);

			if (ts_width && ((config_display_indent==0) || (rows_count==0))) {
				ncurses_fstring_print_fast(n->window, ts_str, ts_attr, -1);
			} else if (config_display_indent==2 || prompt_width)
				wmove(n->window, n->y0 + y, n->x0 + ts_width);

			if (prompt_width)	/* print prompt */
				ncurses_fstring_print_fast(n->window, b->line->str, b->line->attr, b->line->prompt_len);

			if (width > 0)		/* print text */
				ncurses_fstring_print_fast(n->window, str, attr, len);
		}

		rows_count++;

		if (w->nowrap)
			break;

		str	+= len + last_space;
		attr	+= len + last_space;
		y++;
	}

	if (show && (n->marker == b) && (0 <= y && y < n->height))
		draw_thin_red_line(w, n->y0 + y);

	xfree(ts_str);
	xfree(ts_attr);

	return rows_count;
}
Exemple #3
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);
		}
	}
}