mirror of
https://github.com/tmux/tmux.git
synced 2024-11-10 13:48:48 +00:00
Break up and simplify screen_redraw_screen.
This commit is contained in:
parent
72d1be5ddd
commit
9f02feb9d0
147
screen-redraw.c
147
screen-redraw.c
@ -29,6 +29,9 @@ int screen_redraw_check_cell(struct client *, u_int, u_int,
|
|||||||
int screen_redraw_check_active(u_int, u_int, int, struct window *,
|
int screen_redraw_check_active(u_int, u_int, int, struct window *,
|
||||||
struct window_pane *);
|
struct window_pane *);
|
||||||
|
|
||||||
|
void screen_redraw_draw_borders(struct client *, int, u_int);
|
||||||
|
void screen_redraw_draw_panes(struct client *, u_int);
|
||||||
|
void screen_redraw_draw_status(struct client *, u_int);
|
||||||
void screen_redraw_draw_number(struct client *, struct window_pane *);
|
void screen_redraw_draw_number(struct client *, struct window_pane *);
|
||||||
|
|
||||||
#define CELL_INSIDE 0
|
#define CELL_INSIDE 0
|
||||||
@ -216,14 +219,12 @@ screen_redraw_check_active(u_int px, u_int py, int type, struct window *w,
|
|||||||
|
|
||||||
/* Redraw entire screen. */
|
/* Redraw entire screen. */
|
||||||
void
|
void
|
||||||
screen_redraw_screen(struct client *c, int status_only, int borders_only)
|
screen_redraw_screen(struct client *c, int draw_panes, int draw_status,
|
||||||
|
int draw_borders)
|
||||||
{
|
{
|
||||||
struct window *w = c->session->curw->window;
|
|
||||||
struct options *oo = &c->session->options;
|
struct options *oo = &c->session->options;
|
||||||
struct tty *tty = &c->tty;
|
struct tty *tty = &c->tty;
|
||||||
struct window_pane *wp;
|
u_int top;
|
||||||
struct grid_cell active_gc, other_gc;
|
|
||||||
u_int i, j, type, top;
|
|
||||||
int status, spos;
|
int status, spos;
|
||||||
|
|
||||||
/* Suspended clients should not be updated. */
|
/* Suspended clients should not be updated. */
|
||||||
@ -239,72 +240,15 @@ screen_redraw_screen(struct client *c, int status_only, int borders_only)
|
|||||||
top = 0;
|
top = 0;
|
||||||
if (status && spos == 0)
|
if (status && spos == 0)
|
||||||
top = 1;
|
top = 1;
|
||||||
|
if (!status)
|
||||||
|
draw_status = 0;
|
||||||
|
|
||||||
/* If only drawing status and it is present, don't need the rest. */
|
if (draw_borders)
|
||||||
if (status_only && status) {
|
screen_redraw_draw_borders(c, status, top);
|
||||||
if (top)
|
if (draw_panes)
|
||||||
tty_draw_line(tty, &c->status, 0, 0, 0);
|
screen_redraw_draw_panes(c, top);
|
||||||
else
|
if (draw_status)
|
||||||
tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
|
screen_redraw_draw_status(c, top);
|
||||||
tty_reset(tty);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set up pane border attributes. */
|
|
||||||
style_apply(&other_gc, oo, "pane-border-style");
|
|
||||||
style_apply(&active_gc, oo, "pane-active-border-style");
|
|
||||||
active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET; /* nuke existing */
|
|
||||||
|
|
||||||
/* Draw background and borders. */
|
|
||||||
for (j = 0; j < tty->sy - status; j++) {
|
|
||||||
if (status_only) {
|
|
||||||
if (spos == 1 && j != tty->sy - 1)
|
|
||||||
continue;
|
|
||||||
else if (spos == 0 && j != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
for (i = 0; i < tty->sx; i++) {
|
|
||||||
type = screen_redraw_check_cell(c, i, j, &wp);
|
|
||||||
if (type == CELL_INSIDE)
|
|
||||||
continue;
|
|
||||||
if (screen_redraw_check_active(i, j, type, w, wp))
|
|
||||||
tty_attributes(tty, &active_gc);
|
|
||||||
else
|
|
||||||
tty_attributes(tty, &other_gc);
|
|
||||||
tty_cursor(tty, i, top + j);
|
|
||||||
tty_putc(tty, CELL_BORDERS[type]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If only drawing borders, that's it. */
|
|
||||||
if (borders_only)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Draw the panes, if necessary. */
|
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
|
||||||
if (!window_pane_visible(wp))
|
|
||||||
continue;
|
|
||||||
for (i = 0; i < wp->sy; i++) {
|
|
||||||
if (status_only) {
|
|
||||||
if (spos == 1 && wp->yoff + i != tty->sy - 1)
|
|
||||||
continue;
|
|
||||||
else if (spos == 0 && wp->yoff + i != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tty_draw_line(
|
|
||||||
tty, wp->screen, i, wp->xoff, top + wp->yoff);
|
|
||||||
}
|
|
||||||
if (c->flags & CLIENT_IDENTIFY)
|
|
||||||
screen_redraw_draw_number(c, wp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Draw the status line. */
|
|
||||||
if (status) {
|
|
||||||
if (top)
|
|
||||||
tty_draw_line(tty, &c->status, 0, 0, 0);
|
|
||||||
else
|
|
||||||
tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
|
|
||||||
}
|
|
||||||
tty_reset(tty);
|
tty_reset(tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,6 +270,69 @@ screen_redraw_pane(struct client *c, struct window_pane *wp)
|
|||||||
tty_reset(&c->tty);
|
tty_reset(&c->tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Draw the borders. */
|
||||||
|
void
|
||||||
|
screen_redraw_draw_borders(struct client *c, int status, u_int top)
|
||||||
|
{
|
||||||
|
struct window *w = c->session->curw->window;
|
||||||
|
struct options *oo = &c->session->options;
|
||||||
|
struct tty *tty = &c->tty;
|
||||||
|
struct window_pane *wp;
|
||||||
|
struct grid_cell active_gc, other_gc;
|
||||||
|
u_int i, j, type;
|
||||||
|
|
||||||
|
style_apply(&other_gc, oo, "pane-border-style");
|
||||||
|
style_apply(&active_gc, oo, "pane-active-border-style");
|
||||||
|
active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET;
|
||||||
|
|
||||||
|
for (j = 0; j < tty->sy - status; j++) {
|
||||||
|
for (i = 0; i < tty->sx; i++) {
|
||||||
|
type = screen_redraw_check_cell(c, i, j, &wp);
|
||||||
|
if (type == CELL_INSIDE)
|
||||||
|
continue;
|
||||||
|
if (screen_redraw_check_active(i, j, type, w, wp))
|
||||||
|
tty_attributes(tty, &active_gc);
|
||||||
|
else
|
||||||
|
tty_attributes(tty, &other_gc);
|
||||||
|
tty_cursor(tty, i, top + j);
|
||||||
|
tty_putc(tty, CELL_BORDERS[type]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw the panes. */
|
||||||
|
void
|
||||||
|
screen_redraw_draw_panes(struct client *c, u_int top)
|
||||||
|
{
|
||||||
|
struct window *w = c->session->curw->window;
|
||||||
|
struct tty *tty = &c->tty;
|
||||||
|
struct window_pane *wp;
|
||||||
|
struct screen *s;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
|
if (!window_pane_visible(wp))
|
||||||
|
continue;
|
||||||
|
s = wp->screen;
|
||||||
|
for (i = 0; i < wp->sy; i++)
|
||||||
|
tty_draw_line(tty, s, i, wp->xoff, top + wp->yoff);
|
||||||
|
if (c->flags & CLIENT_IDENTIFY)
|
||||||
|
screen_redraw_draw_number(c, wp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw the status line. */
|
||||||
|
void
|
||||||
|
screen_redraw_draw_status(struct client *c, u_int top)
|
||||||
|
{
|
||||||
|
struct tty *tty = &c->tty;
|
||||||
|
|
||||||
|
if (top)
|
||||||
|
tty_draw_line(tty, &c->status, 0, 0, 0);
|
||||||
|
else
|
||||||
|
tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Draw number on a pane. */
|
/* Draw number on a pane. */
|
||||||
void
|
void
|
||||||
screen_redraw_draw_number(struct client *c, struct window_pane *wp)
|
screen_redraw_draw_number(struct client *c, struct window_pane *wp)
|
||||||
|
@ -743,7 +743,7 @@ server_client_check_redraw(struct client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c->flags & CLIENT_REDRAW) {
|
if (c->flags & CLIENT_REDRAW) {
|
||||||
screen_redraw_screen(c, 0, 0);
|
screen_redraw_screen(c, 1, 1, 1);
|
||||||
c->flags &= ~(CLIENT_STATUS|CLIENT_BORDERS);
|
c->flags &= ~(CLIENT_STATUS|CLIENT_BORDERS);
|
||||||
} else if (c->flags & CLIENT_REDRAWWINDOW) {
|
} else if (c->flags & CLIENT_REDRAWWINDOW) {
|
||||||
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry)
|
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry)
|
||||||
@ -757,10 +757,10 @@ server_client_check_redraw(struct client *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c->flags & CLIENT_BORDERS)
|
if (c->flags & CLIENT_BORDERS)
|
||||||
screen_redraw_screen(c, 0, 1);
|
screen_redraw_screen(c, 0, 0, 1);
|
||||||
|
|
||||||
if (c->flags & CLIENT_STATUS)
|
if (c->flags & CLIENT_STATUS)
|
||||||
screen_redraw_screen(c, 1, 0);
|
screen_redraw_screen(c, 0, 1, 0);
|
||||||
|
|
||||||
c->tty.flags |= flags;
|
c->tty.flags |= flags;
|
||||||
|
|
||||||
|
2
tmux.h
2
tmux.h
@ -2084,7 +2084,7 @@ void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
|
|||||||
void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
|
void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
|
||||||
|
|
||||||
/* screen-redraw.c */
|
/* screen-redraw.c */
|
||||||
void screen_redraw_screen(struct client *, int, int);
|
void screen_redraw_screen(struct client *, int, int, int);
|
||||||
void screen_redraw_pane(struct client *, struct window_pane *);
|
void screen_redraw_pane(struct client *, struct window_pane *);
|
||||||
|
|
||||||
/* screen.c */
|
/* screen.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user