jcs's openbsd hax
openbsd

Implement some obvious missing sort orders, from Dane Jensen in GitHub issue 4813.

nicm 80a55d5e 9883e2f2

+45 -19
+28 -14
usr.bin/tmux/sort.c
··· 1 - /* $OpenBSD: sort.c,v 1.1 2026/02/02 10:08:30 nicm Exp $ */ 1 + /* $OpenBSD: sort.c,v 1.2 2026/02/10 09:55:53 nicm Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2026 Dane Jensen <dhcjensen@gmail.com> ··· 197 197 case SORT_CREATION: 198 198 result = a->id - b->id; 199 199 break; 200 - case SORT_INDEX: 201 - case SORT_NAME: 202 - case SORT_ORDER: 203 200 case SORT_SIZE: 204 - case SORT_END: 201 + result = a->sx * a->sy - b->sx * b->sy; 205 202 break; 206 - } 207 - if (result == 0) { 208 - /* 209 - * Panes don't have names, so use number order for any other 210 - * sort field. 211 - */ 203 + case SORT_INDEX: 212 204 window_pane_index(a, &ai); 213 205 window_pane_index(b, &bi); 214 206 result = ai - bi; 207 + break; 208 + case SORT_NAME: 209 + result = strcmp(a->screen->title, b->screen->title); 210 + break; 211 + case SORT_ORDER: 212 + case SORT_END: 213 + break; 215 214 } 216 215 216 + if (result == 0) 217 + result = strcmp(a->screen->title, b->screen->title); 218 + 217 219 if (sort_crit->reversed) 218 220 result = -result; 219 221 return (result); ··· 235 237 case SORT_INDEX: 236 238 result = wla->idx - wlb->idx; 237 239 break; 240 + case SORT_CREATION: 241 + if (timercmp(&wa->creation_time, &wb->creation_time, >)) { 242 + result = -1; 243 + break; 244 + } 245 + if (timercmp(&wa->creation_time, &wb->creation_time, <)) { 246 + result = 1; 247 + break; 248 + } 249 + break; 238 250 case SORT_ACTIVITY: 239 251 if (timercmp(&wa->activity_time, &wb->activity_time, >)) { 240 252 result = -1; ··· 248 260 case SORT_NAME: 249 261 result = strcmp(wa->name, wb->name); 250 262 break; 251 - case SORT_CREATION: 263 + case SORT_SIZE: 264 + result = wa->sx * wa->sy - wb->sx * wb->sy; 265 + break; 252 266 case SORT_ORDER: 253 - case SORT_SIZE: 254 267 case SORT_END: 255 268 break; 256 269 } ··· 295 308 return (SORT_CREATION); 296 309 if (strcasecmp(order, "index") == 0) 297 310 return (SORT_INDEX); 298 - if (strcasecmp(order, "name") == 0) 311 + if (strcasecmp(order, "name") == 0 || 312 + strcasecmp(order, "title") == 0) 299 313 return (SORT_NAME); 300 314 if (strcasecmp(order, "order") == 0) 301 315 return (SORT_ORDER);
+11 -3
usr.bin/tmux/tmux.1
··· 1 - .\" $OpenBSD: tmux.1,v 1.1029 2026/02/02 10:08:30 nicm Exp $ 1 + .\" $OpenBSD: tmux.1,v 1.1030 2026/02/10 09:55:53 nicm Exp $ 2 2 .\" 3 3 .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> 4 4 .\" ··· 14 14 .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 15 15 .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 16 .\" 17 - .Dd $Mdocdate: February 2 2026 $ 17 + .Dd $Mdocdate: February 10 2026 $ 18 18 .Dt TMUX 1 19 19 .Os 20 20 .Sh NAME ··· 3090 3090 section. 3091 3091 .Fl O 3092 3092 specifies the sort order: one of 3093 - .Ql name , 3093 + .Ql name 3094 + (title), 3095 + .Ql index , 3096 + .Ql size 3097 + (area), 3094 3098 .Ql creation 3095 3099 (time), or 3096 3100 .Ql activity ··· 3123 3127 specifies the sort order: one of 3124 3128 .Ql index , 3125 3129 .Ql name , 3130 + .Ql size 3131 + (area), 3132 + .Ql creation 3133 + (time), 3126 3134 or 3127 3135 .Ql activity 3128 3136 (time).
+2 -1
usr.bin/tmux/tmux.h
··· 1 - /* $OpenBSD: tmux.h,v 1.1291 2026/02/03 09:07:44 nicm Exp $ */ 1 + /* $OpenBSD: tmux.h,v 1.1292 2026/02/10 09:55:53 nicm Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> ··· 1254 1254 struct event offset_timer; 1255 1255 1256 1256 struct timeval activity_time; 1257 + struct timeval creation_time; 1257 1258 1258 1259 struct window_pane *active; 1259 1260 struct window_panes last_panes;
+4 -1
usr.bin/tmux/window.c
··· 1 - /* $OpenBSD: window.c,v 1.310 2026/02/03 09:07:44 nicm Exp $ */ 1 + /* $OpenBSD: window.c,v 1.311 2026/02/10 09:55:53 nicm Exp $ */ 2 2 3 3 /* 4 4 * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> ··· 330 330 RB_INSERT(windows, &windows, w); 331 331 332 332 window_set_fill_character(w); 333 + 334 + if (gettimeofday(&w->creation_time, NULL) != 0) 335 + fatal("gettimeofday failed"); 333 336 window_update_activity(w); 334 337 335 338 log_debug("%s: @%u create %ux%u (%ux%u)", __func__, w->id, sx, sy,