mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Add -O option to choose-* to set initial sort order.
This commit is contained in:
		@@ -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 },
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								mode-tree.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								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;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								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 )
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								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 **);
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user