aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2016-06-06 10:01:11 +0100
committerThomas Adam <thomas@xteddy.org>2016-06-06 10:01:11 +0100
commitcc096ae9291c35887679c7031c24cac218ddc319 (patch)
treeb2cfe5c70312723a6fe91d22660b00ba71a69d74
parent1f75c98f4999856ddb6a5d620b6dd1ed18b6324d (diff)
parentaba44380137b5d78f9033e46b5dc4a4f3ef1012a (diff)
downloadrtmux-cc096ae9291c35887679c7031c24cac218ddc319.tar.gz
rtmux-cc096ae9291c35887679c7031c24cac218ddc319.tar.bz2
rtmux-cc096ae9291c35887679c7031c24cac218ddc319.zip
Merge branch 'obsd-master'
-rw-r--r--cmd-split-window.c2
-rw-r--r--screen-write.c20
-rw-r--r--status.c13
-rw-r--r--tmux.h4
-rw-r--r--window.c12
5 files changed, 33 insertions, 18 deletions
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 93e23cdd..f39dfc56 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -135,7 +135,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
cause = xstrdup("pane too small");
goto error;
}
- new_wp = window_add_pane(w, hlimit);
+ new_wp = window_add_pane(w, wp, hlimit);
layout_assign_pane(lc, new_wp);
path = NULL;
diff --git a/screen-write.c b/screen-write.c
index 0341f0ad..48af1383 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -989,8 +989,19 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
if (skip)
skip = (memcmp(&now_gc, gc, sizeof now_gc) == 0);
- /* Set the cell. */
- if (!skip)
+ /* Update the selection the flag and set the cell. */
+ selected = screen_check_selection(s, s->cx, s->cy);
+ if (selected && ~gc->flags & GRID_FLAG_SELECTED) {
+ skip = 0;
+ memcpy(&tmp_gc, gc, sizeof tmp_gc);
+ tmp_gc.flags |= GRID_FLAG_SELECTED;
+ grid_view_set_cell(gd, s->cx, s->cy, &tmp_gc);
+ } else if (!selected && gc->flags & GRID_FLAG_SELECTED) {
+ skip = 0;
+ memcpy(&tmp_gc, gc, sizeof tmp_gc);
+ tmp_gc.flags &= ~GRID_FLAG_SELECTED;
+ grid_view_set_cell(gd, s->cx, s->cy, &tmp_gc);
+ } else if (!skip)
grid_view_set_cell(gd, s->cx, s->cy, gc);
/*
@@ -1009,11 +1020,6 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
tty_write(tty_cmd_insertcharacter, &ttyctx);
}
- /* Check if this is selected. */
- selected = screen_check_selection(s, s->cx - width, s->cy);
- if (selected)
- skip = 0;
-
/* Save last cell if it will be needed. */
if (!skip && ctx->wp != NULL && ttyctx.ocx > ctx->wp->sx - width)
screen_write_save_last(ctx, &ttyctx);
diff --git a/status.c b/status.c
index 1bd02c43..607d6476 100644
--- a/status.c
+++ b/status.c
@@ -257,16 +257,19 @@ status_get_window_at(struct client *c, u_int x)
struct session *s = c->session;
struct winlink *wl;
struct options *oo;
- size_t len;
+ const char *sep;
+ size_t seplen;
x += c->wlmouse;
RB_FOREACH(wl, winlinks, &s->windows) {
oo = wl->window->options;
- len = strlen(options_get_string(oo, "window-status-separator"));
+
+ sep = options_get_string(oo, "window-status-separator");
+ seplen = screen_write_cstrlen("%s", sep);
if (x < wl->status_width)
return (wl->window);
- x -= wl->status_width + len;
+ x -= wl->status_width + seplen;
}
return (NULL);
}
@@ -344,7 +347,7 @@ status_redraw(struct client *c)
oo = wl->window->options;
sep = options_get_string(oo, "window-status-separator");
- seplen = screen_write_strlen("%s", sep);
+ seplen = screen_write_cstrlen("%s", sep);
wlwidth += wl->status_width + seplen;
}
@@ -359,7 +362,7 @@ status_redraw(struct client *c)
oo = wl->window->options;
sep = options_get_string(oo, "window-status-separator");
- screen_write_nputs(&ctx, -1, &stdgc, "%s", sep);
+ screen_write_cnputs(&ctx, -1, &stdgc, "%s", sep);
}
screen_write_stop(&ctx);
diff --git a/tmux.h b/tmux.h
index 796938af..e5c546eb 100644
--- a/tmux.h
+++ b/tmux.h
@@ -644,6 +644,7 @@ enum utf8_state {
#define GRID_FLAG_EXTENDED 0x8
#define GRID_FLAG_FGRGB 0x10
#define GRID_FLAG_BGRGB 0x20
+#define GRID_FLAG_SELECTED 0x40
/* Grid line flags. */
#define GRID_LINE_WRAPPED 0x1
@@ -2132,7 +2133,8 @@ int window_has_pane(struct window *, struct window_pane *);
int window_set_active_pane(struct window *, struct window_pane *);
void window_redraw_active_switch(struct window *,
struct window_pane *);
-struct window_pane *window_add_pane(struct window *, u_int);
+struct window_pane *window_add_pane(struct window *, struct window_pane *,
+ u_int);
void window_resize(struct window *, u_int, u_int);
int window_zoom(struct window_pane *);
int window_unzoom(struct window *);
diff --git a/window.c b/window.c
index a75c17de..6d14c181 100644
--- a/window.c
+++ b/window.c
@@ -323,7 +323,7 @@ window_create(const char *name, int argc, char **argv, const char *path,
struct window_pane *wp;
w = window_create1(sx, sy);
- wp = window_add_pane(w, hlimit);
+ wp = window_add_pane(w, NULL, hlimit);
layout_init(w, wp);
if (window_pane_spawn(wp, argc, argv, path, shell, cwd, env, tio,
@@ -553,15 +553,19 @@ window_unzoom(struct window *w)
}
struct window_pane *
-window_add_pane(struct window *w, u_int hlimit)
+window_add_pane(struct window *w, struct window_pane *after, u_int hlimit)
{
struct window_pane *wp;
wp = window_pane_create(w, w->sx, w->sy, hlimit);
if (TAILQ_EMPTY(&w->panes))
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
- else
- TAILQ_INSERT_AFTER(&w->panes, w->active, wp, entry);
+ else {
+ if (after == NULL)
+ TAILQ_INSERT_AFTER(&w->panes, w->active, wp, entry);
+ else
+ TAILQ_INSERT_AFTER(&w->panes, after, wp, entry);
+ }
return (wp);
}