From c2f88373e76b8c62ac2e2baed6bc1f0f20036401 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 18 Oct 2016 07:38:16 +0000 Subject: [PATCH 1/5] Store the right size in the pipe offset for pipe-pane. --- window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window.c b/window.c index 2c221f4390..8ef54084a7 100644 --- a/window.c +++ b/window.c @@ -970,7 +970,7 @@ window_pane_read_callback(__unused struct bufferevent *bufev, void *data) input_parse(wp); - wp->pipe_off = size; + wp->pipe_off = EVBUFFER_LENGTH(evb); } static void From 8763bced7678b97fe4a55d03c50f168418ff5f13 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 18 Oct 2016 08:39:18 +0000 Subject: [PATCH 2/5] Zero dirty count after flushing. --- screen-write.c | 1 + 1 file changed, 1 insertion(+) diff --git a/screen-write.c b/screen-write.c index 95caabce2c..d5fc1deecb 100644 --- a/screen-write.c +++ b/screen-write.c @@ -130,6 +130,7 @@ screen_write_flush(struct screen_write_ctx *ctx) if (dirty == ctx->dirty) break; } + ctx->dirty = 0; s->cx = cx; s->cy = cy; From 2e5c49a1fd8c534d546899f7c133a0adf212a7d1 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 18 Oct 2016 08:46:43 +0000 Subject: [PATCH 3/5] Give each item on queue a name for better logging. --- cmd-queue.c | 18 +++++++++++++++--- tmux.h | 4 +++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd-queue.c b/cmd-queue.c index 5056fffca5..24fd0c5658 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -112,6 +112,8 @@ cmdq_remove(struct cmdq_item *item) cmd_list_free(item->cmdlist); TAILQ_REMOVE(item->queue, item, entry); + + free((void *)item->name); free(item); } @@ -147,10 +149,15 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current, struct cmdq_item *item, *first = NULL, *last = NULL; struct cmd *cmd; u_int group = cmdq_next_group(); + char *tmp; TAILQ_FOREACH(cmd, &cmdlist->list, qentry) { + xasprintf(&tmp, "command[%s]", cmd->entry->name); + item = xcalloc(1, sizeof *item); + item->name = tmp; item->type = CMDQ_COMMAND; + item->group = group; item->flags = flags; @@ -220,12 +227,17 @@ cmdq_fire_command(struct cmdq_item *item) /* Get a callback for the command queue. */ struct cmdq_item * -cmdq_get_callback(cmdq_cb cb, void *data) +cmdq_get_callback1(const char *name, cmdq_cb cb, void *data) { struct cmdq_item *item; + char *tmp; + + xasprintf(&tmp, "callback[%s]", name); item = xcalloc(1, sizeof *item); + item->name = tmp; item->type = CMDQ_CALLBACK; + item->group = 0; item->flags = 0; @@ -289,8 +301,8 @@ cmdq_next(struct client *c) item = TAILQ_FIRST(queue); if (item == NULL) break; - log_debug("%s %s: type %d, flags %x", __func__, name, - item->type, item->flags); + log_debug("%s %s: %s (%d), flags %x", __func__, name, + item->name, item->type, item->flags); /* * Any item with the waiting flag set waits until an external diff --git a/tmux.h b/tmux.h index 84affa9c79..ae4b75dd44 100644 --- a/tmux.h +++ b/tmux.h @@ -1239,6 +1239,7 @@ enum cmdq_type { /* Command queue item. */ typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *); struct cmdq_item { + const char *name; struct cmdq_list *queue; struct cmdq_item *next; @@ -1779,7 +1780,8 @@ char *cmd_list_print(struct cmd_list *); /* cmd-queue.c */ struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *, struct mouse_event *, int); -struct cmdq_item *cmdq_get_callback(cmdq_cb, void *); +#define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data) +struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *); void cmdq_insert_after(struct cmdq_item *, struct cmdq_item *); void cmdq_append(struct client *, struct cmdq_item *); void printflike(3, 4) cmdq_format(struct cmdq_item *, const char *, From cf7289662fd8f3a40d7446ff18bf5d48206c2ef8 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 18 Oct 2016 12:51:26 +0000 Subject: [PATCH 4/5] Tweak a couple of log statements. --- cmd-find.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd-find.c b/cmd-find.c index 4e88fe4373..8bad330b83 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -990,13 +990,13 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current, /* Find current state. */ if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) { fs->current = &marked_pane; - log_debug(" current is marked pane"); + log_debug("%s: current is marked pane", __func__); } else if (cmd_find_valid_state(&item->current)) { fs->current = &item->current; - log_debug(" current is from queue"); + log_debug("%s: current is from queue", __func__); } else { fs->current = current; - log_debug(" current is from argument"); + log_debug("%s: current is from argument", __func__); } if (!cmd_find_empty_state(fs->current) && !cmd_find_valid_state(fs->current)) @@ -1207,7 +1207,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current, error: fs->current = NULL; - log_debug(" error"); + log_debug("%s: error", __func__); free(copy); return (-1); From a0998e42b77b05e58c9a34b6541dc95ad9e2290f Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 18 Oct 2016 14:56:17 +0000 Subject: [PATCH 5/5] Make grid_clear_cell set up the entry properly for 256 and RGB cells. --- grid.c | 58 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/grid.c b/grid.c index d0a2846332..9619c4fe8c 100644 --- a/grid.c +++ b/grid.c @@ -59,12 +59,46 @@ static size_t grid_string_cells_bg(const struct grid_cell *, int *); static void grid_string_cells_code(const struct grid_cell *, const struct grid_cell *, char *, size_t, int); +/* Set cell as extended. */ +static struct grid_cell * +grid_extended_cell(struct grid_line *gl, struct grid_cell_entry *gce, + const struct grid_cell *gc) +{ + struct grid_cell *gcp; + + gl->flags |= GRID_LINE_EXTENDED; + + if (~gce->flags & GRID_FLAG_EXTENDED) { + gl->extddata = xreallocarray(gl->extddata, gl->extdsize + 1, + sizeof *gl->extddata); + gce->offset = gl->extdsize++; + gce->flags = gc->flags | GRID_FLAG_EXTENDED; + } + if (gce->offset >= gl->extdsize) + fatalx("offset too big"); + + gcp = &gl->extddata[gce->offset]; + memcpy(gcp, gc, sizeof *gcp); + return (gcp); +} + /* Copy default into a cell. */ static void grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg) { - gd->linedata[py].celldata[px] = grid_default_entry; - gd->linedata[py].celldata[px].data.bg = bg; + struct grid_line *gl = &gd->linedata[py]; + struct grid_cell_entry *gce = &gl->celldata[px]; + struct grid_cell *gc; + + memcpy(gce, &grid_default_cell, sizeof *gce); + if (bg & COLOUR_FLAG_RGB) { + gc = grid_extended_cell(gl, gce, &grid_default_cell); + gc->bg = bg; + } else { + if (bg & COLOUR_FLAG_256) + gce->flags |= GRID_FLAG_BG256; + gce->data.bg = bg; + } } /* Check grid y position. */ @@ -322,7 +356,6 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) { struct grid_line *gl; struct grid_cell_entry *gce; - struct grid_cell *gcp; int extended; if (grid_check_y(gd, py) != 0) @@ -339,23 +372,12 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) extended = (gce->flags & GRID_FLAG_EXTENDED); if (!extended && (gc->data.size != 1 || gc->data.width != 1)) extended = 1; - if (!extended && ((gc->fg & COLOUR_FLAG_RGB) || - (gc->bg & COLOUR_FLAG_RGB))) + if (!extended && (gc->fg & COLOUR_FLAG_RGB)) + extended = 1; + if (!extended && (gc->bg & COLOUR_FLAG_RGB)) extended = 1; if (extended) { - gl->flags |= GRID_LINE_EXTENDED; - - if (~gce->flags & GRID_FLAG_EXTENDED) { - gl->extddata = xreallocarray(gl->extddata, - gl->extdsize + 1, sizeof *gl->extddata); - gce->offset = gl->extdsize++; - gce->flags = gc->flags | GRID_FLAG_EXTENDED; - } - - if (gce->offset >= gl->extdsize) - fatalx("offset too big"); - gcp = &gl->extddata[gce->offset]; - memcpy(gcp, gc, sizeof *gcp); + grid_extended_cell(gl, gce, gc); return; }