Add -O option to choose-* to set initial sort order.

This commit is contained in:
nicm
2017-06-09 15:29:15 +00:00
parent 3ec28ceb9b
commit bab4da5133
7 changed files with 48 additions and 15 deletions

View File

@ -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;