summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2018-02-05 08:21:55 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2018-02-05 08:21:55 +0000
commit05cd6cb32f94ff6fc4b2e345f167e0d6660cd966 (patch)
treedb6f62e75e2b09fb8fd2c0d96b8899ac5b7ae18a /usr.bin
parentadc0ca20d48bf925e95fdda0730c7bb040f8a4be (diff)
Add struct status_line to hold status line members of struct client, not
used yet but will be soon. From Thomas Adam.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/screen-redraw.c4
-rw-r--r--usr.bin/tmux/server-client.c16
-rw-r--r--usr.bin/tmux/status.c75
-rw-r--r--usr.bin/tmux/tmux.h14
-rw-r--r--usr.bin/tmux/window-client.c8
5 files changed, 62 insertions, 55 deletions
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c
index 1a801564679..1ff37e67a0b 100644
--- a/usr.bin/tmux/screen-redraw.c
+++ b/usr.bin/tmux/screen-redraw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-redraw.c,v 1.48 2017/12/22 23:16:41 nicm Exp $ */
+/* $OpenBSD: screen-redraw.c,v 1.49 2018/02/05 08:21:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -563,7 +563,7 @@ screen_redraw_draw_status(struct client *c, u_int lines, u_int top)
else
y = tty->sy - lines;
for (i = 0; i < lines; i++)
- tty_draw_line(tty, NULL, &c->status, i, 0, y);
+ tty_draw_line(tty, NULL, &c->status.status, i, 0, y);
}
/* Draw number on a pane. */
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 6f90ae353ca..a9222f156ed 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.246 2017/12/19 15:00:39 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.247 2018/02/05 08:21:54 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -195,7 +195,7 @@ server_client_create(int fd)
c->tty.sx = 80;
c->tty.sy = 24;
- screen_init(&c->status, c->tty.sx, 1, 0);
+ screen_init(&c->status.status, c->tty.sx, 1, 0);
c->message_string = NULL;
TAILQ_INIT(&c->message_log);
@@ -272,12 +272,12 @@ server_client_lost(struct client *c)
if (c->stderr_data != c->stdout_data)
evbuffer_free(c->stderr_data);
- if (event_initialized(&c->status_timer))
- evtimer_del(&c->status_timer);
- screen_free(&c->status);
- if (c->old_status != NULL) {
- screen_free(c->old_status);
- free(c->old_status);
+ if (event_initialized(&c->status.timer))
+ evtimer_del(&c->status.timer);
+ screen_free(&c->status.status);
+ if (c->status.old_status != NULL) {
+ screen_free(c->status.old_status);
+ free(c->status.old_status);
}
free(c->title);
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index 86aa853d903..cdbd8b6c7c4 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.174 2018/01/01 11:03:54 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.175 2018/02/05 08:21:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -151,7 +151,7 @@ status_timer_callback(__unused int fd, __unused short events, void *arg)
struct session *s = c->session;
struct timeval tv;
- evtimer_del(&c->status_timer);
+ evtimer_del(&c->status.timer);
if (s == NULL)
return;
@@ -163,7 +163,7 @@ status_timer_callback(__unused int fd, __unused short events, void *arg)
tv.tv_sec = options_get_number(s->options, "status-interval");
if (tv.tv_sec != 0)
- evtimer_add(&c->status_timer, &tv);
+ evtimer_add(&c->status.timer, &tv);
log_debug("client %p, status interval %d", c, (int)tv.tv_sec);
}
@@ -173,10 +173,10 @@ status_timer_start(struct client *c)
{
struct session *s = c->session;
- if (event_initialized(&c->status_timer))
- evtimer_del(&c->status_timer);
+ if (event_initialized(&c->status.timer))
+ evtimer_del(&c->status.timer);
else
- evtimer_set(&c->status_timer, status_timer_callback, c);
+ evtimer_set(&c->status.timer, status_timer_callback, c);
if (s != NULL && options_get_number(s->options, "status"))
status_timer_callback(-1, 0, c);
@@ -317,10 +317,10 @@ status_redraw(struct client *c)
int larrow, rarrow;
/* Delete the saved status line, if any. */
- if (c->old_status != NULL) {
- screen_free(c->old_status);
- free(c->old_status);
- c->old_status = NULL;
+ if (c->status.old_status != NULL) {
+ screen_free(c->status.old_status);
+ free(c->status.old_status);
+ c->status.old_status = NULL;
}
/* No status line? */
@@ -337,9 +337,9 @@ status_redraw(struct client *c)
style_apply(&stdgc, s->options, "status-style");
/* Create the target screen. */
- memcpy(&old_status, &c->status, sizeof old_status);
- screen_init(&c->status, c->tty.sx, lines, 0);
- screen_write_start(&ctx, NULL, &c->status);
+ memcpy(&old_status, &c->status.status, sizeof old_status);
+ screen_init(&c->status.status, c->tty.sx, lines, 0);
+ screen_write_start(&ctx, NULL, &c->status.status);
for (offset = 0; offset < lines * c->tty.sx; offset++)
screen_write_putc(&ctx, &stdgc, ' ');
screen_write_stop(&ctx);
@@ -462,7 +462,7 @@ status_redraw(struct client *c)
draw:
/* Begin drawing. */
- screen_write_start(&ctx, NULL, &c->status);
+ screen_write_start(&ctx, NULL, &c->status.status);
/* Draw the left string and arrow. */
screen_write_cursormove(&ctx, 0, 0);
@@ -517,7 +517,7 @@ out:
free(left);
free(right);
- if (grid_compare(c->status.grid, old_status.grid) == 0) {
+ if (grid_compare(c->status.status.grid, old_status.grid) == 0) {
screen_free(&old_status);
return (0);
}
@@ -590,10 +590,11 @@ status_message_set(struct client *c, const char *fmt, ...)
status_message_clear(c);
- if (c->old_status == NULL) {
- c->old_status = xmalloc(sizeof *c->old_status);
- memcpy(c->old_status, &c->status, sizeof *c->old_status);
- screen_init(&c->status, c->tty.sx, 1, 0);
+ if (c->status.old_status == NULL) {
+ c->status.old_status = xmalloc(sizeof *c->status.old_status);
+ memcpy(c->status.old_status, &c->status.status,
+ sizeof *c->status.old_status);
+ screen_init(&c->status.status, c->tty.sx, 1, 0);
}
va_start(ap, fmt);
@@ -631,7 +632,7 @@ status_message_clear(struct client *c)
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_REDRAW; /* screen was frozen and may have changed */
- screen_reinit(&c->status);
+ screen_reinit(&c->status.status);
}
/* Clear status line message after timer expires. */
@@ -656,14 +657,14 @@ status_message_redraw(struct client *c)
if (c->tty.sx == 0 || c->tty.sy == 0)
return (0);
- memcpy(&old_status, &c->status, sizeof old_status);
+ memcpy(&old_status, &c->status.status, sizeof old_status);
lines = status_line_size(c->session);
if (lines <= 1) {
lines = 1;
- screen_init(&c->status, c->tty.sx, 1, 0);
+ screen_init(&c->status.status, c->tty.sx, 1, 0);
} else
- screen_init(&c->status, c->tty.sx, lines, 0);
+ screen_init(&c->status.status, c->tty.sx, lines, 0);
len = screen_write_strlen("%s", c->message_string);
if (len > c->tty.sx)
@@ -671,7 +672,7 @@ status_message_redraw(struct client *c)
style_apply(&gc, s->options, "message-style");
- screen_write_start(&ctx, NULL, &c->status);
+ screen_write_start(&ctx, NULL, &c->status.status);
screen_write_cursormove(&ctx, 0, 0);
for (offset = 0; offset < lines * c->tty.sx; offset++)
screen_write_putc(&ctx, &gc, ' ');
@@ -679,7 +680,7 @@ status_message_redraw(struct client *c)
screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
screen_write_stop(&ctx);
- if (grid_compare(c->status.grid, old_status.grid) == 0) {
+ if (grid_compare(c->status.status.grid, old_status.grid) == 0) {
screen_free(&old_status);
return (0);
}
@@ -710,10 +711,11 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
status_message_clear(c);
status_prompt_clear(c);
- if (c->old_status == NULL) {
- c->old_status = xmalloc(sizeof *c->old_status);
- memcpy(c->old_status, &c->status, sizeof *c->old_status);
- screen_init(&c->status, c->tty.sx, 1, 0);
+ if (c->status.old_status == NULL) {
+ c->status.old_status = xmalloc(sizeof *c->status.old_status);
+ memcpy(c->status.old_status, &c->status.status,
+ sizeof *c->status.old_status);
+ screen_init(&c->status.status, c->tty.sx, 1, 0);
}
c->prompt_string = format_expand_time(ft, msg, t);
@@ -763,7 +765,7 @@ status_prompt_clear(struct client *c)
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_REDRAW; /* screen was frozen and may have changed */
- screen_reinit(&c->status);
+ screen_reinit(&c->status.status);
}
/* Update status line prompt with a new prompt string. */
@@ -809,14 +811,14 @@ status_prompt_redraw(struct client *c)
if (c->tty.sx == 0 || c->tty.sy == 0)
return (0);
- memcpy(&old_status, &c->status, sizeof old_status);
+ memcpy(&old_status, &c->status.status, sizeof old_status);
lines = status_line_size(c->session);
if (lines <= 1) {
lines = 1;
- screen_init(&c->status, c->tty.sx, 1, 0);
+ screen_init(&c->status.status, c->tty.sx, 1, 0);
} else
- screen_init(&c->status, c->tty.sx, lines, 0);
+ screen_init(&c->status.status, c->tty.sx, lines, 0);
len = screen_write_strlen("%s", c->prompt_string);
if (len > c->tty.sx)
@@ -834,7 +836,7 @@ status_prompt_redraw(struct client *c)
if (start > c->tty.sx)
start = c->tty.sx;
- screen_write_start(&ctx, NULL, &c->status);
+ screen_write_start(&ctx, NULL, &c->status.status);
screen_write_cursormove(&ctx, 0, 0);
for (offset = 0; offset < lines * c->tty.sx; offset++)
screen_write_putc(&ctx, &gc, ' ');
@@ -880,13 +882,14 @@ status_prompt_redraw(struct client *c)
screen_write_cell(&ctx, &cursorgc);
}
}
- if (c->status.cx < screen_size_x(&c->status) && c->prompt_index >= i)
+ if (c->status.status.cx < screen_size_x(&c->status.status) &&
+ c->prompt_index >= i)
screen_write_putc(&ctx, &cursorgc, ' ');
finished:
screen_write_stop(&ctx);
- if (grid_compare(c->status.grid, old_status.grid) == 0) {
+ if (grid_compare(c->status.status.grid, old_status.grid) == 0) {
screen_free(&old_status);
return (0);
}
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index c868b198bd1..749c6abb105 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.817 2018/02/04 10:10:39 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.818 2018/02/05 08:21:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1312,6 +1312,13 @@ struct cmd_entry {
enum cmd_retval (*exec)(struct cmd *, struct cmdq_item *);
};
+/* Status line. */
+struct status_line {
+ struct event timer;
+ struct screen status;
+ struct screen *old_status;
+};
+
/* Client connection. */
typedef int (*prompt_input_cb)(struct client *, void *, const char *, int);
typedef void (*prompt_free_cb)(void *);
@@ -1354,10 +1361,7 @@ struct client {
struct event click_timer;
u_int click_button;
- struct event status_timer;
- struct screen status;
-
- struct screen *old_status;
+ struct status_line status;
#define CLIENT_TERMINAL 0x1
#define CLIENT_LOGIN 0x2
diff --git a/usr.bin/tmux/window-client.c b/usr.bin/tmux/window-client.c
index 812cf0680fc..efd947dc64e 100644
--- a/usr.bin/tmux/window-client.c
+++ b/usr.bin/tmux/window-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-client.c,v 1.12 2017/11/03 17:02:33 nicm Exp $ */
+/* $OpenBSD: window-client.c,v 1.13 2018/02/05 08:21:54 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -229,10 +229,10 @@ window_client_draw(__unused void *modedata, void *itemdata,
screen_write_hline(ctx, sx, 0, 0);
screen_write_cursormove(ctx, cx, cy + sy - 1);
- if (c->old_status != NULL)
- screen_write_fast_copy(ctx, c->old_status, 0, 0, sx, 1);
+ if (c->status.old_status != NULL)
+ screen_write_fast_copy(ctx, c->status.old_status, 0, 0, sx, 1);
else
- screen_write_fast_copy(ctx, &c->status, 0, 0, sx, 1);
+ screen_write_fast_copy(ctx, &c->status.status, 0, 0, sx, 1);
}
static struct screen *