Exemplo n.º 1
0
/* SYNTAX: WINDOW MOVE <number>|left|right */
static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
	int new_refnum, refnum;

	if (!is_numeric(data, 0)) {
		command_runsub("window move", data, server, item);
                return;
	}

	new_refnum = atoi(data);
	if (new_refnum > active_win->refnum) {
		for (;;) {
			refnum = window_refnum_next(active_win->refnum, FALSE);
			if (refnum == -1 || refnum > new_refnum)
				break;

			window_set_refnum(active_win, refnum);
		}
	} else {
		for (;;) {
			refnum = window_refnum_prev(active_win->refnum, FALSE);
			if (refnum == -1 || refnum < new_refnum)
				break;

			window_set_refnum(active_win, refnum);
		}
	}
}
Exemplo n.º 2
0
/* we're moving the last window to first - make some space so we can use the
   refnum 1 */
static void window_refnums_move_right(WINDOW_REC *move_window)
{
	WINDOW_REC *window;
	int refnum, new_refnum;

        new_refnum = 1;
	if (window_find_refnum(new_refnum) == NULL) {
		window_set_refnum(move_window, new_refnum);
                return;
	}

	/* find the first unused refnum, like if there's windows
	   1..5 and 7..10, we only need to move 1..5 to 2..6 */
	refnum = new_refnum;
	while (move_window->refnum == refnum ||
	       window_find_refnum(refnum) != NULL) refnum++;
	refnum--;

	while (refnum >= new_refnum) {
		window = window_find_refnum(refnum);
		window_set_refnum(window, refnum+1);

		refnum--;
	}

	window_set_refnum(move_window, new_refnum);
}
Exemplo n.º 3
0
/* we're moving the first window to last - move the first contiguous block
   of refnums to left. Like if there's windows 1..5 and 7..10, move 1 to
   11, 2..5 to 1..4 and leave 7..10 alone  */
static void windows_move_left(WINDOW_REC *move_window)
{
	WINDOW_REC *window;
	int refnum;

	window_set_refnum(move_window, windows_refnum_last()+1);
	for (refnum = 2;; refnum++) {
		window = window_find_refnum(refnum);
		if (window == NULL) break;

		window_set_refnum(window, refnum-1);
	}
}
Exemplo n.º 4
0
/* SYNTAX: WINDOW NUMBER [-sticky] <number> */
static void cmd_window_number(const char *data)
{
	GHashTable *optlist;
        char *refnum;
	void *free_arg;
        int num;

	if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
			    "window number", &optlist, &refnum))
		return;

	if (*refnum == '\0')
		cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);

	num = atoi(refnum);
	if (num < 1) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_REFNUM_TOO_LOW);
	} else {
		window_set_refnum(active_win, num);
		active_win->sticky_refnum =
			g_hash_table_lookup(optlist, "sticky") != NULL;
	}

        cmd_params_free(free_arg);
}
Exemplo n.º 5
0
static void sig_layout_restore(void)
{
	WINDOW_REC *window;
	CONFIG_NODE *node;
	GSList *tmp;

	node = iconfig_node_traverse("windows", FALSE);
	if (node == NULL) return;

	tmp = config_node_first(node->value);
	for (; tmp != NULL; tmp = config_node_next(tmp)) {
		CONFIG_NODE *node = tmp->data;

		window = window_find_refnum(atoi(node->key));
		if (window == NULL)
			window = window_create(NULL, TRUE);

		window_set_refnum(window, atoi(node->key));
                window->sticky_refnum = config_node_get_bool(node, "sticky_refnum", FALSE);
                window->immortal = config_node_get_bool(node, "immortal", FALSE);
		window_set_name(window, config_node_get_str(node, "name", NULL));
		window_set_history(window, config_node_get_str(node, "history_name", NULL));
		window_set_level(window, level2bits(config_node_get_str(node, "level", "")));

		window->servertag = g_strdup(config_node_get_str(node, "servertag", NULL));
		window->theme_name = g_strdup(config_node_get_str(node, "theme", NULL));
		if (window->theme_name != NULL)
			window->theme = theme_load(window->theme_name);

		window_add_items(window, config_node_section(node, "items", -1));
		signal_emit("layout restore window", 2, window, node);
	}
}
Exemplo n.º 6
0
void windows_layout_restore(void)
{
	WINDOW_REC *window;
	CONFIG_NODE *node;
	GSList *tmp;

	node = iconfig_node_traverse("windows", FALSE);
	if (node == NULL) return;

	for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
		CONFIG_NODE *node = tmp->data;

		window = window_create(NULL, TRUE);
		window_set_refnum(window, atoi(node->key));
                window->sticky_refnum = config_node_get_bool(node, "sticky_refnum", FALSE);
		window_set_name(window, config_node_get_str(node, "name", NULL));
		window_set_level(window, level2bits(config_node_get_str(node, "level", "")));

		window->servertag = g_strdup(config_node_get_str(node, "servertag", NULL));
		window->theme_name = g_strdup(config_node_get_str(node, "theme", NULL));
		if (window->theme_name != NULL)
			window->theme = theme_load(window->theme_name);

		window_add_items(window, config_node_section(node, "items", -1));
		signal_emit("window restore", 2, window, node);
	}

	signal_emit("windows restored", 0);
}
Exemplo n.º 7
0
/* SYNTAX: WINDOW MOVE LEFT */
static void cmd_window_move_left(void)
{
	int refnum;

	refnum = window_refnum_left(active_win->refnum, TRUE);
	if (refnum != -1)
		window_set_refnum(active_win, refnum);
}
Exemplo n.º 8
0
static void create_windows(void)
{
	WINDOW_REC *window;
	int have_status = settings_get_bool("use_status_window");

	window = window_find_name("(status)");
	if (have_status) {
		if (window == NULL) {
			window = window_create(NULL, TRUE);
			window_set_refnum(window, 1);
			window_set_name(window, "(status)");
			window_set_level(window, MSGLEVEL_ALL ^
					 (settings_get_bool("use_msgs_window") ?
					  MSGS_WINDOW_LEVELS : 0));
			window_set_immortal(window, TRUE);
		}
	} else {
		if (window != NULL) {
			window_set_name(window, NULL);
			window_set_level(window, 0);
			window_set_immortal(window, FALSE);
		}
	}

	window = window_find_name("(msgs)");
	if (settings_get_bool("use_msgs_window")) {
		if (window == NULL) {
			window = window_create(NULL, TRUE);
			window_set_refnum(window, have_status ? 2 : 1);
			window_set_name(window, "(msgs)");
			window_set_level(window, MSGS_WINDOW_LEVELS);
			window_set_immortal(window, TRUE);
		}
	} else {
		if (window != NULL) {
			window_set_name(window, NULL);
			window_set_level(window, 0);
			window_set_immortal(window, FALSE);
		}
	}

	if (windows == NULL) {
		/* we have to have at least one window.. */
                window = window_create(NULL, TRUE);
	}
}
Exemplo n.º 9
0
/* we're moving the first window to last - move the first contiguous block
   of refnums to left. Like if there's windows 1..5 and 7..10, move 1 to
   11, 2..5 to 1..4 and leave 7..10 alone */
