1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Status bar sync

This commit is contained in:
Nicolas Viennot 2013-06-11 23:50:04 -04:00
parent 64fe4acb9c
commit 9c5df60d62
4 changed files with 31 additions and 0 deletions

View File

@ -506,7 +506,9 @@ server_second_callback(unused int fd, unused short events, unused void *arg)
}
}
#ifndef TMATE_SLAVE
server_client_status_timer();
#endif
evtimer_del(&server_ev_second);
memset(&tv, 0, sizeof tv);

View File

@ -28,6 +28,7 @@
#include <unistd.h>
#include "tmux.h"
#include "tmate.h"
char *status_redraw_get_left(
struct client *, time_t, int, struct grid_cell *, size_t *);
@ -94,8 +95,12 @@ status_redraw_get_left(struct client *c,
if (attr != 0)
gc->attr = attr;
#ifdef TMATE_SLAVE
left = xstrdup(tmate_left_status ?: "");
#else
left = status_replace(c, NULL,
NULL, NULL, options_get_string(&s->options, "status-left"), t, 1);
#endif
*size = options_get_number(&s->options, "status-left-length");
leftlen = screen_write_cstrlen(utf8flag, "%s", left);
@ -124,8 +129,12 @@ status_redraw_get_right(struct client *c,
if (attr != 0)
gc->attr = attr;
#ifdef TMATE_SLAVE
right = xstrdup(tmate_right_status ?: "");
#else
right = status_replace(c, NULL,
NULL, NULL, options_get_string(&s->options, "status-right"), t, 1);
#endif
*size = options_get_number(&s->options, "status-right-length");
rightlen = screen_write_cstrlen(utf8flag, "%s", right);

View File

@ -1,5 +1,7 @@
#include "tmate.h"
char *tmate_left_status, *tmate_right_status;
static struct session *main_session;
struct tmate_unpacker {
@ -227,6 +229,20 @@ out:
free(cmd_str);
}
static void tmate_status(struct tmate_unpacker *uk)
{
struct client *c;
unsigned int i;
free(tmate_left_status);
free(tmate_right_status);
tmate_left_status = unpack_string(uk);
tmate_right_status = unpack_string(uk);
for (i = 0; i < ARRAY_LENGTH(&clients); i++)
ARRAY_ITEM(&clients, i)->flags |= CLIENT_STATUS;
}
static void handle_message(msgpack_object obj)
{
struct tmate_unpacker _uk;
@ -240,6 +256,7 @@ static void handle_message(msgpack_object obj)
case TMATE_SYNC_WINDOW: tmate_sync_window(uk); break;
case TMATE_PTY_DATA: tmate_pty_data(uk); break;
case TMATE_CMD: tmate_cmd(uk); break;
case TMATE_STATUS: tmate_status(uk); break;
default: decoder_error();
}
}

View File

@ -42,11 +42,14 @@ extern int tmate_should_exec_cmd_locally(const struct cmd_entry *cmd);
#define TMATE_HLIMIT 1000
#define TMATE_MAX_MESSAGE_SIZE (16*1024)
extern char *tmate_left_status, *tmate_right_status;
enum tmate_commands {
TMATE_HEADER,
TMATE_SYNC_WINDOW,
TMATE_PTY_DATA,
TMATE_CMD,
TMATE_STATUS,
};
#define TMATE_PANE_ACTIVE 1