=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/mode-tree.c,v retrieving revision 1.35 retrieving revision 1.36 diff -c -r1.35 -r1.36 *** src/usr.bin/tmux/mode-tree.c 2019/07/19 07:20:51 1.35 --- src/usr.bin/tmux/mode-tree.c 2019/08/16 11:49:12 1.36 *************** *** 1,4 **** ! /* $OpenBSD: mode-tree.c,v 1.35 2019/07/19 07:20:51 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: mode-tree.c,v 1.36 2019/08/16 11:49:12 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott *************** *** 39,45 **** const char **sort_list; u_int sort_size; ! u_int sort_type; mode_tree_build_cb buildcb; mode_tree_draw_cb drawcb; --- 39,45 ---- const char **sort_list; u_int sort_size; ! struct mode_tree_sort_criteria sort_crit; mode_tree_build_cb buildcb; mode_tree_draw_cb drawcb; *************** *** 334,340 **** mtd->sort_list = sort_list; mtd->sort_size = sort_size; - mtd->sort_type = 0; mtd->preview = !args_has(args, 'N'); --- 334,339 ---- *************** *** 342,350 **** if (sort != NULL) { for (i = 0; i < sort_size; i++) { if (strcasecmp(sort, sort_list[i]) == 0) ! mtd->sort_type = i; } } if (args_has(args, 'f')) mtd->filter = xstrdup(args_get(args, 'f')); --- 341,350 ---- if (sort != NULL) { for (i = 0; i < sort_size; i++) { if (strcasecmp(sort, sort_list[i]) == 0) ! 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,401 **** TAILQ_CONCAT(&mtd->saved, &mtd->children, entry); TAILQ_INIT(&mtd->children); ! mtd->buildcb(mtd->modedata, mtd->sort_type, &tag, mtd->filter); mtd->no_matches = TAILQ_EMPTY(&mtd->children); if (mtd->no_matches) ! mtd->buildcb(mtd->modedata, mtd->sort_type, &tag, NULL); mode_tree_free_items(&mtd->saved); TAILQ_INIT(&mtd->saved); --- 392,401 ---- TAILQ_CONCAT(&mtd->saved, &mtd->children, entry); TAILQ_INIT(&mtd->children); ! 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_crit, &tag, NULL); mode_tree_free_items(&mtd->saved); TAILQ_INIT(&mtd->saved); *************** *** 634,641 **** 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]); if (w - 2 >= strlen(text)) { screen_write_cursormove(&ctx, 1, h, 0); screen_write_puts(&ctx, &gc0, "%s", text); --- 634,642 ---- screen_write_cursormove(&ctx, 0, h, 0); screen_write_box(&ctx, w, sy - h); ! 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,1001 **** } break; case 'O': ! mtd->sort_type++; ! if (mtd->sort_type == mtd->sort_size) ! mtd->sort_type = 0; mode_tree_build(mtd); break; case KEYC_LEFT: --- 994,1006 ---- } break; case 'O': ! 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: