Beispiel #1
0
/** Handle resizing of the terminal.
    @return A boolean indicating success of the resizing operation, which depends on
		memory allocation success.

    Should be called after a @c SIGWINCH. Retrieves the size of the terminal and
    resizes the backing structures. After calling ::t3_term_resize,
    ::t3_term_get_size can be called to retrieve the new terminal size.
*/
t3_bool t3_term_resize(void) {
#ifdef HAS_WINSIZE_IOCTL
	struct winsize wsz;

	if (ioctl(_t3_terminal_out_fd, TIOCGWINSZ, &wsz) < 0)
		return t3_true;

	_t3_lines = wsz.ws_row;
	_t3_columns = wsz.ws_col;

	if (_t3_columns == _t3_terminal_window->width && _t3_lines == _t3_terminal_window->height)
		return t3_true;

	if (_t3_columns < _t3_terminal_window->width || _t3_lines != _t3_terminal_window->height) {
		/* Clear the cache of the terminal contents and the actual terminal. This
		   is necessary because shrinking the terminal tends to cause all kinds of
		   weird corruption of the on screen state. */
		t3_term_redraw();
	}

	return t3_win_resize(_t3_terminal_window, _t3_lines, _t3_columns);
#else
	return t3_true;
#endif
}
Beispiel #2
0
int main(int argc, char *argv[]) {
  t3_window_t *low, *high, *sub;

  (void)argc;
  (void)argv;
  setlocale(LC_ALL, "");

  printf("Waiting for enter to allow debug\n");
  getchar();

  ASSERT(t3_term_init(-1, NULL) == T3_ERR_SUCCESS);
  atexit(t3_term_restore);
  inited = t3_true;

  t3_term_hide_cursor();
  ASSERT(low = t3_win_new(NULL, 10, 10, 0, 5, 10));
  ASSERT(high = t3_win_new(NULL, 10, 10, 5, 10, 0));
  t3_win_show(low);
  /* 	t3_term_update();
          get_keychar(); */

  t3_win_set_paint(low, 0, 0);
  t3_win_addstr(low, "0123456789-", 0);
  t3_win_set_paint(low, 6, 0);
  t3_win_addstr(low, "abQc̃defghijk", 0);
  /* 	t3_term_update();
          get_keychar(); */

  t3_term_show_cursor();
  t3_win_set_cursor(low, 0, 0);
  t3_win_show(high);
  /* 	t3_term_update();
          get_keychar();
   */
  t3_win_set_paint(high, 0, 0);
  t3_win_addstr(high, "ABCDEFGHIJK", 0);
  /* 	t3_term_update();
          get_keychar();
   */
  t3_win_set_paint(high, 1, 0);
  t3_win_addstr(high, "9876543210+", T3_ATTR_REVERSE | T3_ATTR_FG_RED);
  t3_win_set_paint(high, 2, 0);
  t3_win_addstr(high, "wutvlkmjqx", T3_ATTR_ACS);

  t3_term_set_user_callback(callback);
  t3_win_set_paint(high, 3, 0);
  t3_win_addstr(high, "f", T3_ATTR_USER);
  /* 	t3_term_update();
          get_keychar(); */

  t3_win_hide(high);
  /* 	t3_term_update();
          get_keychar(); */

  t3_win_move(high, 5, 0);
  t3_win_resize(high, 10, 8);
  t3_win_show(high);
  /* 	t3_term_update();
          get_keychar(); */

  t3_win_hide(high);
  /* 	t3_term_update();
          get_keychar(); */

  t3_win_box(low, 0, 0, 10, 10, T3_ATTR_REVERSE);
  /* 	t3_term_update();
          get_keychar(); */

  t3_win_hide(low);
  //~ t3_win_show(high);
  /* 	t3_term_update();
          get_keychar(); */

  ASSERT(sub = t3_win_new(low, 1, 20, 1, -6, -3));

  t3_win_set_paint(sub, 0, 2);
  t3_win_set_default_attrs(sub, T3_ATTR_REVERSE);
  t3_win_addstr(sub, "abcQabcQabcQ", 0);
  t3_win_show(sub);
  t3_term_update();
  get_keychar();

  t3_win_show(low);
  t3_term_update();
  get_keychar();

  return 0;
}
Beispiel #3
0
static int test(void) {
	t3_window_t *low, *high, *sub;

	t3_term_hide_cursor();
	ASSERT(low = t3_win_new(NULL, 10, 10, 0, 5, 10));
	ASSERT(high = t3_win_new(NULL, 10, 10, 5, 10, 0));
	t3_win_show(low);
	next();

	t3_win_set_paint(low, 0, 0);
	t3_win_addstr(low, "0123456789-", 0);
	t3_win_set_paint(low, 6, 0);
	t3_win_addstr(low, "abQc̃defghijk", 0);
	next();

	t3_term_show_cursor();
	t3_win_set_cursor(low, 0, 0);
	t3_win_show(high);
	next();

	t3_win_set_paint(high, 0, 0);
	t3_win_addstr(high, "ABCDEFGHIJK", 0);
	next();

	t3_win_set_paint(high, 1, 0);
	t3_win_addstr(high, "9876543210+", T3_ATTR_REVERSE | T3_ATTR_FG_RED);
	t3_win_set_paint(high, 2, 0);
	t3_win_addstr(high, "wutvlkmjqx", T3_ATTR_ACS);

	t3_term_set_user_callback(callback);
	t3_win_set_paint(high, 3, 0);
	t3_win_addstr(high, "f", T3_ATTR_USER);
	next();

	t3_win_hide(high);
	next();

	t3_win_move(high, 5, 0);
	t3_win_resize(high, 10, 8);
	t3_win_show(high);
	next();

	t3_win_hide(high);
	next();

	t3_win_box(low, 0, 0, 10, 10, T3_ATTR_REVERSE);
	next();

	t3_win_hide(low);
	next();

	//~ ASSERT(sub = t3_win_new(low, 1, 20, 1, -6, -3));
	ASSERT(sub = t3_win_new(low, 1, 20, 1, -6, -3));

	t3_win_set_paint(sub, 0, 2);
	t3_win_set_default_attrs(sub, T3_ATTR_REVERSE);
	t3_win_addstr(sub, "abcQabcQabcQ", 0);
	t3_win_show(sub);
	next();

	t3_win_show(low);
	next();

	return 0;
}