aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES25
-rw-r--r--Makefile.am3
-rw-r--r--cmd-capture-pane.c9
-rw-r--r--cmd-choose-tree.c12
-rw-r--r--cmd-parse.y16
-rw-r--r--cmd-queue.c1
-rw-r--r--cmd-rotate-window.c17
-rw-r--r--cmd-select-pane.c30
-rw-r--r--cmd-swap-pane.c26
-rw-r--r--cmd-switch-client.c19
-rw-r--r--configure.ac2
-rw-r--r--format-draw.c21
-rw-r--r--format.c6
-rw-r--r--key-bindings.c1
-rw-r--r--mode-tree.c25
-rw-r--r--options-table.c4
-rw-r--r--server-client.c75
-rw-r--r--style.c39
-rw-r--r--tmux.1202
-rw-r--r--tmux.h24
-rw-r--r--window-buffer.c70
-rw-r--r--window-client.c106
-rw-r--r--window-copy.c134
-rw-r--r--window-tree.c168
-rw-r--r--window.c24
25 files changed, 615 insertions, 444 deletions
diff --git a/CHANGES b/CHANGES
index f4ff86d2..cdad8ed8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,28 @@
+CHANGES FROM 3.0 to X.X
+
+* Add push-default and pop-default for styles which change the colours and
+ attributes used for #[default]. These are used in status-format to restore
+ the behaviour of window-status-style being the default for
+ window-status-format.
+
+* Add window_marked_flag.
+
+* Add cursor-down-and-cancel in copy mode.
+
+* Default to previous search string for search-forward and search-backward.
+
+* Add -Z flag to rotate-window, select-pane, swap-pane, switch-client to
+ preserve zoomed state.
+
+* Add support for the SD (scroll down) escape sequence.
+
+* xterm 348 now disables margins when resized, so send DECLRMM again after
+ resize.
+
+* Add -N to capture-pane to preserve trailing spaces.
+
+* Add reverse sorting in tree, client and buffer modes.
+
CHANGES FROM 2.9 to 3.0
* xterm 348 now disables margins when resized, so send DECLRMM again after
diff --git a/Makefile.am b/Makefile.am
index 94b1564b..ab302637 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,8 +6,9 @@ CLEANFILES = tmux.1.mdoc tmux.1.man cmd-parse.c
# Distribution tarball options.
EXTRA_DIST = \
- CHANGES README README.ja COPYING example_tmux.conf compat/*.[ch] \
+ CHANGES README README.ja COPYING example_tmux.conf \
osdep-*.c mdoc2man.awk tmux.1
+dist_EXTRA_tmux_SOURCES = compat/*.[ch]
# Preprocessor flags.
AM_CPPFLAGS += @XOPEN_DEFINES@ -DTMUX_CONF="\"$(sysconfdir)/tmux.conf\""
diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index a3ec066c..fc6c26e4 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -39,8 +39,8 @@ const struct cmd_entry cmd_capture_pane_entry = {
.name = "capture-pane",
.alias = "capturep",
- .args = { "ab:CeE:JpPqS:t:", 0, 0 },
- .usage = "[-aCeJpPq] " CMD_BUFFER_USAGE " [-E end-line] "
+ .args = { "ab:CeE:JNpPqS:t:", 0, 0 },
+ .usage = "[-aCeJNpPq] " CMD_BUFFER_USAGE " [-E end-line] "
"[-S start-line] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
@@ -110,7 +110,7 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
struct grid *gd;
const struct grid_line *gl;
struct grid_cell *gc = NULL;
- int n, with_codes, escape_c0, join_lines;
+ int n, with_codes, escape_c0, join_lines, no_trim;
u_int i, sx, top, bottom, tmp;
char *cause, *buf, *line;
const char *Sflag, *Eflag;
@@ -170,11 +170,12 @@ cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
with_codes = args_has(args, 'e');
escape_c0 = args_has(args, 'C');
join_lines = args_has(args, 'J');
+ no_trim = args_has(args, 'N');
buf = NULL;
for (i = top; i <= bottom; i++) {
line = grid_string_cells(gd, 0, i, sx, &gc, with_codes,
- escape_c0, !join_lines);
+ escape_c0, !join_lines && !no_trim);
linelen = strlen(line);
buf = cmd_capture_pane_append(buf, len, line, linelen);
diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c
index 5eb58ff5..8178ec9f 100644
--- a/cmd-choose-tree.c
+++ b/cmd-choose-tree.c
@@ -30,8 +30,8 @@ const struct cmd_entry cmd_choose_tree_entry = {
.name = "choose-tree",
.alias = NULL,
- .args = { "F:Gf:NO:st:wZ", 0, 1 },
- .usage = "[-GNsw] [-F format] [-f filter] [-O sort-order] "
+ .args = { "F:Gf:NO:rst:wZ", 0, 1 },
+ .usage = "[-GNrswZ] [-F format] [-f filter] [-O sort-order] "
CMD_TARGET_PANE_USAGE " [template]",
.target = { 't', CMD_FIND_PANE, 0 },
@@ -44,8 +44,8 @@ const struct cmd_entry cmd_choose_client_entry = {
.name = "choose-client",
.alias = NULL,
- .args = { "F:f:NO:t:Z", 0, 1 },
- .usage = "[-N] [-F format] [-f filter] [-O sort-order] "
+ .args = { "F:f:NO:rt:Z", 0, 1 },
+ .usage = "[-NrZ] [-F format] [-f filter] [-O sort-order] "
CMD_TARGET_PANE_USAGE " [template]",
.target = { 't', CMD_FIND_PANE, 0 },
@@ -58,8 +58,8 @@ const struct cmd_entry cmd_choose_buffer_entry = {
.name = "choose-buffer",
.alias = NULL,
- .args = { "F:f:NO:t:Z", 0, 1 },
- .usage = "[-N] [-F format] [-f filter] [-O sort-order] "
+ .args = { "F:f:NO:rt:Z", 0, 1 },
+ .usage = "[-NrZ] [-F format] [-f filter] [-O sort-order] "
CMD_TARGET_PANE_USAGE " [template]",
.target = { 't', CMD_FIND_PANE, 0 },
diff --git a/cmd-parse.y b/cmd-parse.y
index 6d2b970c..b0a42f7c 100644
--- a/cmd-parse.y
+++ b/cmd-parse.y
@@ -176,18 +176,18 @@ expanded : format
struct cmd_parse_input *pi = ps->input;
struct format_tree *ft;
struct client *c = pi->c;
- struct cmd_find_state *fs;
+ struct cmd_find_state *fsp;
+ struct cmd_find_state fs;
int flags = FORMAT_NOJOBS;
if (cmd_find_valid_state(&pi->fs))
- fs = &pi->fs;
- else
- fs = NULL;
+ fsp = &pi->fs;
+ else {
+ cmd_find_from_client(&fs, c, 0);
+ fsp = &fs;
+ }
ft = format_create(NULL, pi->item, FORMAT_NONE, flags);
- if (fs != NULL)
- format_defaults(ft, c, fs->s, fs->wl, fs->wp);
- else
- format_defaults(ft, c, NULL, NULL, NULL);
+ format_defaults(ft, c, fsp->s, fsp->wl, fsp->wp);
$$ = format_expand(ft, $1);
format_free(ft);
diff --git a/cmd-queue.c b/cmd-queue.c
index ef68d5d5..fa6999e8 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -102,7 +102,6 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
} while (item != NULL);
}
-
/* Insert a hook. */
void
cmdq_insert_hook(struct session *s, struct cmdq_item *item,
diff --git a/cmd-rotate-window.c b/cmd-rotate-window.c
index 6dc0f2a8..cc661163 100644
--- a/cmd-rotate-window.c
+++ b/cmd-rotate-window.c
@@ -31,8 +31,8 @@ const struct cmd_entry cmd_rotate_window_entry = {
.name = "rotate-window",
.alias = "rotatew",
- .args = { "Dt:U", 0, 0 },
- .usage = "[-DU] " CMD_TARGET_WINDOW_USAGE,
+ .args = { "Dt:UZ", 0, 0 },
+ .usage = "[-DUZ] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 },
@@ -50,7 +50,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
struct layout_cell *lc;
u_int sx, sy, xoff, yoff;
- server_unzoom_window(w);
+ window_push_zoom(w, args_has(self->args, 'Z'));
if (args_has(self->args, 'D')) {
wp = TAILQ_LAST(&w->panes, window_panes);
@@ -77,9 +77,6 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL)
wp = TAILQ_LAST(&w->panes, window_panes);
- window_set_active_pane(w, wp, 1);
- cmd_find_from_winlink_pane(current, wl, wp, 0);
- server_redraw_window(w);
} else {
wp = TAILQ_FIRST(&w->panes);
TAILQ_REMOVE(&w->panes, wp, entry);
@@ -105,10 +102,12 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
if ((wp = TAILQ_NEXT(w->active, entry)) == NULL)
wp = TAILQ_FIRST(&w->panes);
- window_set_active_pane(w, wp, 1);
- cmd_find_from_winlink_pane(current, wl, wp, 0);
- server_redraw_window(w);
}
+ window_set_active_pane(w, wp, 1);
+ cmd_find_from_winlink_pane(current, wl, wp, 0);
+ window_pop_zoom(w);
+ server_redraw_window(w);
+
return (CMD_RETURN_NORMAL);
}
diff --git a/cmd-select-pane.c b/cmd-select-pane.c
index 52c58dbc..15f76afe 100644
--- a/cmd-select-pane.c
+++ b/cmd-select-pane.c
@@ -33,8 +33,8 @@ const struct cmd_entry cmd_select_pane_entry = {
.name = "select-pane",
.alias = "selectp",
- .args = { "DdegLlMmP:RT:t:U", 0, 0 }, /* -P and -g deprecated */
- .usage = "[-DdeLlMmRU] [-T title] " CMD_TARGET_PANE_USAGE,
+ .args = { "DdegLlMmP:RT:t:UZ", 0, 0 }, /* -P and -g deprecated */
+ .usage = "[-DdeLlMmRUZ] [-T title] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
@@ -46,8 +46,8 @@ const struct cmd_entry cmd_last_pane_entry = {
.name = "last-pane",
.alias = "lastp",
- .args = { "det:", 0, 0 },
- .usage = "[-de] " CMD_TARGET_WINDOW_USAGE,
+ .args = { "det:Z", 0, 0 },
+ .usage = "[-deZ] " CMD_TARGET_WINDOW_USAGE,
.target = { 't', CMD_FIND_WINDOW, 0 },
@@ -111,12 +111,15 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
else if (args_has(self->args, 'd'))
lastwp->flags |= PANE_INPUTOFF;
else {
- server_unzoom_window(w);
+ if (window_push_zoom(w, args_has(self->args, 'Z')))
+ server_redraw_window(w);
window_redraw_active_switch(w, lastwp);
if (window_set_active_pane(w, lastwp, 1)) {
cmd_find_from_winlink(current, wl, 0);
cmd_select_pane_redraw(w);
}
+ if (window_pop_zoom(w))
+ server_redraw_window(w);
}
return (CMD_RETURN_NORMAL);
}
@@ -161,17 +164,21 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
}
if (args_has(self->args, 'L')) {
- server_unzoom_window(wp->window);
+ window_push_zoom(w, 1);
wp = window_pane_find_left(wp);
+ window_pop_zoom(w);
} else if (args_has(self->args, 'R')) {
- server_unzoom_window(wp->window);
+ window_push_zoom(w, 1);
wp = window_pane_find_right(wp);
+ window_pop_zoom(w);
} else if (args_has(self->args, 'U')) {
- server_unzoom_window(wp->window);
+ window_push_zoom(w, 1);
wp = window_pane_find_up(wp);
+ window_pop_zoom(w);
} else if (args_has(self->args, 'D')) {
- server_unzoom_window(wp->window);
+ window_push_zoom(w, 1);
wp = window_pane_find_down(wp);
+ window_pop_zoom(w);
}
if (wp == NULL)
return (CMD_RETURN_NORMAL);
@@ -196,13 +203,16 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
if (wp == w->active)
return (CMD_RETURN_NORMAL);
- server_unzoom_window(wp->window);
+ if (window_push_zoom(w, args_has(self->args, 'Z')))
+ server_redraw_window(w);
window_redraw_active_switch(w, wp);
if (window_set_active_pane(w, wp, 1)) {
cmd_find_from_winlink_pane(current, wl, wp, 0);
cmdq_insert_hook(s, item, current, "after-select-pane");
cmd_select_pane_redraw(w);
}
+ if (window_pop_zoom(w))
+ server_redraw_window(w);
return (CMD_RETURN_NORMAL);
}
diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c
index 994ad0e8..3e0e6e60 100644
--- a/cmd-swap-pane.c
+++ b/cmd-swap-pane.c
@@ -32,8 +32,8 @@ const struct cmd_entry cmd_swap_pane_entry = {
.name = "swap-pane",
.alias = "swapp",
- .args = { "dDs:t:U", 0, 0 },
- .usage = "[-dDU] " CMD_SRCDST_PANE_USAGE,
+ .args = { "dDs:t:UZ", 0, 0 },
+ .usage = "[-dDUZ] " CMD_SRCDST_PANE_USAGE,
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
.target = { 't', CMD_FIND_PANE, 0 },
@@ -45,6 +45,7 @@ const struct cmd_entry cmd_swap_pane_entry = {
static enum cmd_retval
cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
{
+ struct args *args = self->args;
struct window *src_w, *dst_w;
struct window_pane *tmp_wp, *src_wp, *dst_wp;
struct layout_cell *src_lc, *dst_lc;
@@ -54,23 +55,27 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
dst_wp = item->target.wp;
src_w = item->source.wl->window;
src_wp = item->source.wp;
- server_unzoom_window(dst_w);
- if (args_has(self->args, 'D')) {
+ if (window_push_zoom(dst_w, args_has(args, 'Z')))
+ server_redraw_window(dst_w);
+
+ if (args_has(args, 'D')) {
src_w = dst_w;
src_wp = TAILQ_NEXT(dst_wp, entry);
if (src_wp == NULL)
src_wp = TAILQ_FIRST(&dst_w->panes);
- } else if (args_has(self->args, 'U')) {
+ } else if (args_has(args, 'U')) {
src_w = dst_w;
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
if (src_wp == NULL)
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
}
- server_unzoom_window(src_w);
+
+ if (src_w != dst_w && window_push_zoom(src_w, args_has(args, 'Z')))
+ server_redraw_window(src_w);
if (src_wp == dst_wp)
- return (CMD_RETURN_NORMAL);
+ goto out;
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
@@ -103,7 +108,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
dst_wp->xoff = xoff; dst_wp->yoff = yoff;
window_pane_resize(dst_wp, sx, sy);
- if (!args_has(self->args, 'd')) {
+ if (!args_has(args, 'd')) {
if (src_w != dst_w) {
window_set_active_pane(src_w, dst_wp, 1);
window_set_active_pane(dst_w, src_wp, 1);
@@ -126,5 +131,10 @@ cmd_swap_pane_exec(struct cmd *self, struct cmdq_item *item)
server_redraw_window(src_w);
server_redraw_window(dst_w);
+out:
+ if (window_pop_zoom(src_w))
+ server_redraw_window(src_w);
+ if (src_w != dst_w && window_pop_zoom(dst_w))
+ server_redraw_window(dst_w);
return (CMD_RETURN_NORMAL);
}
diff --git a/cmd-switch-client.c b/cmd-switch-client.c
index 8f51d0fe..309a7e7c 100644
--- a/cmd-switch-client.c
+++ b/cmd-switch-client.c
@@ -34,8 +34,8 @@ const struct cmd_entry cmd_switch_client_entry = {
.name = "switch-client",
.alias = "switchc",
- .args = { "lc:Enpt:rT:", 0, 0 },
- .usage = "[-Elnpr] [-c target-client] [-t target-session] "
+ .args = { "lc:Enpt:rT:Z", 0, 0 },
+ .usage = "[-ElnprZ] [-c target-client] [-t target-session] "
"[-T key-table]",
/* -t is special */
@@ -54,6 +54,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
struct client *c;
struct session *s;
struct winlink *wl;
+ struct window *w;
struct window_pane *wp;
const char *tablename;
struct key_table *table;
@@ -72,6 +73,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
s = item->target.s;
wl = item->target.wl;
+ w = wl->window;
wp = item->target.wp;
if (args_has(args, 'r'))
@@ -112,12 +114,15 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
} else {
if (item->client == NULL)
return (CMD_RETURN_NORMAL);
+ if (wl != NULL && wp != NULL) {
+ if (window_push_zoom(w, args_has(self->args, 'Z')))
+ server_redraw_window(w);
+ window_redraw_active_switch(w, wp);
+ window_set_active_pane(w, wp, 1);
+ if (window_pop_zoom(w))
+ server_redraw_window(w);
+ }
if (wl != NULL) {
- server_unzoom_window(wl->window);
- if (wp != NULL) {
- window_redraw_active_switch(wp->window, wp);
- window_set_active_pane(wp->window, wp, 1);
- }
session_set_current(s, wl);
cmd_find_from_session(&item->shared->current, s, 0);
}
diff --git a/configure.ac b/configure.ac
index 21e8926d..5fba1eaf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
# configure.ac
-AC_INIT([tmux], 3.0-rc4)
+AC_INIT([tmux], next-3.1)
AC_PREREQ([2.60])
AC_CONFIG_AUX_DIR(etc)
diff --git a/format-draw.c b/format-draw.c
index e0ca89f0..6cced9fd 100644
--- a/format-draw.c
+++ b/format-draw.c
@@ -513,8 +513,8 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
int focus_start = -1, focus_end = -1;
int list_state = -1, fill = -1;
enum style_align list_align = STYLE_ALIGN_DEFAULT;
- struct grid_cell gc;
- struct style sy;
+ struct grid_cell gc, current_default;
+ struct style sy, saved_sy;
struct utf8_data *ud = &sy.gc.data;
const char *cp, *end;
enum utf8_state more;
@@ -523,7 +523,8 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
struct format_ranges frs;
struct style_range *sr;
- style_set(&sy, base);
+ memcpy(&current_default, base, sizeof current_default);
+ style_set(&sy, &current_default);
TAILQ_INIT(&frs);
log_debug("%s: %s", __func__, expanded);
@@ -535,7 +536,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
for (i = 0; i < TOTAL; i++) {
screen_init(&s[i], size, 1, 0);
screen_write_start(&ctx[i], NULL, &s[i]);
- screen_write_clearendofline(&ctx[i], base->bg);
+ screen_write_clearendofline(&ctx[i], current_default.bg);
width[i] = 0;
}
@@ -581,7 +582,8 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
goto out;
}
tmp = xstrndup(cp + 2, end - (cp + 2));
- if (style_parse(&sy, base, tmp) != 0) {
+ style_copy(&saved_sy, &sy);
+ if (style_parse(&sy, &current_default, tmp) != 0) {
log_debug("%s: invalid style '%s'", __func__, tmp);
free(tmp);
cp = end + 1;
@@ -595,6 +597,15 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
if (sy.fill != 8)
fill = sy.fill;
+ /* If this style pushed or popped the default, update it. */
+ if (sy.default_type == STYLE_DEFAULT_PUSH) {
+ memcpy(&current_default, &saved_sy.gc, sizeof current_default);
+ sy.default_type = STYLE_DEFAULT_BASE;
+ } else if (sy.default_type == STYLE_DEFAULT_POP) {
+ memcpy(&current_default, base, sizeof current_default);
+ sy.default_type = STYLE_DEFAULT_BASE;
+ }
+
/* Check the list state. */
switch (sy.list) {
case STYLE_LIST_ON:
diff --git a/format.c b/format.c
index eb7a9e53..2e041e6d 100644
--- a/format.c
+++ b/format.c
@@ -962,7 +962,6 @@ format_each(struct format_tree *ft, void (*cb)(const char *, const char *,
}
}
-
/* Add a key-value pair. */
void
format_add(struct format_tree *ft, const char *key, const char *fmt, ...)
@@ -2214,6 +2213,11 @@ format_defaults_winlink(struct format_tree *ft, struct winlink *wl)
format_add(ft, "window_end_flag", "%d",
!!(wl == RB_MAX(winlinks, &s->windows)));
+ if (server_check_marked() && marked_pane.wl == wl)
+ format_add(ft, "window_marked_flag", "1");
+ else
+ format_add(ft, "window_marked_flag", "0");
+
format_add(ft, "window_bell_flag", "%d",
!!(wl->flags & WINLINK_BELL));
format_add(ft, "window_activity_flag", "%d",
diff --git a/key-bindings.c b/key-bindings.c
index 0c9ba67b..df2dcf46 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -69,7 +69,6 @@
" '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}" \
" '#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}"
-
static int key_bindings_cmp(struct key_binding *, struct key_binding *);
RB_GENERATE_STATIC(key_bindings, key_binding, entry, key_bindings_cmp);
static int key_table_cmp(struct key_table *, struct key_table *);
diff --git a/mode-tree.c b/mode-tree.c
index 03a91ef8..054989fb 100644
--- a/mode-tree.c
+++ b/mode-tree.c
@@ -39,7 +39,7 @@ struct mode_tree_data {
const char **sort_list;
u_int sort_size;
- u_int sort_type;
+ struct mode_tree_sort_criteria sort_crit;
mode_tree_build_cb buildcb;
mode_tree_draw_cb drawcb;
@@ -334,7 +334,6 @@ mode_tree_start(struct window_pane *wp, struct args *args,
mtd->sort_list = sort_list;
mtd->sort_size = sort_size;
- mtd->sort_type = 0;
mtd->preview = !args_has(args, 'N');
@@ -342,9 +341,10 @@ mode_tree_start(struct window_pane *wp, struct args *args,
if (sort != NULL) {
for (i = 0; i < sort_size; i++) {
if (strcasecmp(sort, sort_list[i]) == 0)
- mtd->sort_type = i;
+ mtd->sort_crit.field = i;
}
}
+ mtd->sort_crit.reversed = args_has(args, 'r');
if (args_has(args, 'f'))
mtd->filter = xstrdup(args_get(args, 'f'));
@@ -392,10 +392,10 @@ mode_tree_build(struct mode_tree_data *mtd)
TAILQ_CONCAT(&mtd->saved, &mtd->children, entry);
TAILQ_INIT(&mtd->children);
- mtd->buildcb(mtd->modedata, mtd->sort_type, &tag, mtd->filter);
+ mtd->buildcb(mtd->modedata, &mtd->sort_crit, &tag, mtd->filter);
mtd->no_matches = TAILQ_EMPTY(&mtd->children);
if (mtd->no_matches)
- mtd->buildcb(mtd->modedata, mtd->sort_type, &tag, NULL);
+ mtd->buildcb(mtd->modedata, &mtd->sort_crit, &tag, NULL);
mode_tree_free_items(&mtd->saved);
TAILQ_INIT(&mtd->saved);
@@ -634,8 +634,9 @@ mode_tree_draw(struct mode_tree_data *mtd)
screen_write_cursormove(&ctx, 0, h, 0);
screen_write_box(&ctx, w, sy - h);
- xasprintf(&text, " %s (sort: %s)", mti->name,
- mtd->sort_list[mtd->sort_type]);
+ xasprintf(&text, " %s (sort: %s%s)", mti->name,
+ mtd->sort_list[mtd->sort_crit.field],
+ mtd->sort_crit.reversed ? ", reversed" : "");
if (w - 2 >= strlen(text)) {
screen_write_cursormove(&ctx, 1, h, 0);
screen_write_puts(&ctx, &gc0, "%s", text);
@@ -993,9 +994,13 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key,
}
break;
case 'O':
- mtd->sort_type++;
- if (mtd->sort_type == mtd->sort_size)
- mtd->sort_type = 0;
+ mtd->sort_crit.field++;
+ if (mtd->sort_crit.field == mtd->sort_size)
+ mtd->sort_crit.field = 0;
+ mode_tree_build(mtd);
+ break;
+ case 'r':
+ mtd->sort_crit.reversed = !mtd->sort_crit.reversed;
mode_tree_build(mtd);
break;
case KEYC_LEFT:
diff --git a/options-table.c b/options-table.c
index ba7db3e1..66276e0b 100644
--- a/options-table.c
+++ b/options-table.c
@@ -91,7 +91,9 @@ static const char *options_table_window_size_list[] = {
"}" \
"}" \
"]" \
+ "#[push-default]" \
"#{T:window-status-format}" \
+ "#[pop-default]" \
"#[norange default]" \
"#{?window_end_flag,,#{window-status-separator}}" \
"," \
@@ -116,7 +118,9 @@ static const char *options_table_window_size_list[] = {
"}" \
"}" \
"]" \
+ "#[push-default]" \
"#{T:window-status-current-format}" \
+ "#[pop-default]" \
"#[norange list=on default]" \
"#{?window_end_flag,,#{window-status-separator}}" \
"}" \
diff --git a/server-client.c b/server-client.c
index f44631c9..62862634 100644
--- a/server-client.c
+++ b/server-client.c
@@ -42,6 +42,7 @@ static void server_client_set_title(struct client *);
static void server_client_reset_state(struct client *);
static int server_client_assume_paste(struct session *);
static void server_client_clear_overlay(struct client *);
+static void server_client_resize_event(int, short, void *);
static void server_client_dispatch(struct imsg *, void *);
static void server_client_dispatch_command(struct client *, struct imsg *);
@@ -1320,19 +1321,11 @@ server_client_resize_force(struct window_pane *wp)
return (1);
}
-/* Resize timer event. */
+/* Resize a pane. */
static void
-server_client_resize_event(__unused int fd, __unused short events, void *data)
+server_client_resize_pane(struct window_pane *wp)
{
- struct window_pane *wp = data;
- struct winsize ws;
-
- evtimer_del(&wp->resize_timer);
-
- if (!(wp->flags & PANE_RESIZE))
- return;
- if (server_client_resize_force(wp))
- return;
+ struct winsize ws;
memset(&ws, 0, sizeof ws);
ws.ws_col = wp->sx;
@@ -1356,35 +1349,55 @@ server_client_resize_event(__unused int fd, __unused short events, void *data)
wp->osy = wp->sy;
}
+/* Start the resize timer. */
+static void
+server_client_start_resize_timer(struct window_pane *wp)
+{
+ struct timeval tv = { .tv_usec = 250000 };
+
+ if (!evtimer_pending(&wp->resize_timer, NULL))
+ evtimer_add(&wp->resize_timer, &tv);
+}
+
+/* Resize timer event. */
+static void
+server_client_resize_event(__unused int fd, __unused short events, void *data)
+{
+ struct window_pane *wp = data;
+
+ evtimer_del(&wp->resize_timer);
+
+ if (~wp->flags & PANE_RESIZE)
+ return;
+ log_debug("%s: %%%u timer fired (was%s resized)", __func__, wp->id,
+ (wp->flags & PANE_RESIZED) ? "" : " not");
+
+ if (wp->saved_grid == NULL && (wp->flags & PANE_RESIZED)) {
+ log_debug("%s: %%%u deferring timer", __func__, wp->id);
+ server_client_start_resize_timer(wp);
+ } else if (!server_client_resize_force(wp)) {
+ log_debug("%s: %%%u resizing pane", __func__, wp->id);
+ server_client_resize_pane(wp);
+ }
+ wp->flags &= ~PANE_RESIZED;
+}
+
/* Check if pane should be resized. */
static void
server_client_check_resize(struct window_pane *wp)
{
- struct timeval tv = { .tv_usec = 250000 };
-
- if (!(wp->flags & PANE_RESIZE))
+ if (~wp->flags & PANE_RESIZE)
return;
- log_debug("%s: %%%u resize to %u,%u", __func__, wp->id, wp->sx, wp->sy);
if (!event_initialized(&wp->resize_timer))
evtimer_set(&wp->resize_timer, server_client_resize_event, wp);
- /*
- * The first resize should happen immediately, so if the timer is not
- * running, do it now.
- */
- if (!evtimer_pending(&wp->resize_timer, NULL))
- server_client_resize_event(-1, 0, wp);
-
- /*
- * If the pane is in the alternate screen, let the timer expire and
- * resize to give the application a chance to redraw. If not, keep
- * pushing the timer back.
- */
- if (wp->saved_grid != NULL && evtimer_pending(&wp->resize_timer, NULL))
- return;
- evtimer_del(&wp->resize_timer);
- evtimer_add(&wp->resize_timer, &tv);
+ if (!evtimer_pending(&wp->resize_timer, NULL)) {
+ log_debug("%s: %%%u starting timer", __func__, wp->id);
+ server_client_resize_pane(wp);
+ server_client_start_resize_timer(wp);
+ } else
+ log_debug("%s: %%%u timer running", __func__, wp->id);
}
/* Check whether pane should be focused. */
diff --git a/style.c b/style.c
index 9f986314..6ba4c524 100644
--- a/style.c
+++ b/style.c
@@ -36,13 +36,15 @@ static struct style style_default = {
STYLE_ALIGN_DEFAULT,
STYLE_LIST_OFF,
- STYLE_RANGE_NONE, 0
+ STYLE_RANGE_NONE, 0,
+
+ STYLE_DEFAULT_BASE
};
/*
- * Parse an embedded style of the form "fg=colour,bg=colour,bright,...".
- * Note that this adds onto the given style, so it must have been initialized
- * alredy.
+ * Parse an embedded style of the form "fg=colour,bg=colour,bright,...". Note
+ * that this adds onto the given style, so it must have been initialized
+ * already.
*/
int
style_parse(struct style *sy, const struct grid_cell *base, const char *in)
@@ -74,7 +76,11 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
sy->gc.bg = base->bg;
sy->gc.attr = base->attr;
sy->gc.flags = base->flags;
- } else if (strcasecmp(tmp, "nolist") == 0)
+ } else if (strcasecmp(tmp, "push-default") == 0)
+ sy->default_type = STYLE_DEFAULT_PUSH;
+ else if (strcasecmp(tmp, "pop-default") == 0)
+ sy->default_type = STYLE_DEFAULT_POP;
+ else if (strcasecmp(tmp, "nolist") == 0)
sy->list = STYLE_LIST_OFF;
else if (strncasecmp(tmp, "list=", 5) == 0) {
if (strcasecmp(tmp + 5, "on") == 0)
@@ -218,6 +224,14 @@ style_tostring(struct style *sy)
tmp);
comma = ",";
}
+ if (sy->default_type != STYLE_DEFAULT_BASE) {
+ if (sy->default_type == STYLE_DEFAULT_PUSH)
+ tmp = "push-default";
+ else if (sy->default_type == STYLE_DEFAULT_POP)
+ tmp = "pop-default";
+ off += xsnprintf(s + off, sizeof s - off, "%s%s", comma, tmp);
+ comma = ",";
+ }
if (sy->fill != 8) {
off += xsnprintf(s + off, sizeof s - off, "%sfill=%s", comma,
colour_tostring(sy->fill));
@@ -257,21 +271,6 @@ style_apply(struct grid_cell *gc, struct options *oo, const char *name)
gc->attr |= sy->gc.attr;
}
-/* Apply a style, updating if default. */
-void
-style_apply_update(struct grid_cell *gc, struct options *oo, const char *name)
-{
- struct style *sy;
-
- sy = options_get_style(oo, name);
- if (sy->gc.fg != 8)
- gc->fg = sy->gc.fg;
- if (sy->gc.bg != 8)
- gc->bg = sy->gc.bg;
- if (sy->gc.attr != 0)
- gc->attr |= sy->gc.attr;
-}
-
/* Initialize style from cell. */
void
style_set(struct style *sy, const struct grid_cell *gc)
diff --git a/tmux.1 b/tmux.1
index 227ed36b..a9e82f87 100644
--- a/tmux.1
+++ b/tmux.1
@@ -296,6 +296,12 @@ Prompt to search for text in open windows.
Display some information about the current window.
.It l
Move to the previously selected window.
+.It m
+Mark the current pane (see
+.Ic select-pane
+.Fl m ) .
+.It M
+Clear the marked pane.
.It n
Change to the next window.
.It o
@@ -306,12 +312,6 @@ Change to the previous window.
Briefly display pane indexes.
.It r
Force redraw of the attached client.
-.It m
-Mark the current pane (see
-.Ic select-pane
-.Fl m ) .
-.It M
-Clear the marked pane.
.It s
Select a new session for the attached client interactively.
.It t
@@ -1156,7 +1156,7 @@ The
.Fl P
option prints information about the new session after it has been created.
By default, it uses the format
-.Ql #{session_name}:
+.Ql #{session_name}:\&
but a different format may be specified with
.Fl F .
.Pp
@@ -1296,7 +1296,7 @@ Suspend a client by sending
.Dv SIGTSTP
(tty stop).
.It Xo Ic switch-client
-.Op Fl Elnpr
+.Op Fl ElnprZ
.Op Fl c Ar target-client
.Op Fl t Ar target-session
.Op Fl T Ar key-table
@@ -1313,7 +1313,10 @@ may refer to a pane (a target that contains
.Ql \&.
or
.Ql % ) ,
-in which case the session, window and pane are all changed.
+to change session, window and pane.
+In that case,
+.Fl Z
+keeps the window zoomed if it was zoomed.
If
.Fl l ,
.Fl n
@@ -1349,11 +1352,41 @@ bind-key -Troot a switch-client -Ttable1
.Ed
.El
.Sh WINDOWS AND PANES
-A
+Each window displayed by
+.Nm
+may be split into one or more
+.Em panes ;
+each pane takes up a certain area of the display and is a separate terminal.
+A window may be split into panes using the
+.Ic split-window
+command.
+Windows may be split horizontally (with the
+.Fl h
+flag) or vertically.
+Panes may be resized with the
+.Ic resize-pane
+command (bound to
+.Ql C-Up ,
+.Ql C-Down
+.Ql C-Left
+and
+.Ql C-Right
+by default), the current pane may be changed with the
+.Ic select-pane
+command and the
+.Ic rotate-window
+and
+.Ic swap-pane
+commands may be used to swap panes without changing their position.
+Panes are numbered beginning from zero in the order they are created.
+.Pp
+By default, a
.Nm
-window may be in one of two modes.
-The default permits direct access to the terminal attached to the window.
-The other is copy mode, which permits a section of a window or its
+pane permits direct access to the terminal contained in the pane.
+A pane may also be put into one of several modes:
+.Bl -dash -offset indent
+.It
+Copy mode, which permits a section of a window or its
history to be copied to a
.Em paste buffer
for later insertion into another window.
@@ -1362,9 +1395,21 @@ This mode is entered with the
command, bound to
.Ql \&[
by default.
-It is also entered when a command that produces output, such as
+.It
+View mode, which is like copy mode but is entered when a command that produces
+output, such as
.Ic list-keys ,
is executed from a key binding.
+.It
+Choose mode, which allows an item to be chosen from a list.
+This may be a client, a session or window or pane, or a buffer.
+This mode is entered with the
+.Ic choose-buffer ,
+.Ic choose-client
+and
+.Ic choose-tree
+commands.
+.El
.Pp
In copy mode an indicator is displayed in the top-right corner of the pane with
the current position and the number of lines in the history.
@@ -1405,6 +1450,7 @@ The following commands are supported in copy mode:
.It Li "copy-selection-no-clear [<prefix>]" Ta "" Ta ""
.It Li "copy-selection-and-cancel [<prefix>]" Ta "Enter" Ta "M-w"
.It Li "cursor-down" Ta "j" Ta "Down"
+.It Li "cursor-down-and-cancel" Ta "" Ta ""
.It Li "cursor-left" Ta "h" Ta "Left"
.It Li "cursor-right" Ta "l" Ta "Right"
.It Li "cursor-up" Ta "k" Ta "Up"
@@ -1526,37 +1572,7 @@ bind PageUp copy-mode -eu
.Ed
.El
.Pp
-Each window displayed by
-.Nm
-may be split into one or more
-.Em panes ;
-each pane takes up a certain area of the display and is a separate terminal.
-A window may be split into panes using the
-.Ic split-window
-command.
-Windows may be split horizontally (with the
-.Fl h
-flag) or vertically.
-Panes may be resized with the
-.Ic resize-pane
-command (bound to
-.Ql C-Up ,
-.Ql C-Down
-.Ql C-Left
-and
-.Ql C-Right
-by default), the current pane may be changed with the
-.Ic select-pane
-command and the
-.Ic rotate-window
-and
-.Ic swap-pane
-commands may be used to swap panes without changing their position.
-Panes are numbered beginning from zero in the order they are created.
-.Pp
-A number of preset
-.Em layouts
-are available.
+A number of preset arrangements of panes are available, these are called layouts.
These may be selected with the
.Ic select-layout
command or cycled with
@@ -1635,7 +1651,7 @@ By default, it uses the format
but a different format may be specified with
.Fl F .
.It Xo Ic capture-pane
-.Op Fl aepPqCJ
+.Op Fl aepPqCJN
.Op Fl b Ar buffer-name
.Op Fl E Ar end-line
.Op Fl S Ar start-line
@@ -1660,8 +1676,10 @@ is given, the output includes escape sequences for text and background
attributes.
.Fl C
also escapes non-printable characters as octal \exxx.
+.Fl N
+preserves trailing spaces at each line's end and
.Fl J
-joins wrapped lines and preserves trailing spaces at each line's end.
+preserves trailing spaces and joins any wrapped lines.
.Fl P
captures only any output that the pane has received that is the beginning of an
as-yet incomplete escape sequence.
@@ -1680,7 +1698,7 @@ the end of the visible pane.
The default is to capture only the visible contents of the pane.
.It Xo
.Ic choose-client
-.Op Fl NZ
+.Op Fl NrZ
.Op Fl F Ar format
.Op Fl f Ar filter
.Op Fl O Ar sort-order
@@ -1709,7 +1727,8 @@ The following keys may be used in client mode:
.It Li "z" Ta "Suspend selected client"
.It Li "Z" Ta "Suspend tagged clients"
.It Li "f" Ta "Enter a format to filter items"
-.It Li "O" Ta "Change sort order"
+.It Li "O" Ta "Change sort field"
+.It Li "r" Ta "Reverse sort order"
.It Li "v" Ta "Toggle preview"
.It Li "q" Ta "Exit mode"
.El
@@ -1724,12 +1743,14 @@ If
is not given, "detach-client -t '%%'" is used.
.Pp
.Fl O
-specifies the initial sort order: one of
+specifies the initial sort field: one of
.Ql name ,
.Ql size ,
.Ql creation ,
or
.Ql activity .
+.Fl r
+reverses the sort order.
.Fl f
specifies an initial filter: the filter is a format - if it evaluates to zero,
the item in the list is not shown, otherwise it is shown.
@@ -1741,7 +1762,7 @@ starts without the preview.
This command works only if at least one client is attached.
.It Xo
.Ic choose-tree
-.Op Fl GNswZ
+.Op Fl GNrswZ
.Op Fl F Ar format
.Op Fl f Ar filter
.Op Fl O Ar sort-order
@@ -1773,7 +1794,8 @@ The following keys may be used in tree mode:
.It Li "C-t" Ta "Tag all items"
.It Li "\&:" Ta "Run a command for each tagged item"
.It Li "f" Ta "Enter a format to filter items"
-.It Li "O" Ta "Change sort order"
+.It Li "O" Ta "Change sort field"
+.It Li "r" Ta "Reverse sort order"
.It Li "v" Ta "Toggle preview"
.It Li "q" Ta "Exit mode"
.El
@@ -1788,11 +1810,13 @@ If
is not given, "switch-client -t '%%'" is used.
.Pp
.Fl O
-specifies the initial sort order: one of
+specifies the initial sort field: one of
.Ql index ,
.Ql name ,
or
.Ql time .
+.Fl r
+reverses the sort order.
.Fl f
specifies an initial filter: the filter is a format - if it evaluates to zero,
the item in the list is not shown, otherwise it is shown.
@@ -1925,11 +1949,13 @@ The
option kills all but the window given with
.Fl t .
.It Xo Ic last-pane
-.Op Fl de
+.Op Fl deZ
.Op Fl t Ar target-window
.Xc
.D1 (alias: Ic lastp )
Select the last (previously selected) pane.
+.Fl Z
+keeps the window zoomed if it was zoomed.
.Fl e
enables or
.Fl d
@@ -2311,7 +2337,7 @@ option has the same meaning as for the
.Ic new-window
command.
.It Xo Ic rotate-window
-.Op Fl DU
+.Op Fl DUZ
.Op Fl t Ar target-window
.Xc
.D1 (alias: Ic rotatew )
@@ -2319,6 +2345,8 @@ Rotate the positions of the panes within a window, either upward (numerically
lower) with
.Fl U
or downward (numerically higher).
+.Fl Z
+keeps the window zoomed if it was zoomed.
.It Xo Ic select-layout
.Op Fl Enop
.Op Fl t Ar target-pane
@@ -2342,7 +2370,7 @@ applies the last set layout if possible (undoes the most recent layout change).
.Fl E
spreads the current pane and any panes next to it out evenly.
.It Xo Ic select-pane
-.Op Fl DdeLlMmRU
+.Op Fl DdeLlMmRUZ
.Op Fl T Ar title
.Op Fl t Ar target-pane
.Xc
@@ -2359,6 +2387,8 @@ or
.Fl U
is used, respectively the pane below, to the left, to the right, or above the
target pane is used.
+.Fl Z
+keeps the window zoomed if it was zoomed.
.Fl l
is the same as using the
.Ic last-pane
@@ -2464,7 +2494,7 @@ All other options have the same meaning as for the
.Ic new-window
command.
.It Xo Ic swap-pane
-.Op Fl dDU
+.Op Fl dDUZ
.Op Fl s Ar src-pane
.Op Fl t Ar dst-pane
.Xc
@@ -2481,7 +2511,9 @@ swaps with the next pane (after it numerically).
.Fl d
instructs
.Nm
-not to change the active pane.
+not to change the active pane and
+.Fl Z
+keeps the window zoomed if it was zoomed.
.Pp
If
.Fl s
@@ -2716,7 +2748,7 @@ and
.Pp
The
.Nm
-server has a set of global options which do not apply to any particular
+server has a set of global server options which do not apply to any particular
window or session or pane.
These are altered with the
.Ic set-option
@@ -4060,7 +4092,7 @@ will append
if the pane title is more than five characters.
.Pp
Prefixing a time variable with
-.Ql t:
+.Ql t:\&
will convert it to a string, so if
.Ql #{window_activity}
gives
@@ -4069,34 +4101,34 @@ gives
gives
.Ql Sun Oct 25 09:25:02 2015 .
The
-.Ql b:
+.Ql b:\&
and
-.Ql d:
+.Ql d:\&
prefixes are
.Xr basename 3
and
.Xr dirname 3
of the variable respectively.
-.Ql q:
+.Ql q:\&
will escape
.Xr sh 1
special characters.
-.Ql E:
+.Ql E:\&
will expand the format twice, for example
.Ql #{E:status-left}
is the result of expanding the content of the
.Ic status-left
option rather than the option itself.
-.Ql T:
+.Ql T:\&
is like
-.Ql E:
+.Ql E:\&
but also expands
.Xr strftime 3
specifiers.
-.Ql S: ,
-.Ql W:
+.Ql S:\& ,
+.Ql W:\&
or
-.Ql P:
+.Ql P:\&
will loop over each session, window or pane and insert the format once
for each.
For windows and panes, two comma-separated formats may be given:
@@ -4107,7 +4139,7 @@ For example, to get a list of windows formatted like the status line:
.Ed
.Pp
A prefix of the form
-.Ql s/foo/bar/:
+.Ql s/foo/bar/:\&
will substitute
.Ql foo
with
@@ -4116,7 +4148,7 @@ throughout.
The first argument may be an extended regular expression and a final argument may be
.Ql i
to ignore case, for example
-.Ql s/a(.)/\e1x/i:
+.Ql s/a(.)/\e1x/i:\&
would change
.Ql abABab
into
@@ -4280,6 +4312,7 @@ The following variables are available, where appropriate:
.It Li "window_last_flag" Ta "" Ta "1 if window is the last used"
.It Li "window_layout" Ta "" Ta "Window layout description, ignoring zoomed window panes"
.It Li "window_linked" Ta "" Ta "1 if window is linked across sessions"
+.It Li "window_marked_flag" Ta "" Ta "1 if window contains the marked pane"
.It Li "window_name" Ta "#W" Ta "Name of window"
.It Li "window_offset_x" Ta "" Ta "X offset into window if larger than client"
.It Li "window_offset_y" Ta "" Ta "Y offset into window if larger than client"
@@ -4307,7 +4340,9 @@ and
.Pp
A style may be the single term
.Ql default
-to specify the default style (which may inherit from another option) or a space
+to specify the default style (which may come from an option, for example
+.Ic status-style
+in the status line) or a space
or comma separated list of the following:
.Bl -tag -width Ds
.It Ic fg=colour
@@ -4386,6 +4421,20 @@ and
.Ic list=right-marker
mark the text to be used to mark that text has been trimmed from the left or
right of the list if there is not enough space.
+.It Xo Ic push-default ,
+.Ic pop-default
+.Xc
+Store the current colours and attributes as the default or reset to the previous
+default.
+A
+.Ic push-default
+affects any subsequent use of the
+.Ic default
+term until a
+.Ic pop-default .
+Only one default may be pushed (each
+.Ic push-default
+replaces the previous saved default).
.It Xo Ic range=left ,
.Ic range=right ,
.Ic range=window|X ,
@@ -4842,7 +4891,7 @@ The buffer commands are as follows:
.Bl -tag -width Ds
.It Xo
.Ic choose-buffer
-.Op Fl NZ
+.Op Fl NZr
.Op Fl F Ar format
.Op Fl f Ar filter
.Op Fl O Ar sort-order
@@ -4869,7 +4918,8 @@ The following keys may be used in buffer mode:
.It Li "d" Ta "Delete selected buffer"
.It Li "D" Ta "Delete tagged buffers"
.It Li "f" Ta "Enter a format to filter items"
-.It Li "O" Ta "Change sort order"
+.It Li "O" Ta "Change sort field"
+.It Li "r" Ta "Reverse sort order"
.It Li "v" Ta "Toggle preview"
.It Li "q" Ta "Exit mode"
.El
@@ -4884,11 +4934,13 @@ If
is not given, "paste-buffer -b '%%'" is used.
.Pp
.Fl O
-specifies the initial sort order: one of
+specifies the initial sort field: one of
.Ql time ,
.Ql name
or
.Ql size .
+.Fl r
+reverses the sort order.
.Fl f
specifies an initial filter: the filter is a format - if it evaluates to zero,
the item in the list is not shown, otherwise it is shown.
diff --git a/tmux.h b/tmux.h
index 9bf9f933..cfdc79a2 100644
--- a/tmux.h
+++ b/tmux.h
@@ -682,6 +682,13 @@ struct style_range {
};
TAILQ_HEAD(style_ranges, style_range);
+/* Style default. */
+enum style_default_type {
+ STYLE_DEFAULT_BASE,
+ STYLE_DEFAULT_PUSH,
+ STYLE_DEFAULT_POP
+};
+
/* Style option. */
struct style {
struct grid_cell gc;
@@ -692,6 +699,8 @@ struct style {
enum style_range_type range_type;
u_int range_argument;
+
+ enum style_default_type default_type;
};
/* Virtual screen. */
@@ -845,6 +854,7 @@ struct window_pane {
#define PANE_STATUSDRAWN 0x400
#define PANE_EMPTY 0x800
#define PANE_STYLECHANGED 0x1000
+#define PANE_RESIZED 0x2000
int argc;
char **argv;
@@ -924,6 +934,7 @@ struct window {
#define WINDOW_ACTIVITY 0x2
#define WINDOW_SILENCE 0x4
#define WINDOW_ZOOMED 0x8
+#define WINDOW_WASZOOMED 0x10
#define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
int alerts_queued;
@@ -1683,6 +1694,12 @@ struct spawn_context {
#define SPAWN_EMPTY 0x40
};
+/* Mode tree sort order. */
+struct mode_tree_sort_criteria {
+ u_int field;
+ int reversed;
+};
+
/* tmux.c */
extern struct options *global_options;
extern struct options *global_s_options;
@@ -2383,6 +2400,8 @@ struct window_pane *window_add_pane(struct window *, struct window_pane *,
void window_resize(struct window *, u_int, u_int);
int window_zoom(struct window_pane *);
int window_unzoom(struct window *);
+int window_push_zoom(struct window *, int);
+int window_pop_zoom(struct window *);
void window_lost_pane(struct window *, struct window_pane *);
void window_remove_pane(struct window *, struct window_pane *);
struct window_pane *window_pane_at_index(struct window *, u_int);
@@ -2472,7 +2491,8 @@ u_int layout_set_next(struct window *);
u_int layout_set_previous(struct window *);
/* mode-tree.c */
-typedef void (*mode_tree_build_cb)(void *, u_int, uint64_t *, const char *);
+typedef void (*mode_tree_build_cb)(void *, struct mode_tree_sort_criteria *,
+ uint64_t *, const char *);
typedef void (*mode_tree_draw_cb)(void *, void *, struct screen_write_ctx *,
u_int, u_int);
typedef int (*mode_tree_search_cb)(void *, void *, const char *);
@@ -2641,8 +2661,6 @@ int style_parse(struct style *,const struct grid_cell *,
const char *style_tostring(struct style *);
void style_apply(struct grid_cell *, struct options *,
const char *);
-void style_apply_update(struct grid_cell *, struct options *,
- const char *);
int style_equal(struct style *, struct style *);
void style_set(struct style *, const struct grid_cell *);
void style_copy(struct style *, struct style *);
diff --git a/window-buffer.c b/window-buffer.c
index 224dfedb..5c897341 100644
--- a/window-buffer.c
+++ b/window-buffer.c
@@ -74,6 +74,7 @@ static const char *window_buffer_sort_list[] = {
"name",
"size"
};
+static struct mode_tree_sort_criteria *window_buffer_sort;
struct window_buffer_itemdata {
const char *name;
@@ -112,43 +113,29 @@ window_buffer_free_item(struct window_buffer_itemdata *item)
}
static int
-window_buffer_cmp_name(const void *a0, const void *b0)
+window_buffer_cmp(const void *a0, const void *b0)
{
- const struct window_buffer_itemdata *const *a = a0;
- const struct window_buffer_itemdata *const *b = b0;
-
- return (strcmp((*a)->name, (*b)->name));
-}
-
-static int
-window_buffer_cmp_time(const void *a0, const void *b0)
-{
- const struct window_buffer_itemdata *const *a = a0;
- const struct window_buffer_itemdata *const *b = b0;
-
- if ((*a)->order > (*b)->order)
- return (-1);
- if ((*a)->order < (*b)->order)
- return (1);
- return (strcmp((*a)->name, (*b)->name));
-}
-
-static int
-window_buffer_cmp_size(const void *a0, const void *b0)
-{
- const struct window_buffer_itemdata *const *a = a0;
- const struct window_buffer_itemdata *const *b = b0;
-
- if ((*a)->size > (*b)->size)
- return (-1);
- if ((*a)->size < (*b)->size)
- return (1);
- return (strcmp((*a)->name, (*b)->name));
+ const struct window_buffer_itemdata *const *a = a0;
+ const struct window_buffer_itemdata *const *b = b0;
+ int result = 0;
+
+ if (window_buffer_sort->field == WINDOW_BUFFER_BY_TIME)
+ result = (*b)->order - (*a)->order;
+ else if (window_buffer_sort->field == WINDOW_BUFFER_BY_SIZE)
+ result = (*b)->size - (*a)->size;
+
+ /* Use WINDOW_BUFFER_BY_NAME as default order and tie breaker. */
+ if (result == 0)
+ result = strcmp((*a)->name, (*b)->name);
+
+ if (window_buffer_sort->reversed)
+ result = -result;
+ return (result);
}
static void
-window_buffer_build(void *modedata, u_int sort_type, __unused uint64_t *tag,
- const char *filter)
+window_buffer_build(void *modedata, struct mode_tree_sort_criteria *sort_crit,
+ __unused uint64_t *tag, const char *filter)
{
struct window_buffer_modedata *data = modedata;
struct window_buffer_itemdata *item;
@@ -174,20 +161,9 @@ window_buffer_build(void *modedata, u_int sort_type, __unused uint64_t *tag,
item->order = paste_buffer_order(pb);
}
- switch (sort_type) {
- case WINDOW_BUFFER_BY_NAME:
- qsort(data->item_list, data->item_size, sizeof *data->item_list,
- window_buffer_cmp_name);
- break;
- case WINDOW_BUFFER_BY_TIME:
- qsort(data->item_list, data->item_size, sizeof *data->item_list,
- window_buffer_cmp_time);
- break;
- case WINDOW_BUFFER_BY_SIZE:
- qsort(data->item_list, data->item_size, sizeof *data->item_list,
- window_buffer_cmp_size);
- break;
- }
+ window_buffer_sort = sort_crit;
+ qsort(data->item_list, data->item_size, sizeof *data->item_list,
+ window_buffer_cmp);
if (cmd_find_valid_state(&data->fs)) {
s = data->fs.s;
diff --git a/window-client.c b/window-client.c
index d85414ea..2ca9c012 100644
--- a/window-client.c
+++ b/window-client.c
@@ -75,6 +75,7 @@ static const char *window_client_sort_list[] = {
"creation",
"activity"
};
+static struct mode_tree_sort_criteria *window_client_sort;
struct window_client_itemdata {
struct client *c;
@@ -110,60 +111,48 @@ window_client_free_item(struct window_client_itemdata *item)
}
static int
-window_client_cmp_name(const void *a0, const void *b0)
+window_client_cmp(const void *a0, const void *b0)
{
- const struct window_client_itemdata *const *a = a0;
- const struct window_client_itemdata *const *b = b0;
-
- return (strcmp((*a)->c->name, (*b)->c->name));
-}
-
-static int
-window_client_cmp_size(const void *a0, const void *b0)
-{
- const struct window_client_itemdata *const *a = a0;
- const struct window_client_itemdata *const *b = b0;
-
- if ((*a)->c->tty.sx < (*b)->c->tty.sx)
- return (-1);
- if ((*a)->c->tty.sx > (*b)->c->tty.sx)
- return (1);
- if ((*a)->c->tty.sy < (*b)->c->tty.sy)
- return (-1);
- if ((*a)->c->tty.sy > (*b)->c->tty.sy)
- return (1);
- return (strcmp((*a)->c->name, (*b)->c->name));
-}
+ const struct window_client_itemdata *const *a = a0;
+ const struct window_client_itemdata *const *b = b0;
+ const struct window_client_itemdata *itema = *a;
+ const struct window_client_itemdata *itemb = *b;
+ struct client *ca = itema->c;
+ struct client *cb = itemb->c;
+ int result = 0;
+
+ switch (window_client_sort->field) {
+ case WINDOW_CLIENT_BY_SIZE:
+ result = ca->tty.sx - cb->tty.sx;
+ if (result == 0)
+ result = ca->tty.sy - cb->tty.sy;
+ break;
+ case WINDOW_CLIENT_BY_CREATION_TIME:
+ if (timercmp(&ca->creation_time, &cb->creation_time, >))
+ result = -1;
+ else if (timercmp(&ca->creation_time, &cb->creation_time, <))
+ result = 1;
+ break;
+ case WINDOW_CLIENT_BY_ACTIVITY_TIME:
+ if (timercmp(&ca->activity_time, &cb->activity_time, >))
+ result = -1;
+ else if (timercmp(&ca->activity_time, &cb->activity_time, <))
+ result = 1;
+ break;
+ }
-static int
-window_client_cmp_creation_time(const void *a0, const void *b0)
-{
- const struct window_client_itemdata *const *a = a0;
- const struct window_client_itemdata *const *b = b0;
-
- if (timercmp(&(*a)->c->creation_time, &(*b)->c->creation_time, >))
- return (-1);
- if (timercmp(&(*a)->c->creation_time, &(*b)->c->creation_time, <))
- return (1);
- return (strcmp((*a)->c->name, (*b)->c->name));
-}
+ /* Use WINDOW_CLIENT_BY_NAME as default order and tie breaker. */
+ if (result == 0)
+ result = strcmp(ca->name, cb->name);
-static int
-window_client_cmp_activity_time(const void *a0, const void *b0)
-{
- const struct window_client_itemdata *const *a = a0;
- const struct window_client_itemdata *const *b = b0;
-
- if (timercmp(&(*a)->c->activity_time, &(*b)->c->activity_time, >))
- return (-1);
- if (timercmp(&(*a)->c->activity_time, &(*b)->c->activity_time, <))
- return (1);
- return (strcmp((*a)->c->name, (*b)->c->name));
+ if (window_client_sort->reversed)
+ result = -result;
+ return (result);
}
static void
-window_client_build(void *modedata, u_int sort_type, __unused uint64_t *tag,
- const char *filter)
+window_client_build(void *modedata, struct mode_tree_sort_criteria *sort_crit,
+ __unused uint64_t *tag, const char *filter)
{
struct window_client_modedata *data = modedata;
struct window_client_itemdata *item;
@@ -187,24 +176,9 @@ window_client_build(void *modedata, u_int sort_type, __unused uint64_t *tag,
c->references++;
}
- switch (sort_type) {
- case WINDOW_CLIENT_BY_NAME:
- qsort(data->item_list, data->item_size, sizeof *data->item_list,
- window_client_cmp_name);
- break;
- case WINDOW_CLIENT_BY_SIZE:
- qsort(data->item_list, data->item_size, sizeof *data->item_list,
- window_client_cmp_size);
- break;
- case WINDOW_CLIENT_BY_CREATION_TIME:
- qsort(data->item_list, data->item_size, sizeof *data->item_list,
- window_client_cmp_creation_time);
- break;
- case WINDOW_CLIENT_BY_ACTIVITY_TIME:
- qsort(data->item_list, data->item_size, sizeof *data->item_list,
- window_client_cmp_activity_time);
- break;
- }
+ window_client_sort = sort_crit;
+ qsort(data->item_list, data->item_size, sizeof *data->item_list,
+ window_client_cmp);
for (i = 0; i < data->item_size; i++) {
item = data->item_list[i];
diff --git a/window-copy.c b/window-copy.c
index d868631c..76736ab2 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -60,8 +60,8 @@ static int window_copy_search_rl(struct grid *, struct grid *, u_int *,
static int window_copy_search_marks(struct window_mode_entry *,
struct screen *);
static void window_copy_clear_marks(struct window_mode_entry *);
-static void window_copy_move_left(struct screen *, u_int *, u_int *);
-static void window_copy_move_right(struct screen *, u_int *, u_int *);
+static void window_copy_move_left(struct screen *, u_int *, u_int *, int);
+static void window_copy_move_right(struct screen *, u_int *, u_int *, int);
static int window_copy_is_lowercase(const char *);
static int window_copy_search_jump(struct window_mode_entry *,
struct grid *, struct grid *, u_int, u_int, u_int, int, int,
@@ -110,7 +110,7 @@ static void window_copy_cursor_next_word(struct window_mode_entry *,
static void window_copy_cursor_next_word_end(struct window_mode_entry *,
const char *);
static void window_copy_cursor_previous_word(struct window_mode_entry *,
- const char *);
+ const char *, int);
static void window_copy_scroll_up(struct window_mode_entry *, u_int);
static void window_copy_scroll_down(struct window_mode_entry *, u_int);
static void window_copy_rectangle_toggle(struct window_mode_entry *);
@@ -820,6 +820,21 @@ window_copy_cmd_cursor_down(struct window_copy_cmd_state *cs)
}
static enum window_copy_cmd_action
+window_copy_cmd_cursor_down_and_cancel(struct window_copy_cmd_state *cs)
+{
+ struct window_mode_entry *wme = cs->wme;
+ struct window_copy_mode_data *data = wme->data;
+ u_int np = wme->prefix, cy;
+
+ cy = data->cy;
+ for (; np != 0; np--)
+ window_copy_cursor_down(wme, 0);
+ if (cy == data->cy && data->oy == 0)
+ return (WINDOW_COPY_CMD_CANCEL);
+ return (WINDOW_COPY_CMD_NOTHING);
+}
+
+static enum window_copy_cmd_action
window_copy_cmd_cursor_left(struct window_copy_cmd_state *cs)
{
struct window_mode_entry *wme = cs->wme;
@@ -1048,7 +1063,7 @@ window_copy_cmd_previous_matching_bracket(struct window_copy_cmd_state *cs)
tried = 1;
goto retry;
}
- window_copy_cursor_previous_word(wme, "}]) ");
+ window_copy_cursor_previous_word(wme, "}]) ", 1);
}
continue;
}
@@ -1093,7 +1108,6 @@ window_copy_cmd_previous_matching_bracket(struct window_copy_cmd_state *cs)
return (WINDOW_COPY_CMD_NOTHING);
}
-
static enum window_copy_cmd_action
window_copy_cmd_next_matching_bracket(struct window_copy_cmd_state *cs)
{
@@ -1343,7 +1357,7 @@ window_copy_cmd_previous_space(struct window_copy_cmd_state *cs)
u_int np = wme->prefix;
for (; np != 0; np--)
- window_copy_cursor_previous_word(wme, " ");
+ window_copy_cursor_previous_word(wme, " ", 1);
return (WINDOW_COPY_CMD_NOTHING);
}
@@ -1357,7 +1371,7 @@ window_copy_cmd_previous_word(struct window_copy_cmd_state *cs)
ws = options_get_string(s->options, "word-separators");
for (; np != 0; np--)
- window_copy_cursor_previous_word(wme, ws);
+ window_copy_cursor_previous_word(wme, ws, 1);
return (WINDOW_COPY_CMD_NOTHING);
}
@@ -1477,7 +1491,7 @@ window_copy_cmd_select_word(struct window_copy_cmd_state *cs)
data->rectflag = 0;
ws = options_get_string(s->options, "word-separators");
- window_copy_cursor_previous_word(wme, ws);
+ window_copy_cursor_previous_word(wme, ws, 0);
window_copy_start_selection(wme);
window_copy_cursor_next_word_end(wme, ws);
@@ -1635,12 +1649,17 @@ window_copy_cmd_search_backward(struct window_copy_cmd_state *cs)
struct window_mode_entry *wme = cs->wme;
struct window_copy_mode_data *data = wme->data;
u_int np = wme->prefix;
- const char *argument = cs->args->argv[1];
+ const char *argument;
- if (*argument != '\0') {
+ if (cs->args->argc == 2) {
+ argument = cs->args->argv[1];
+ if (*argument != '\0') {
+ free(data->searchstr);
+ data->searchstr = xstrdup(argument);
+ }
+ }
+ if (data->searchstr != NULL) {
data->searchtype = WINDOW_COPY_SEARCHUP;
- free(data->searchstr);
- data->searchstr = xstrdup(argument);
for (; np != 0; np--)
window_copy_search_up(wme);
}
@@ -1653,12 +1672,17 @@ window_copy_cmd_search_forward(struct window_copy_cmd_state *cs)
struct window_mode_entry *wme = cs->wme;
struct window_copy_mode_data *data = wme->data;
u_int np = wme->prefix;
- const char *argument = cs->args->argv[1];
+ const char *argument;
- if (*argument != '\0') {
+ if (cs->args->argc == 2) {
+ argument = cs->args->argv[1];
+ if (*argument != '\0') {
+ free(data->searchstr);
+ data->searchstr = xstrdup(argument);
+ }
+ }
+ if (data->searchstr != NULL) {
data->searchtype = WINDOW_COPY_SEARCHDOWN;
- free(data->searchstr);
- data->searchstr = xstrdup(argument);
for (; np != 0; np--)
window_copy_search_down(wme);
}
@@ -1800,6 +1824,8 @@ static const struct {
window_copy_cmd_copy_selection_and_cancel },
{ "cursor-down", 0, 0,
window_copy_cmd_cursor_down },
+ { "cursor-down-and-cancel", 0, 0,
+ window_copy_cmd_cursor_down_and_cancel },
{ "cursor-left", 0, 0,
window_copy_cmd_cursor_left },
{ "cursor-right", 0, 0,
@@ -1872,11 +1898,11 @@ static const struct {
window_copy_cmd_scroll_up },
{ "search-again", 0, 0,
window_copy_cmd_search_again },
- { "search-backward", 1, 1,
+ { "search-backward", 0, 1,
window_copy_cmd_search_backward },
{ "search-backward-incremental", 1, 1,
window_copy_cmd_search_backward_incremental },
- { "search-forward", 1, 1,
+ { "search-forward", 0, 1,
window_copy_cmd_search_forward },
{ "search-forward-incremental", 1, 1,
window_copy_cmd_search_forward_incremental },
@@ -2047,11 +2073,16 @@ window_copy_search_rl(struct grid *gd,
}
static void
-window_copy_move_left(struct screen *s, u_int *fx, u_int *fy)
+window_copy_move_left(struct screen *s, u_int *fx, u_int *fy, int wrapflag)
{
if (*fx == 0) { /* left */
- if (*fy == 0) /* top */
+ if (*fy == 0) { /* top */
+ if (wrapflag) {
+ *fx = screen_size_x(s) - 1;
+ *fy = screen_hsize(s) + screen_size_y(s);
+ }
return;
+ }
*fx = screen_size_x(s) - 1;
*fy = *fy - 1;
} else
@@ -2059,11 +2090,16 @@ window_copy_move_left(struct screen *s, u_int *fx, u_int *fy)
}
static void
-window_copy_move_right(struct screen *s, u_int *fx, u_int *fy)
+window_copy_move_right(struct screen *s, u_int *fx, u_int *fy, int wrapflag)
{
if (*fx == screen_size_x(s) - 1) { /* right */
- if (*fy == screen_hsize(s) + screen_size_y(s)) /* bottom */
+ if (*fy == screen_hsize(s) + screen_size_y(s)) { /* bottom */
+ if (wrapflag) {
+ *fx = 0;
+ *fy = 0;
+ }
return;
+ }
*fx = 0;
*fy = *fy + 1;
} else
@@ -2155,18 +2191,16 @@ window_copy_search(struct window_mode_entry *wme, int direction)
screen_write_nputs(&ctx, -1, &grid_default_cell, "%s", data->searchstr);
screen_write_stop(&ctx);
- if (direction)
- window_copy_move_right(s, &fx, &fy);
- else
- window_copy_move_left(s, &fx, &fy);
-
wrapflag = options_get_number(wp->window->options, "wrap-search");
cis = window_copy_is_lowercase(data->searchstr);
- if (direction)
+ if (direction) {
+ window_copy_move_right(s, &fx, &fy, wrapflag);
endline = gd->hsize + gd->sy - 1;
- else
+ } else {
+ window_copy_move_left(s, &fx, &fy, wrapflag);
endline = 0;
+ }
found = window_copy_search_jump(wme, gd, ss.grid, fx, fy, endline, cis,
wrapflag, direction);
@@ -3314,7 +3348,7 @@ window_copy_cursor_next_word_end(struct window_mode_entry *wme,
/* Move to the previous place where a word begins. */
static void
window_copy_cursor_previous_word(struct window_mode_entry *wme,
- const char *separators)
+ const char *separators, int already)
{
struct window_copy_mode_data *data = wme->data;
u_int px, py;
@@ -3323,25 +3357,27 @@ window_copy_cursor_previous_word(struct window_mode_entry *wme,
py = screen_hsize(data->backing) + data->cy - data->oy;
/* Move back to the previous word character. */
- for (;;) {
- if (px > 0) {
- px--;
- if (!window_copy_in_set(wme, px, py, separators))
- break;
- } else {
- if (data->cy == 0 &&
- (screen_hsize(data->backing) == 0 ||
- data->oy >= screen_hsize(data->backing) - 1))
- goto out;
- window_copy_cursor_up(wme, 0);
-
- py = screen_hsize(data->backing) + data->cy - data->oy;
- px = window_copy_find_length(wme, py);
-
- /* Stop if separator at EOL. */
- if (px > 0 &&
- window_copy_in_set(wme, px - 1, py, separators))
- break;
+ if (already || window_copy_in_set(wme, px, py, separators)) {
+ for (;;) {
+ if (px > 0) {
+ px--;
+ if (!window_copy_in_set(wme, px, py, separators))
+ break;
+ } else {
+ if (data->cy == 0 &&
+ (screen_hsize(data->backing) == 0 ||
+ data->oy >= screen_hsize(data->backing) - 1))
+ goto out;
+ window_copy_cursor_up(wme, 0);
+
+ py = screen_hsize(data->backing) + data->cy - data->oy;
+ px = window_copy_find_length(wme, py);
+
+ /* Stop if separator at EOL. */
+ if (px > 0 &&
+ window_copy_in_set(wme, px - 1, py, separators))
+ break;
+ }
}
}
diff --git a/window-tree.c b/window-tree.c
index 61b11b1b..1ee5e7d4 100644
--- a/window-tree.c
+++ b/window-tree.c
@@ -89,6 +89,7 @@ static const char *window_tree_sort_list[] = {
"name",
"time"
};
+static struct mode_tree_sort_criteria *window_tree_sort;
enum window_tree_type {
WINDOW_TREE_NONE,
@@ -184,62 +185,92 @@ window_tree_free_item(struct window_tree_itemdata *item)
}
static int
-window_tree_cmp_session_name(const void *a0, const void *b0)
+window_tree_cmp_session(const void *a0, const void *b0)
{
- const struct session *const *a = a0;
- const struct session *const *b = b0;
+ const struct session *const *a = a0;
+ const struct session *const *b = b0;
+ const struct session *sa = *a;
+ const struct session *sb = *b;
+ int result;
- return (strcmp((*a)->name, (*b)->name));
-}
-
-static int
-window_tree_cmp_session_time(const void *a0, const void *b0)
-{
- const struct session *const *a = a0;
- const struct session *const *b = b0;
+ switch (window_tree_sort->field) {
+ case WINDOW_TREE_BY_INDEX:
+ result = sa->id - sb->id;
+ break;
+ case WINDOW_TREE_BY_TIME:
+ if (timercmp(&sa->activity_time, &sb->activity_time, >)) {
+ result = -1;
+ break;
+ }
+ if (timercmp(&sa->activity_time, &sb->activity_time, <)) {
+ result = 1;
+ break;
+ }
+ /* FALLTHROUGH */
+ case WINDOW_TREE_BY_NAME:
+ result = strcmp(sa->name, sb->name);
+ break;
+ }
- if (timercmp(&(*a)->activity_time, &(*b)->activity_time, >))
- return (-1);
- if (timercmp(&(*a)->activity_time, &(*b)->activity_time, <))
- return (1);
- return (strcmp((*a)->name, (*b)->name));
+ if (window_tree_sort->reversed)
+ result = -result;
+ return (result);
}
static int
-window_tree_cmp_window_name(const void *a0, const void *b0)
+window_tree_cmp_window(const void *a0, const void *b0)
{
- const struct winlink *const *a = a0;
- const struct winlink *const *b = b0;
-
- return (strcmp((*a)->window->name, (*b)->window->name));
-}
+ const struct winlink *const *a = a0;
+ const struct winlink *const *b = b0;
+ const struct winlink *wla = *a;
+ const struct winlink *wlb = *b;
+ struct window *wa = wla->window;
+ struct window *wb = wlb->window;
+ int result;
+
+ switch (window_tree_sort->field) {
+ case WINDOW_TREE_BY_INDEX:
+ result = wla->idx - wlb->idx;
+ break;
+ case WINDOW_TREE_BY_TIME:
+ if (timercmp(&wa->activity_time, &wb->activity_time, >)) {
+ result = -1;
+ break;
+ }
+ if (timercmp(&wa->activity_time, &wb->activity_time, <)) {
+ result = 1;
+ break;
+ }
+ /* FALLTHROUGH */
+ case WINDOW_TREE_BY_NAME:
+ result = strcmp(wa->name, wb->name);
+ break;
+ }
-static int
-window_tree_cmp_window_time(const void *a0, const void *b0)
-{
- const struct winlink *const *a = a0;
- const struct winlink *const *b = b0;
-
- if (timercmp(&(*a)->window->activity_time,
- &(*b)->window->activity_time, >))
- return (-1);
- if (timercmp(&(*a)->window->activity_time,
- &(*b)->window->activity_time, <))
- return (1);
- return (strcmp((*a)->window->name, (*b)->window->name));
+ if (window_tree_sort->reversed)
+ result = -result;
+ return (result);
}
static int
-window_tree_cmp_pane_time(const void *a0, const void *b0)
+window_tree_cmp_pane(const void *a0, const void *b0)
{
- const struct window_pane *const *a = a0;
- const struct window_pane *const *b = b0;
+ const struct window_pane *const *a = a0;
+ const struct window_pane *const *b = b0;
+ int result;
- if ((*a)->active_point < (*b)->active_point)
- return (-1);
- if ((*a)->active_point > (*b)->active_point)
- return (1);
- return (0);
+ if (window_tree_sort->field == WINDOW_TREE_BY_TIME)
+ result = (*a)->active_point - (*b)->active_point;
+ else {
+ /*
+ * Panes don't have names, so use number order for any other
+ * sort field.
+ */
+ result = (*a)->id - (*b)->id;
+ }
+ if (window_tree_sort->reversed)
+ result *= -1;
+ return (result);
}
static void
@@ -285,8 +316,9 @@ window_tree_filter_pane(struct session *s, struct winlink *wl,
}
static int
-window_tree_build_window(struct session *s, struct winlink *wl, void* modedata,
- u_int sort_type, struct mode_tree_item *parent, const char *filter)
+window_tree_build_window(struct session *s, struct winlink *wl,
+ void* modedata, struct mode_tree_sort_criteria *sort_crit,
+ struct mode_tree_item *parent, const char *filter)
{
struct window_tree_modedata *data = modedata;
struct window_tree_itemdata *item;
@@ -335,16 +367,8 @@ window_tree_build_window(struct session *s, struct winlink *wl, void* modedata,
if (n == 0)
goto empty;
- switch (sort_type) {
- case WINDOW_TREE_BY_INDEX:
- break;
- case WINDOW_TREE_BY_NAME:
- /* Panes don't have names, so leave in number order. */
- break;
- case WINDOW_TREE_BY_TIME:
- qsort(l, n, sizeof *l, window_tree_cmp_pane_time);
- break;
- }
+ window_tree_sort = sort_crit;
+ qsort(l, n, sizeof *l, window_tree_cmp_pane);
for (i = 0; i < n; i++)
window_tree_build_pane(s, wl, l[i], modedata, mti);
@@ -360,7 +384,7 @@ empty:
static void
window_tree_build_session(struct session *s, void* modedata,
- u_int sort_type, const char *filter)
+ struct mode_tree_sort_criteria *sort_crit, const char *filter)
{
struct window_tree_modedata *data = modedata;
struct window_tree_itemdata *item;
@@ -392,20 +416,12 @@ window_tree_build_session(struct session *s, void* modedata,
l = xreallocarray(l, n + 1, sizeof *l);
l[n++] = wl;
}
- switch (sort_type) {
- case WINDOW_TREE_BY_INDEX:
- break;
- case WINDOW_TREE_BY_NAME:
- qsort(l, n, sizeof *l, window_tree_cmp_window_name);
- break;
- case WINDOW_TREE_BY_TIME:
- qsort(l, n, sizeof *l, window_tree_cmp_window_time);
- break;
- }
+ window_tree_sort = sort_crit;
+ qsort(l, n, sizeof *l, window_tree_cmp_window);
empty = 0;
for (i = 0; i < n; i++) {
- if (!window_tree_build_window(s, l[i], modedata, sort_type, mti,
+ if (!window_tree_build_window(s, l[i], modedata, sort_crit, mti,
filter))
empty++;
}
@@ -418,8 +434,8 @@ window_tree_build_session(struct session *s, void* modedata,
}
static void
-window_tree_build(void *modedata, u_int sort_type, uint64_t *tag,
- const char *filter)
+window_tree_build(void *modedata, struct mode_tree_sort_criteria *sort_crit,
+ uint64_t *tag, const char *filter)
{
struct window_tree_modedata *data = modedata;
struct session *s, **l;
@@ -446,19 +462,11 @@ window_tree_build(void *modedata, u_int sort_type, uint64_t *tag,
l = xreallocarray(l, n + 1, sizeof *l);
l[n++] = s;
}
- switch (sort_type) {
- case WINDOW_TREE_BY_INDEX:
- break;
- case WINDOW_TREE_BY_NAME:
- qsort(l, n, sizeof *l, window_tree_cmp_session_name);
- break;
- case WINDOW_TREE_BY_TIME:
- qsort(l, n, sizeof *l, window_tree_cmp_session_time);
- break;
- }
+ window_tree_sort = sort_crit;
+ qsort(l, n, sizeof *l, window_tree_cmp_session);
for (i = 0; i < n; i++)
- window_tree_build_session(l[i], modedata, sort_type, filter);
+ window_tree_build_session(l[i], modedata, sort_crit, filter);
free(l);
switch (data->type) {
diff --git a/window.c b/window.c
index 254ccc83..cd974649 100644
--- a/window.c
+++ b/window.c
@@ -585,6 +585,28 @@ window_unzoom(struct window *w)
return (0);
}
+int
+window_push_zoom(struct window *w, int flag)
+{
+ log_debug("%s: @%u %d", __func__, w->id,
+ flag && (w->flags & WINDOW_ZOOMED));
+ if (flag && (w->flags & WINDOW_ZOOMED))
+ w->flags |= WINDOW_WASZOOMED;
+ else
+ w->flags &= ~WINDOW_WASZOOMED;
+ return (window_unzoom(w) == 0);
+}
+
+int
+window_pop_zoom(struct window *w)
+{
+ log_debug("%s: @%u %d", __func__, w->id,
+ !!(w->flags & WINDOW_WASZOOMED));
+ if (w->flags & WINDOW_WASZOOMED)
+ return (window_zoom(w->active) == 0);
+ return (0);
+}
+
struct window_pane *
window_add_pane(struct window *w, struct window_pane *other, u_int hlimit,
int flags)
@@ -932,7 +954,7 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
if (wme != NULL && wme->mode->resize != NULL)
wme->mode->resize(wme, sx, sy);
- wp->flags |= PANE_RESIZE;
+ wp->flags |= (PANE_RESIZE|PANE_RESIZED);
}
/*