mirror of
https://github.com/weechat/weechat.git
synced 2026-07-10 03:33:12 +02:00
Improved window management: new window may have different size (% of current
window size), window sizes are automatically recomputed when term window is resized
This commit is contained in:
+167
-205
@@ -2800,7 +2800,7 @@ gui_window_init_subwindows (t_gui_window *window)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_split_horiz (t_gui_window *window)
|
||||
gui_window_split_horiz (t_gui_window *window, int pourcentage)
|
||||
{
|
||||
t_gui_window *new_window;
|
||||
int height1, height2;
|
||||
@@ -2808,24 +2808,32 @@ gui_window_split_horiz (t_gui_window *window)
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
height1 = window->win_height / 2;
|
||||
height1 = (window->win_height * pourcentage) / 100;
|
||||
height2 = window->win_height - height1;
|
||||
if ((new_window = gui_window_new (window->win_x, window->win_y,
|
||||
window->win_width, height1)))
|
||||
|
||||
if ((height1 >= WINDOW_MIN_HEIGHT) && (height2 >= WINDOW_MIN_HEIGHT)
|
||||
&& (pourcentage > 0) && (pourcentage <= 100))
|
||||
{
|
||||
/* reduce old window height (bottom window) */
|
||||
window->win_y = new_window->win_y + new_window->win_height;
|
||||
window->win_height = height2;
|
||||
|
||||
/* assign same buffer for new window (top window) */
|
||||
new_window->buffer = window->buffer;
|
||||
new_window->buffer->num_displayed++;
|
||||
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
|
||||
gui_current_window = new_window;
|
||||
gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
if ((new_window = gui_window_new (window,
|
||||
window->win_x, window->win_y,
|
||||
window->win_width, height1,
|
||||
100, pourcentage)))
|
||||
{
|
||||
/* reduce old window height (bottom window) */
|
||||
window->win_y = new_window->win_y + new_window->win_height;
|
||||
window->win_height = height2;
|
||||
window->win_height_pct = 100 - pourcentage;
|
||||
|
||||
/* assign same buffer for new window (top window) */
|
||||
new_window->buffer = window->buffer;
|
||||
new_window->buffer->num_displayed++;
|
||||
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
|
||||
gui_current_window = new_window;
|
||||
gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2834,7 +2842,7 @@ gui_window_split_horiz (t_gui_window *window)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_split_vertic (t_gui_window *window)
|
||||
gui_window_split_vertic (t_gui_window *window, int pourcentage)
|
||||
{
|
||||
t_gui_window *new_window;
|
||||
int width1, width2;
|
||||
@@ -2842,170 +2850,84 @@ gui_window_split_vertic (t_gui_window *window)
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
width1 = window->win_width / 2;
|
||||
width1 = (window->win_width * pourcentage) / 100;
|
||||
width2 = window->win_width - width1 - 1;
|
||||
if ((new_window = gui_window_new (window->win_x + width1 + 1, window->win_y,
|
||||
width2, window->win_height)))
|
||||
|
||||
if ((width1 >= WINDOW_MIN_WIDTH) && (width2 >= WINDOW_MIN_WIDTH)
|
||||
&& (pourcentage > 0) && (pourcentage <= 100))
|
||||
{
|
||||
/* reduce old window height (left window) */
|
||||
window->win_width = width1;
|
||||
if ((new_window = gui_window_new (window,
|
||||
window->win_x + width1 + 1, window->win_y,
|
||||
width2, window->win_height,
|
||||
pourcentage, 100)))
|
||||
{
|
||||
/* reduce old window height (left window) */
|
||||
window->win_width = width1;
|
||||
window->win_width_pct = 100 - pourcentage;
|
||||
|
||||
/* assign same buffer for new window (right window) */
|
||||
new_window->buffer = window->buffer;
|
||||
new_window->buffer->num_displayed++;
|
||||
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
|
||||
gui_current_window = new_window;
|
||||
gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
|
||||
/* create & draw separator */
|
||||
gui_draw_window_separator (gui_current_window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge: merge window with its sister
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_merge (t_gui_window *window)
|
||||
{
|
||||
t_gui_window_tree *parent, *sister;
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
sister = (parent->child1->window == window) ?
|
||||
parent->child2 : parent->child1;
|
||||
|
||||
/* assign same buffer for new window (right window) */
|
||||
new_window->buffer = window->buffer;
|
||||
new_window->buffer->num_displayed++;
|
||||
if (!(sister->window))
|
||||
return 0;
|
||||
|
||||
if (window->win_y == sister->window->win_y)
|
||||
{
|
||||
/* horizontal merge */
|
||||
window->win_width += sister->window->win_width + 1;
|
||||
window->win_width_pct += sister->window->win_width_pct;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* vertical merge */
|
||||
window->win_height += sister->window->win_height;
|
||||
window->win_height_pct += sister->window->win_height_pct;
|
||||
}
|
||||
if (sister->window->win_x < window->win_x)
|
||||
window->win_x = sister->window->win_x;
|
||||
if (sister->window->win_y < window->win_y)
|
||||
window->win_y = sister->window->win_y;
|
||||
|
||||
gui_window_free (sister->window);
|
||||
gui_window_tree_node_to_leaf (parent, window);
|
||||
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
|
||||
gui_current_window = new_window;
|
||||
gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
|
||||
/* create & draw separator */
|
||||
gui_draw_window_separator (gui_current_window);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge_down: merge window, direction down
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_merge_down (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win != window)
|
||||
{
|
||||
if ((ptr_win->win_y == window->win_y + window->win_height)
|
||||
&& (ptr_win->win_x == window->win_x)
|
||||
&& (ptr_win->win_width == window->win_width))
|
||||
{
|
||||
window->win_height += ptr_win->win_height;
|
||||
gui_window_free (ptr_win);
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no window found below current window */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge_up: merge window, direction up
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_merge_up (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win != window)
|
||||
{
|
||||
if ((ptr_win->win_y + ptr_win->win_height == window->win_y)
|
||||
&& (ptr_win->win_x == window->win_x)
|
||||
&& (ptr_win->win_width == window->win_width))
|
||||
{
|
||||
window->win_height += ptr_win->win_height;
|
||||
window->win_y -= ptr_win->win_height;
|
||||
gui_window_free (ptr_win);
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no window found above current window */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge_left: merge window, direction left
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_merge_left (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win != window)
|
||||
{
|
||||
if ((ptr_win->win_x + ptr_win->win_width + 1 == window->win_x)
|
||||
&& (ptr_win->win_y == window->win_y)
|
||||
&& (ptr_win->win_height == window->win_height))
|
||||
{
|
||||
window->win_width += ptr_win->win_width + 1;
|
||||
window->win_x -= ptr_win->win_width + 1;
|
||||
gui_window_free (ptr_win);
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no window found on the left of current window */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge_right: merge window, direction right
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_merge_right (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win != window)
|
||||
{
|
||||
if ((ptr_win->win_x == window->win_x + window->win_width + 1)
|
||||
&& (ptr_win->win_y == window->win_y)
|
||||
&& (ptr_win->win_height == window->win_height))
|
||||
{
|
||||
window->win_width += ptr_win->win_width + 1;
|
||||
gui_window_free (ptr_win);
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no window found on the right of current window */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge: merge a window, direction auto
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_merge_auto (t_gui_window *window)
|
||||
{
|
||||
if (gui_window_merge_down (window) == 0)
|
||||
return;
|
||||
if (gui_window_merge_up (window) == 0)
|
||||
return;
|
||||
if (gui_window_merge_left (window) == 0)
|
||||
return;
|
||||
if (gui_window_merge_right (window) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge_all: merge all windows
|
||||
* gui_window_merge_all: merge all windows into only one
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -3015,14 +2937,61 @@ gui_window_merge_all (t_gui_window *window)
|
||||
{
|
||||
gui_window_free ((gui_windows == window) ? gui_windows->next_window : gui_windows);
|
||||
}
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
gui_window_tree_init (window);
|
||||
window->ptr_tree = gui_windows_tree;
|
||||
window->win_x = 0;
|
||||
window->win_y = 0;
|
||||
window->win_width = COLS;
|
||||
window->win_height = LINES;
|
||||
window->win_width_pct = 100;
|
||||
window->win_height_pct = 100;
|
||||
gui_switch_to_buffer (window, window->buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_auto_resize: auto-resize all windows, according to % of global size
|
||||
* This function is called after a terminal resize.
|
||||
* Returns 0 if ok, -1 if all window should be merged
|
||||
* (not enough space according to windows %)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_auto_resize (t_gui_window_tree *tree,
|
||||
int x, int y, int width, int height)
|
||||
{
|
||||
int size1, size2;
|
||||
|
||||
if (tree)
|
||||
{
|
||||
if (tree->window)
|
||||
{
|
||||
tree->window->win_x = x;
|
||||
tree->window->win_y = y;
|
||||
tree->window->win_width = width;
|
||||
tree->window->win_height = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tree->split_horiz)
|
||||
{
|
||||
size1 = (height * tree->split_pct) / 100;
|
||||
size2 = height - size1;
|
||||
gui_window_auto_resize (tree->child1, x, y + size1, width, size2);
|
||||
gui_window_auto_resize (tree->child2, x, y, width, size1);
|
||||
}
|
||||
else
|
||||
{
|
||||
size1 = (width * tree->split_pct) / 100;
|
||||
size2 = width - size1 - 1;
|
||||
gui_window_auto_resize (tree->child1, x, y, size1, height);
|
||||
gui_window_auto_resize (tree->child2, x + size1 + 1, y, size2, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_refresh_screen: called when term size is modified
|
||||
*/
|
||||
@@ -3033,7 +3002,7 @@ gui_refresh_screen ()
|
||||
t_gui_window *ptr_win, *old_current_window;
|
||||
int old_width, old_height;
|
||||
int new_width, new_height;
|
||||
int merge_all_windows;
|
||||
int merge_all;
|
||||
|
||||
getmaxyx (stdscr, old_height, old_width);
|
||||
|
||||
@@ -3044,44 +3013,36 @@ gui_refresh_screen ()
|
||||
|
||||
old_current_window = gui_current_window;
|
||||
|
||||
gui_ok = ((new_width > 5) && (new_height > 5));
|
||||
gui_ok = ((new_width > WINDOW_MIN_WIDTH) && (new_height > WINDOW_MIN_HEIGHT));
|
||||
|
||||
merge_all_windows = 0;
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
if (gui_ok)
|
||||
{
|
||||
ptr_win->dcc_first = NULL;
|
||||
ptr_win->dcc_selected = NULL;
|
||||
gui_window_auto_resize (gui_windows_tree, 0, 0, COLS, LINES);
|
||||
|
||||
if (!merge_all_windows)
|
||||
merge_all = 0;
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((ptr_win->win_x > new_width - 5)
|
||||
|| (ptr_win->win_y > new_height - 5))
|
||||
merge_all_windows = 1;
|
||||
else
|
||||
if ((ptr_win->win_width < WINDOW_MIN_WIDTH)
|
||||
|| (ptr_win->win_height < WINDOW_MIN_HEIGHT))
|
||||
{
|
||||
if (ptr_win->win_x + ptr_win->win_width == old_width)
|
||||
ptr_win->win_width = new_width - ptr_win->win_x;
|
||||
if (ptr_win->win_y + ptr_win->win_height == old_height)
|
||||
ptr_win->win_height = new_height - ptr_win->win_y;
|
||||
if ((ptr_win->win_width < 5) || (ptr_win->win_height < 5))
|
||||
merge_all_windows = 1;
|
||||
merge_all = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (merge_all)
|
||||
gui_window_merge_all (gui_current_window);
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
gui_switch_to_buffer (ptr_win, ptr_win->buffer);
|
||||
gui_redraw_buffer (ptr_win->buffer);
|
||||
gui_draw_window_separator (ptr_win);
|
||||
}
|
||||
|
||||
gui_current_window = old_current_window;
|
||||
gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
if (merge_all_windows)
|
||||
gui_window_merge_all (gui_current_window);
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
gui_switch_to_buffer (ptr_win, ptr_win->buffer);
|
||||
gui_redraw_buffer (ptr_win->buffer);
|
||||
gui_draw_window_separator (ptr_win);
|
||||
}
|
||||
|
||||
gui_current_window = old_current_window;
|
||||
gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3265,7 +3226,7 @@ gui_init ()
|
||||
gui_input_clipboard = NULL;
|
||||
|
||||
/* create new window/buffer */
|
||||
if (gui_window_new (0, 0, COLS, LINES))
|
||||
if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
|
||||
{
|
||||
gui_current_window = gui_windows;
|
||||
gui_buffer_new (gui_windows, NULL, NULL, 0, 1);
|
||||
@@ -3316,6 +3277,7 @@ gui_end ()
|
||||
/* delete all windows */
|
||||
while (gui_windows)
|
||||
gui_window_free (gui_windows);
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
|
||||
/* delete global history */
|
||||
history_global_free ();
|
||||
|
||||
+131
-1
@@ -54,6 +54,8 @@ t_gui_window *gui_windows = NULL; /* pointer to first window */
|
||||
t_gui_window *last_gui_window = NULL; /* pointer to last window */
|
||||
t_gui_window *gui_current_window = NULL; /* pointer to current window */
|
||||
|
||||
t_gui_window_tree *gui_windows_tree = NULL; /* pointer to windows tree */
|
||||
|
||||
t_gui_buffer *gui_buffers = NULL; /* pointer to first buffer */
|
||||
t_gui_buffer *last_gui_buffer = NULL; /* pointer to last buffer */
|
||||
t_gui_buffer *buffer_before_dcc = NULL; /* buffer before dcc switch */
|
||||
@@ -61,25 +63,148 @@ t_gui_infobar *gui_infobar; /* pointer to infobar content */
|
||||
|
||||
char *gui_input_clipboard = NULL; /* clipboard content */
|
||||
|
||||
|
||||
/*
|
||||
* gui_window_tree_init: create first entry in windows tree
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_tree_init (t_gui_window *window)
|
||||
{
|
||||
gui_windows_tree = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
|
||||
if (!gui_windows_tree)
|
||||
return 0;
|
||||
gui_windows_tree->parent_node = NULL;
|
||||
gui_windows_tree->split_horiz = 0;
|
||||
gui_windows_tree->split_pct = 0;
|
||||
gui_windows_tree->child1 = NULL;
|
||||
gui_windows_tree->child2 = NULL;
|
||||
gui_windows_tree->window = window;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_tree_node_to_leaf: convert a node to a leaf (free any leafs)
|
||||
* Called when 2 windows are merging into one
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_tree_node_to_leaf (t_gui_window_tree *node, t_gui_window *window)
|
||||
{
|
||||
node->split_horiz = 0;
|
||||
node->split_pct = 0;
|
||||
if (node->child1)
|
||||
{
|
||||
free (node->child1);
|
||||
node->child1 = NULL;
|
||||
}
|
||||
if (node->child2)
|
||||
{
|
||||
free (node->child2);
|
||||
node->child2 = NULL;
|
||||
}
|
||||
node->window = window;
|
||||
window->ptr_tree = node;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_tree_free: delete entire windows tree
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_tree_free (t_gui_window_tree **tree)
|
||||
{
|
||||
if (*tree)
|
||||
{
|
||||
if ((*tree)->child1)
|
||||
gui_window_tree_free (&((*tree)->child1));
|
||||
if ((*tree)->child2)
|
||||
gui_window_tree_free (&((*tree)->child2));
|
||||
free (*tree);
|
||||
*tree = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_new: create a new window
|
||||
*/
|
||||
|
||||
t_gui_window *
|
||||
gui_window_new (int x, int y, int width, int height)
|
||||
gui_window_new (t_gui_window *parent, int x, int y, int width, int height,
|
||||
int width_pct, int height_pct)
|
||||
{
|
||||
t_gui_window *new_window;
|
||||
t_gui_window_tree *ptr_tree, *child1, *child2, *ptr_leaf;
|
||||
|
||||
#ifdef DEBUG
|
||||
wee_log_printf ("Creating new window (x:%d, y:%d, width:%d, height:%d)\n",
|
||||
x, y, width, height);
|
||||
#endif
|
||||
|
||||
if (parent)
|
||||
{
|
||||
child1 = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
|
||||
if (!child1)
|
||||
return NULL;
|
||||
child2 = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
|
||||
if (!child2)
|
||||
{
|
||||
free (child1);
|
||||
return NULL;
|
||||
}
|
||||
ptr_tree = parent->ptr_tree;
|
||||
|
||||
if (width_pct == 100)
|
||||
{
|
||||
ptr_tree->split_horiz = 1;
|
||||
ptr_tree->split_pct = height_pct;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_tree->split_horiz = 0;
|
||||
ptr_tree->split_pct = width_pct;
|
||||
}
|
||||
|
||||
/* parent window leaf becomes node and we add 2 leafs below
|
||||
(#1 is parent win, #2 is new win) */
|
||||
|
||||
parent->ptr_tree = child1;
|
||||
child1->parent_node = ptr_tree;
|
||||
child1->child1 = NULL;
|
||||
child1->child2 = NULL;
|
||||
child1->window = ptr_tree->window;
|
||||
|
||||
child2->parent_node = ptr_tree;
|
||||
child2->child1 = NULL;
|
||||
child2->child2 = NULL;
|
||||
child2->window = NULL; /* will be assigned by new window below */
|
||||
|
||||
ptr_tree->child1 = child1;
|
||||
ptr_tree->child2 = child2;
|
||||
ptr_tree->window = NULL; /* leaf becomes node */
|
||||
|
||||
ptr_leaf = child2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gui_window_tree_init (NULL))
|
||||
return NULL;
|
||||
ptr_leaf = gui_windows_tree;
|
||||
}
|
||||
|
||||
if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
|
||||
{
|
||||
new_window->win_x = x;
|
||||
new_window->win_y = y;
|
||||
new_window->win_width = width;
|
||||
new_window->win_height = height;
|
||||
new_window->win_width_pct = width_pct;
|
||||
new_window->win_height_pct = height_pct;
|
||||
|
||||
new_window->new_x = -1;
|
||||
new_window->new_y = -1;
|
||||
new_window->new_width = -1;
|
||||
new_window->new_height = -1;
|
||||
|
||||
new_window->win_chat_x = 0;
|
||||
new_window->win_chat_y = 0;
|
||||
@@ -120,6 +245,9 @@ gui_window_new (int x, int y, int width, int height)
|
||||
new_window->start_line = NULL;
|
||||
new_window->start_line_pos = 0;
|
||||
|
||||
new_window->ptr_tree = ptr_leaf;
|
||||
ptr_leaf->window = new_window;
|
||||
|
||||
/* add window to windows queue */
|
||||
new_window->prev_window = last_gui_window;
|
||||
if (gui_windows)
|
||||
@@ -1427,6 +1555,8 @@ gui_window_print_log (t_gui_window *window)
|
||||
wee_log_printf (" win_y . . . . . . . : %d\n", window->win_y);
|
||||
wee_log_printf (" win_width . . . . . : %d\n", window->win_width);
|
||||
wee_log_printf (" win_height. . . . . : %d\n", window->win_height);
|
||||
wee_log_printf (" win_width_pct . . . : %d\n", window->win_width_pct);
|
||||
wee_log_printf (" win_height_pct. . . : %d\n", window->win_height_pct);
|
||||
wee_log_printf (" win_chat_x. . . . . : %d\n", window->win_chat_x);
|
||||
wee_log_printf (" win_chat_y. . . . . : %d\n", window->win_chat_y);
|
||||
wee_log_printf (" win_chat_width. . . : %d\n", window->win_chat_width);
|
||||
|
||||
+33
-8
@@ -164,6 +164,9 @@ enum t_weechat_color
|
||||
#define gui_printf_nolog_notime(buffer, fmt, argz...) \
|
||||
gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, fmt, ##argz)
|
||||
|
||||
#define WINDOW_MIN_WIDTH 10
|
||||
#define WINDOW_MIN_HEIGHT 5
|
||||
|
||||
#define NOTIFY_LEVEL_MIN 0
|
||||
#define NOTIFY_LEVEL_MAX 3
|
||||
#define NOTIFY_LEVEL_DEFAULT NOTIFY_LEVEL_MAX
|
||||
@@ -261,6 +264,7 @@ struct t_gui_buffer
|
||||
t_gui_buffer *next_buffer; /* link to next buffer */
|
||||
};
|
||||
|
||||
typedef struct t_gui_window_tree t_gui_window_tree;
|
||||
typedef struct t_gui_window t_gui_window;
|
||||
|
||||
struct t_gui_window
|
||||
@@ -268,6 +272,11 @@ struct t_gui_window
|
||||
/* global position & size */
|
||||
int win_x, win_y; /* position of window */
|
||||
int win_width, win_height; /* window geometry */
|
||||
int win_width_pct; /* % of width (compared to term size) */
|
||||
int win_height_pct; /* % of height (compared to term size) */
|
||||
|
||||
int new_x, new_y; /* used for computing new position */
|
||||
int new_width, new_height; /* used for computing new size */
|
||||
|
||||
/* chat window settings */
|
||||
int win_chat_x, win_chat_y; /* chat window position */
|
||||
@@ -320,10 +329,26 @@ struct t_gui_window
|
||||
t_gui_line *start_line; /* pointer to line if scrolling */
|
||||
int start_line_pos; /* position in first line displayed */
|
||||
|
||||
t_gui_window_tree *ptr_tree; /* pointer to leaf in windows tree */
|
||||
|
||||
t_gui_window *prev_window; /* link to previous window */
|
||||
t_gui_window *next_window; /* link to next window */
|
||||
};
|
||||
|
||||
struct t_gui_window_tree
|
||||
{
|
||||
t_gui_window_tree *parent_node; /* pointer to parent node */
|
||||
|
||||
/* node info */
|
||||
int split_horiz; /* 1 if horizontal, 0 if vertical */
|
||||
int split_pct; /* % of split size (represents child1) */
|
||||
t_gui_window_tree *child1; /* first child, NULL if a leaf */
|
||||
t_gui_window_tree *child2; /* second child, NULL if a leaf */
|
||||
|
||||
/* leaf info */
|
||||
t_gui_window *window; /* pointer to window, NULL if a node */
|
||||
};
|
||||
|
||||
typedef struct t_gui_key t_gui_key;
|
||||
|
||||
struct t_gui_key
|
||||
@@ -353,6 +378,7 @@ extern int gui_add_hotlist;
|
||||
extern t_gui_window *gui_windows;
|
||||
extern t_gui_window *last_gui_window;
|
||||
extern t_gui_window *gui_current_window;
|
||||
extern t_gui_window_tree *gui_windows_tree;
|
||||
extern t_gui_buffer *gui_buffers;
|
||||
extern t_gui_buffer *last_gui_buffer;
|
||||
extern t_gui_buffer *buffer_before_dcc;
|
||||
@@ -369,7 +395,10 @@ extern t_gui_color *gui_color[NUM_COLORS];
|
||||
|
||||
/* GUI independent functions: windows & buffers */
|
||||
|
||||
extern t_gui_window *gui_window_new (int, int, int, int);
|
||||
extern int gui_window_tree_init (t_gui_window *);
|
||||
extern void gui_window_tree_node_to_leaf (t_gui_window_tree *, t_gui_window *);
|
||||
extern void gui_window_tree_free (t_gui_window_tree **);
|
||||
extern t_gui_window *gui_window_new (t_gui_window *, int, int, int, int, int, int);
|
||||
extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int);
|
||||
extern void gui_buffer_clear (t_gui_buffer *);
|
||||
extern void gui_buffer_clear_all ();
|
||||
@@ -480,13 +509,9 @@ extern void gui_window_nick_end (t_gui_window *);
|
||||
extern void gui_window_nick_page_up (t_gui_window *);
|
||||
extern void gui_window_nick_page_down (t_gui_window *);
|
||||
extern void gui_window_init_subwindows (t_gui_window *);
|
||||
extern void gui_window_split_horiz (t_gui_window *);
|
||||
extern void gui_window_split_vertic (t_gui_window *);
|
||||
extern int gui_window_merge_up (t_gui_window *);
|
||||
extern int gui_window_merge_down (t_gui_window *);
|
||||
extern int gui_window_merge_left (t_gui_window *);
|
||||
extern int gui_window_merge_right (t_gui_window *);
|
||||
extern void gui_window_merge_auto (t_gui_window *);
|
||||
extern void gui_window_split_horiz (t_gui_window *, int);
|
||||
extern void gui_window_split_vertic (t_gui_window *, int);
|
||||
extern int gui_window_merge (t_gui_window *);
|
||||
extern void gui_window_merge_all (t_gui_window *);
|
||||
extern void gui_refresh_screen ();
|
||||
extern void gui_pre_init (int *, char **[]);
|
||||
|
||||
Reference in New Issue
Block a user