mirror of
https://github.com/tmux/tmux.git
synced 2026-06-24 06:27:44 +00:00
Rewrite screen-redraw.c to make it tidier and more maintainable. A scene
is generated and cached in the client: it holds positions and sizes of panes, borders and so on. The scene is invalidated when a pane is moved or resized or relevant option is changed. This scene is then drawn to the client as needed and text and colours are filled in. With Michael Grant.
This commit is contained in:
29
layout.c
29
layout.c
@@ -405,7 +405,8 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
|
||||
struct window_pane *wp;
|
||||
struct layout_cell *lc;
|
||||
int status, scrollbars, sb_pos, sb_w, sb_pad;
|
||||
u_int sx, sy;
|
||||
int old_xoff, old_yoff, changed = 0;
|
||||
u_int sx, sy, old_sx, old_sy;
|
||||
|
||||
status = window_get_pane_status(w);
|
||||
scrollbars = options_get_number(w->options, "pane-scrollbars");
|
||||
@@ -415,6 +416,11 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
|
||||
if ((lc = wp->layout_cell) == NULL || wp == skip)
|
||||
continue;
|
||||
|
||||
old_xoff = wp->xoff;
|
||||
old_yoff = wp->yoff;
|
||||
old_sx = wp->sx;
|
||||
old_sy = wp->sy;
|
||||
|
||||
wp->xoff = lc->xoff;
|
||||
wp->yoff = lc->yoff;
|
||||
sx = lc->sx;
|
||||
@@ -452,7 +458,15 @@ layout_fix_panes(struct window *w, struct window_pane *skip)
|
||||
}
|
||||
|
||||
window_pane_resize(wp, sx, sy);
|
||||
|
||||
if (wp->xoff != old_xoff ||
|
||||
wp->yoff != old_yoff ||
|
||||
wp->sx != old_sx ||
|
||||
wp->sy != old_sy)
|
||||
changed = 1;
|
||||
}
|
||||
if (changed)
|
||||
redraw_invalidate_scene(w);
|
||||
}
|
||||
|
||||
/* Count the number of available cells in a layout. */
|
||||
@@ -818,10 +832,16 @@ layout_resize_floating_pane_to(struct window_pane *wp, enum layout_type type,
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == LAYOUT_TOPBOTTOM)
|
||||
if (type == LAYOUT_TOPBOTTOM) {
|
||||
if (lc->sy == size)
|
||||
return;
|
||||
lc->sy = size;
|
||||
else
|
||||
} else {
|
||||
if (lc->sx == size)
|
||||
return;
|
||||
lc->sx = size;
|
||||
}
|
||||
redraw_invalidate_scene(wp->window);
|
||||
}
|
||||
|
||||
/* Resize a floating pane relative to its current size. */
|
||||
@@ -836,6 +856,8 @@ layout_resize_floating_pane(struct window_pane *wp, enum layout_type type,
|
||||
*cause = xstrdup("pane is not floating");
|
||||
return;
|
||||
}
|
||||
if (change == 0)
|
||||
return;
|
||||
|
||||
if (type == LAYOUT_TOPBOTTOM) {
|
||||
size = lc->sy + change;
|
||||
@@ -856,6 +878,7 @@ layout_resize_floating_pane(struct window_pane *wp, enum layout_type type,
|
||||
if (opposite)
|
||||
lc->xoff -= change;
|
||||
}
|
||||
redraw_invalidate_scene(wp->window);
|
||||
}
|
||||
|
||||
/* Resize a layout cell. */
|
||||
|
||||
Reference in New Issue
Block a user