static void window_refnums_move_left(WINDOW_REC *move_window)
{
	WINDOW_REC *window;
	int refnum, new_refnum;

        new_refnum = windows_refnum_last();
	for (refnum = move_window->refnum+1; refnum <= new_refnum; refnum++) {
		window = window_find_refnum(refnum);
		if (window == NULL) {
                        new_refnum++;
			break;
		}

		window_set_refnum(window, refnum-1);
	}

	window_set_refnum(move_window, new_refnum);
}
Exemplo n.º 10
0
/* SYNTAX: WINDOW NUMBER <number> */
static void cmd_window_number(const char *data)
{
	int num;

	num = atoi(data);
	if (num < 1)
		printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_REFNUM_TOO_LOW);
	else
		window_set_refnum(active_win, num);
}
Exemplo n.º 11
0
/* SYNTAX: WINDOW MOVE NEXT */
static void cmd_window_move_next(void)
{
	int refnum;

	refnum = window_refnum_next(active_win->refnum, FALSE);
	if (refnum != -1) {
		window_set_refnum(active_win, refnum);
		return;
	}

        window_refnums_move_right(active_win);
}
Exemplo n.º 12
0
/* removed_refnum was removed from the windows list, pack the windows so
   there won't be any holes. If there is any holes after removed_refnum,
   leave the windows behind it alone. */
static void windows_pack(int removed_refnum)
{
	WINDOW_REC *window;
	int refnum;

	for (refnum = removed_refnum+1;; refnum++) {
		window = window_find_refnum(refnum);
		if (window == NULL) break;

		window_set_refnum(window, refnum-1);
	}
}
Exemplo n.º 13
0
static void cmd_window_move_left(void)
{
	int refnum;

	refnum = window_refnum_prev(active_win->refnum, TRUE);
	if (refnum != -1) {
		window_set_refnum(active_win, refnum);
		return;
	}

	windows_move_left(active_win);
}
Exemplo n.º 14
0
static void active_window_move_to(int new_refnum)
{
	int refnum;

	if (new_refnum > active_win->refnum) {
		for (;;) {
			refnum = window_refnum_next(active_win->refnum, FALSE);
			if (refnum == -1 || refnum > new_refnum)
				break;

			window_set_refnum(active_win, refnum);
		}
	} else {
		for (;;) {
			refnum = window_refnum_prev(active_win->refnum, FALSE);
			if (refnum == -1 || refnum < new_refnum)
				break;

			window_set_refnum(active_win, refnum);
		}
	}
}
Exemplo n.º 15
0
/* we're moving the last window to first - make some space so we can use the
   refnum 1 */
static void windows_move_right(WINDOW_REC *move_window)
{
	WINDOW_REC *window;
	int refnum;

	/* find the first unused refnum, like if there's windows
	   1..5 and 7..10, we only need to move 1..5 to 2..6 */
	refnum = 1;
	while (window_find_refnum(refnum) != NULL) refnum++;

	refnum--;
	while (refnum > 0) {
		window = window_find_refnum(refnum);
		g_return_if_fail(window != NULL);
		window_set_refnum(window, window == move_window ? 1 : refnum+1);

		refnum--;
	}
}