Hello tech@, I got a bit annoyed by the fact that it isn't clear what the current ordering is for states. I'm not very familiar with systat, so I might have missed something obvious.
Since there was no obvious room available for always printing the active ordering and very few fields do support ordering I added a new keyword to the "global" command interpreter: "order". This is similar to "help", but shows the available orderings for the current view. It also adds the corresponding hotkey for every ordering and highlights the current active ordering. I also added a caret to the active ordering name if the sortdir is reverse. I also noticed via this diff that pcache has ordering options. These are not documented and don't seem to do much. For now I decided to document them, but maybe it's better to just remove the option altogether? Feedback? martijn@ Index: engine.c =================================================================== RCS file: /cvs/src/usr.bin/systat/engine.c,v retrieving revision 1.21 diff -u -p -u -r1.21 engine.c --- engine.c 5 Apr 2017 15:57:11 -0000 1.21 +++ engine.c 18 Dec 2017 21:49:22 -0000 @@ -890,6 +890,21 @@ print_fld_float(field_def *fld, double f /* ordering */ +int +foreach_order(void (*callback)(order_type *)) +{ + order_type *o; + + if (curr_view == NULL || curr_view->mgr == NULL || + curr_view->mgr->order_list == NULL) + return -1; + o = curr_view->mgr->order_list; + do { + callback(o++); + } while (o->name != NULL); + return 0; +} + void set_order(const char *opt) { Index: engine.h =================================================================== RCS file: /cvs/src/usr.bin/systat/engine.h,v retrieving revision 1.8 diff -u -p -u -r1.8 engine.h --- engine.h 7 Sep 2013 11:43:49 -0000 1.8 +++ engine.h 18 Dec 2017 21:49:22 -0000 @@ -130,6 +130,7 @@ int set_view(const char *opt); void next_view(void); void prev_view(void); +int foreach_order(void (*callback)(order_type *)); void set_order(const char *opt); void next_order(void); Index: main.c =================================================================== RCS file: /cvs/src/usr.bin/systat/main.c,v retrieving revision 1.66 diff -u -p -u -r1.66 main.c --- main.c 13 Oct 2016 11:22:46 -0000 1.66 +++ main.c 18 Dec 2017 21:49:22 -0000 @@ -251,6 +251,31 @@ show_help(void) } void +add_order_tb(order_type *o) +{ + if (curr_view->mgr->order_curr == o) + tbprintf("[%s%s(%c)] ", o->name, + o->func != NULL && sortdir == -1 ? "^" : "", + (char) o->hotkey); + else + tbprintf("%s(%c) ", o->name, (char) o->hotkey); +} + +void +show_order(void) +{ + if (rawmode) + return; + + tb_start(); + if (foreach_order(add_order_tb) == -1) { + tbprintf("No orders available"); + } + tb_end(); + message_set(tmp_buf); +} + +void cmd_compat(const char *buf) { const char *s; @@ -273,6 +298,11 @@ cmd_compat(const char *buf) paused = 0; gotsig_alarm = 1; cmd_delay(buf + 5); + return; + } + if (strncasecmp(buf, "order", 5) == 0) { + show_order(); + need_update = 1; return; } Index: pftop.c =================================================================== RCS file: /cvs/src/usr.bin/systat/pftop.c,v retrieving revision 1.40 diff -u -p -u -r1.40 pftop.c --- pftop.c 19 Jul 2017 12:58:31 -0000 1.40 +++ pftop.c 18 Dec 2017 21:49:22 -0000 @@ -269,7 +269,7 @@ order_type order_list[] = { /* Define view managers */ struct view_manager state_mgr = { "States", select_states, read_states, sort_states, print_header, - print_states, keyboard_callback, order_list, NULL + print_states, keyboard_callback, order_list, order_list }; struct view_manager rule_mgr = { Index: systat.1 =================================================================== RCS file: /cvs/src/usr.bin/systat/systat.1,v retrieving revision 1.102 diff -u -p -u -r1.102 systat.1 --- systat.1 15 Jun 2017 03:47:07 -0000 1.102 +++ systat.1 18 Dec 2017 21:49:22 -0000 @@ -219,6 +219,8 @@ command interpreter. .Bl -tag -width Fl .It Ic help Print the names of the available views on the command line. +.It Ic order +Print the names of the available orderings on the command line. .It Ic quit Quit .Nm . @@ -384,6 +386,10 @@ changes the view to show all of them. Display kernel .Xr pool 9 per CPU cache statistics. +Available orderins are: +.Ic name , +.Ic request , +.Ic releases . .It Ic queues Display statistics about the active queues, similar to the output of