aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2017-06-09 15:29:15 +0000
committernicm <nicm>2017-06-09 15:29:15 +0000
commitbab4da51334499d1e3e43ad155f2f8da6ad0eb76 (patch)
tree83d04410966d3d4cecb6fe92680faec723245087
parent3ec28ceb9bc4f4f3c186d8006b3ab0c776714fa5 (diff)
downloadrtmux-bab4da51334499d1e3e43ad155f2f8da6ad0eb76.tar.gz
rtmux-bab4da51334499d1e3e43ad155f2f8da6ad0eb76.tar.bz2
rtmux-bab4da51334499d1e3e43ad155f2f8da6ad0eb76.zip
Add -O option to choose-* to set initial sort order.
-rw-r--r--cmd-choose-tree.c12
-rw-r--r--mode-tree.c15
-rw-r--r--tmux.122
-rw-r--r--tmux.h2
-rw-r--r--window-buffer.c2
-rw-r--r--window-client.c6
-rw-r--r--window-tree.c4
7 files changed, 48 insertions, 15 deletions
diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c
index f8f24f12..58fe4dce 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 = { "st:w", 0, 1 },
- .usage = "[-sw] " CMD_TARGET_PANE_USAGE,
+ .args = { "O:st:w", 0, 1 },
+ .usage = "[-sw] [-O sort-order] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
@@ -43,8 +43,8 @@ const struct cmd_entry cmd_choose_client_entry = {
.name = "choose-client",
.alias = NULL,
- .args = { "t:", 0, 1 },
- .usage = CMD_TARGET_PANE_USAGE,
+ .args = { "O:t:", 0, 1 },
+ .usage = "[-O sort-order] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
@@ -56,8 +56,8 @@ const struct cmd_entry cmd_choose_buffer_entry = {
.name = "choose-buffer",
.alias = NULL,
- .args = { "t:", 0, 1 },
- .usage = CMD_TARGET_PANE_USAGE,
+ .args = { "O:t:", 0, 1 },
+ .usage = "[-O sort-order] " CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
diff --git a/mode-tree.c b/mode-tree.c
index 1093aff3..aaea9160 100644
--- a/mode-tree.c
+++ b/mode-tree.c
@@ -273,12 +273,15 @@ mode_tree_each_tagged(struct mode_tree_data *mtd, void (*cb)(void *, void *,
}
struct mode_tree_data *
-mode_tree_start(struct window_pane *wp, void (*buildcb)(void *, u_int,
- uint64_t *), struct screen *(*drawcb)(void *, void *, u_int, u_int),
+mode_tree_start(struct window_pane *wp, struct args *args,
+ void (*buildcb)(void *, u_int, uint64_t *),
+ struct screen *(*drawcb)(void *, void *, u_int, u_int),
int (*searchcb)(void *, void *, const char *), void *modedata,
const char **sort_list, u_int sort_size, struct screen **s)
{
struct mode_tree_data *mtd;
+ const char *sort;
+ u_int i;
mtd = xcalloc(1, sizeof *mtd);
mtd->references = 1;
@@ -290,6 +293,14 @@ mode_tree_start(struct window_pane *wp, void (*buildcb)(void *, u_int,
mtd->sort_size = sort_size;
mtd->sort_type = 0;
+ sort = args_get(args, 'O');
+ if (sort != NULL) {
+ for (i = 0; i < sort_size; i++) {
+ if (strcasecmp(sort, sort_list[i]) == 0)
+ mtd->sort_type = i;
+ }
+ }
+
mtd->buildcb = buildcb;
mtd->drawcb = drawcb;
mtd->searchcb = searchcb;
diff --git a/tmux.1 b/tmux.1
index 025adf69..dab6530e 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1354,6 +1354,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 O Ar sort-order
.Op Fl t Ar target-pane
.Op Ar template
.Xc
@@ -1389,10 +1390,18 @@ If
.Ar template
is not given, "detach-client -t '%%'" is used.
.Pp
+.Fl O
+specifies the initial sort order: one of
+.Ql name ,
+.Ql size ,
+.Ql creation ,
+or
+.Ql activity .
This command works only if at least one client is attached.
.It Xo
.Ic choose-tree
.Op Fl sw
+.Op Fl O Ar sort-order
.Op Fl t Ar target-pane
.Op Ar template
.Xc
@@ -1428,6 +1437,12 @@ If
.Ar template
is not given, "switch-client -t '%%'" is used.
.Pp
+.Fl O
+specifies the initial sort order: one of
+.Ql index ,
+.Ql name ,
+or
+.Ql time .
This command works only if at least one client is attached.
.It Xo
.Ic display-panes
@@ -3957,6 +3972,7 @@ The buffer commands are as follows:
.Bl -tag -width Ds
.It Xo
.Ic choose-buffer
+.Op Fl O Ar sort-order
.Op Fl t Ar target-pane
.Op Ar template
.Xc
@@ -3988,6 +4004,12 @@ If
.Ar template
is not given, "paste-buffer -b '%%'" is used.
.Pp
+.Fl O
+specifies the initial sort order: one of
+.Ql time ,
+.Ql name
+or
+.Ql size .
This command works only if at least one client is attached.
.It Ic clear-history Op Fl t Ar target-pane
.D1 (alias: Ic clearhist )
diff --git a/tmux.h b/tmux.h
index f1d150df..05d111a3 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2201,7 +2201,7 @@ void mode_tree_each_tagged(struct mode_tree_data *, void (*)(void *, void *,
key_code), key_code, int);
void mode_tree_up(struct mode_tree_data *, int);
void mode_tree_down(struct mode_tree_data *, int);
-struct mode_tree_data *mode_tree_start(struct window_pane *,
+struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *,
void (*)(void *, u_int, uint64_t *), struct screen *(*)(void *,
void *, u_int, u_int), int (*)(void *, void *, const char *),
void *, const char **, u_int, struct screen **);
diff --git a/window-buffer.c b/window-buffer.c
index 7ba21608..d7e310d8 100644
--- a/window-buffer.c
+++ b/window-buffer.c
@@ -257,7 +257,7 @@ window_buffer_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
else
data->command = xstrdup(args->argv[0]);
- data->data = mode_tree_start(wp, window_buffer_build,
+ data->data = mode_tree_start(wp, args, window_buffer_build,
window_buffer_draw, window_buffer_search, data,
window_buffer_sort_list, nitems(window_buffer_sort_list), &s);
diff --git a/window-client.c b/window-client.c
index 483ce8fe..cbceead9 100644
--- a/window-client.c
+++ b/window-client.c
@@ -54,8 +54,8 @@ enum window_client_sort_type {
static const char *window_client_sort_list[] = {
"name",
"size",
- "creation time",
- "activity time"
+ "creation",
+ "activity"
};
struct window_client_itemdata {
@@ -247,7 +247,7 @@ window_client_init(struct window_pane *wp, __unused struct cmd_find_state *fs,
else
data->command = xstrdup(args->argv[0]);
- data->data = mode_tree_start(wp, window_client_build,
+ data->data = mode_tree_start(wp, args, window_client_build,
window_client_draw, NULL, data, window_client_sort_list,
nitems(window_client_sort_list), &s);
diff --git a/window-tree.c b/window-tree.c
index 443a9eb8..64e99604 100644
--- a/window-tree.c
+++ b/window-tree.c
@@ -503,8 +503,8 @@ window_tree_init(struct window_pane *wp, struct cmd_find_state *fs,
else
data->command = xstrdup(args->argv[0]);
- data->data = mode_tree_start(wp, window_tree_build, window_tree_draw,
- window_tree_search, data, window_tree_sort_list,
+ data->data = mode_tree_start(wp, args, window_tree_build,
+ window_tree_draw, window_tree_search, data, window_tree_sort_list,
nitems(window_tree_sort_list), &s);
mode_tree_build(data->data);