mirror of
https://github.com/tmate-io/tmate.git
synced 2025-02-28 00:01:38 +01:00
snapshot
This commit is contained in:
parent
cdfb6d7ef1
commit
a7c5507464
@ -2,7 +2,7 @@
|
|||||||
#include "tmate-protocol.h"
|
#include "tmate-protocol.h"
|
||||||
#include "window-copy.h"
|
#include "window-copy.h"
|
||||||
|
|
||||||
#define pack(what, ...) _pack(&tmate_session.encoder, what, __VA_ARGS__)
|
#define pack(what, ...) _pack(&tmate_session.encoder, what, ##__VA_ARGS__)
|
||||||
|
|
||||||
void tmate_write_header(void)
|
void tmate_write_header(void)
|
||||||
{
|
{
|
||||||
@ -237,29 +237,14 @@ void tmate_write_fin(void)
|
|||||||
pack(int, TMATE_OUT_FIN);
|
pack(int, TMATE_OUT_FIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_snapshot(unsigned int max_history_lines,
|
static void do_snapshot_grid(struct grid *grid, unsigned int max_history_lines)
|
||||||
struct window_pane *pane)
|
|
||||||
{
|
{
|
||||||
struct screen *screen;
|
|
||||||
struct grid *grid;
|
|
||||||
struct grid_line *line;
|
struct grid_line *line;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
unsigned int line_i, i;
|
unsigned int line_i, i;
|
||||||
unsigned int max_lines;
|
unsigned int max_lines;
|
||||||
size_t str_len;
|
size_t str_len;
|
||||||
|
|
||||||
screen = &pane->base;
|
|
||||||
grid = screen->grid;
|
|
||||||
|
|
||||||
pack(array, 4);
|
|
||||||
pack(int, pane->id);
|
|
||||||
|
|
||||||
pack(array, 2);
|
|
||||||
pack(int, screen->cx);
|
|
||||||
pack(int, screen->cy);
|
|
||||||
|
|
||||||
pack(unsigned_int, screen->mode);
|
|
||||||
|
|
||||||
max_lines = max_history_lines + grid->sy;
|
max_lines = max_history_lines + grid->sy;
|
||||||
|
|
||||||
#define grid_num_lines(grid) (grid->hsize + grid->sy)
|
#define grid_num_lines(grid) (grid->hsize + grid->sy)
|
||||||
@ -295,6 +280,31 @@ static void do_snapshot(unsigned int max_history_lines,
|
|||||||
gc.fg ));
|
gc.fg ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void do_snapshot_pane(struct window_pane *wp, unsigned int max_history_lines)
|
||||||
|
{
|
||||||
|
struct screen *screen = &wp->base;
|
||||||
|
|
||||||
|
pack(array, 4);
|
||||||
|
pack(int, wp->id);
|
||||||
|
|
||||||
|
pack(unsigned_int, screen->mode);
|
||||||
|
|
||||||
|
pack(array, 3);
|
||||||
|
pack(int, screen->cx);
|
||||||
|
pack(int, screen->cy);
|
||||||
|
do_snapshot_grid(screen->grid, max_history_lines);
|
||||||
|
|
||||||
|
if (wp->saved_grid) {
|
||||||
|
pack(array, 3);
|
||||||
|
pack(int, wp->saved_cx);
|
||||||
|
pack(int, wp->saved_cy);
|
||||||
|
do_snapshot_grid(wp->saved_grid, max_history_lines);
|
||||||
|
} else {
|
||||||
|
pack(nil);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tmate_send_session_snapshot(unsigned int max_history_lines)
|
static void tmate_send_session_snapshot(unsigned int max_history_lines)
|
||||||
@ -329,7 +339,7 @@ static void tmate_send_session_snapshot(unsigned int max_history_lines)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
TAILQ_FOREACH(pane, &w->panes, entry)
|
TAILQ_FOREACH(pane, &w->panes, entry)
|
||||||
do_snapshot(max_history_lines, pane);
|
do_snapshot_pane(pane, max_history_lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
tmate.h
2
tmate.h
@ -38,7 +38,7 @@ extern void tmate_encoder_set_ready_callback(struct tmate_encoder *encoder,
|
|||||||
extern void msgpack_pack_string(msgpack_packer *pk, const char *str);
|
extern void msgpack_pack_string(msgpack_packer *pk, const char *str);
|
||||||
extern void msgpack_pack_boolean(msgpack_packer *pk, bool value);
|
extern void msgpack_pack_boolean(msgpack_packer *pk, bool value);
|
||||||
|
|
||||||
#define _pack(enc, what, ...) msgpack_pack_##what(&(enc)->pk, __VA_ARGS__)
|
#define _pack(enc, what, ...) msgpack_pack_##what(&(enc)->pk, ##__VA_ARGS__)
|
||||||
|
|
||||||
struct tmate_unpacker;
|
struct tmate_unpacker;
|
||||||
struct tmate_decoder;
|
struct tmate_decoder;
|
||||||
|
Loading…
Reference in New Issue
Block a user