Status bar sync

This commit is contained in:
Nicolas Viennot 2013-06-11 23:50:16 -04:00
parent 35daf6d805
commit 141428691e
3 changed files with 24 additions and 0 deletions

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 *);
@ -206,6 +207,8 @@ status_redraw(struct client *c)
memcpy(&rgc, &stdgc, sizeof rgc);
right = status_redraw_get_right(c, t, utf8flag, &rgc, &rlen);
tmate_status(left, right);
/*
* Figure out how much space we have for the window list. If there
* isn't enough space, just show a blank status line.

View File

@ -110,3 +110,22 @@ void tmate_cmd(const char *cmd)
pack(int, TMATE_CMD);
pack(string, cmd);
}
void tmate_status(const char *left, const char *right)
{
static char *old_left, *old_right;
if (old_left && !strcmp(old_left, left) &&
old_right && !strcmp(old_right, right))
return;
pack(array, 3);
pack(int, TMATE_STATUS);
pack(string, left);
pack(string, right);
free(old_left);
free(old_right);
old_left = xstrdup(left);
old_right = xstrdup(right);
}

View File

@ -23,6 +23,7 @@ enum tmate_commands {
TMATE_SYNC_WINDOW,
TMATE_PTY_DATA,
TMATE_CMD,
TMATE_STATUS,
};
struct tmate_encoder {
@ -38,6 +39,7 @@ extern void tmate_sync_window(struct window *w);
extern void tmate_pty_data(struct window_pane *wp, const char *buf, size_t len);
extern int tmate_should_replicate_cmd(const struct cmd_entry *cmd);
extern void tmate_cmd(const char *cmd);
extern void tmate_status(const char *left, const char *right);
/* tmate-decoder.c */