Hi,

I tend to keep systat(1) running in interactive mode, and find it very
useful to have the help line displayed permanently, i.e., not disappear
if a key is pressed or after a command is executed. The same goes for
the Ctrl-G display. For example, it tells me what modes are adjacent to
the currently active one when pressing left or right arrow keys.

The attached diff adds this feature. It is off by default. I noticed
that the 'h' key was not documented in the man page, so I took the
liberty of adding a line describing it.

Hope it is useful. Please have a look, thanks!

Regards,
Anindya

Index: engine.c
===================================================================
RCS file: /cvs/src/usr.bin/systat/engine.c,v
retrieving revision 1.27
diff -u -p -r1.27 engine.c
--- engine.c    6 Feb 2021 06:19:28 -0000       1.27
+++ engine.c    1 Mar 2021 03:20:41 -0000
@@ -70,6 +70,8 @@ volatile sig_atomic_t gotsig_alarm = 0;
 int need_update = 0;
 int need_sort = 0;
 int separate_thousands = 0;
+int viewmode = 0;
+int sticky = 0;
 
 SCREEN *screen;
 
@@ -1139,7 +1141,9 @@ command_set(struct command *cmd, const c
                        cmdbuf[0] = 0;
                }
        }
-       message_set(NULL);
+
+       if (!sticky)
+               message_set(NULL);
        curr_cmd = cmd;
        need_update = 1;
        return prev;
@@ -1234,7 +1238,7 @@ keyboard(void)
                                return;
 
        if (curr_message != NULL) {
-               if (ch > 0) {
+               if (ch > 0 && !sticky) {
                        message_set(NULL);
                        need_update = 1;
                }
@@ -1359,8 +1363,15 @@ engine_loop(int countmax)
                if (need_update) {
                        erase();
                        if (!averageonly ||
-                           (averageonly && count == countmax - 1))
+                           (averageonly && count == countmax - 1)) {
                                disp_update();
+                               if (interactive && sticky) {
+                                       if (viewmode)
+                                               show_view();
+                                       else
+                                               show_help();
+                               }
+                       }
                        end_page();
                        need_update = 0;
                        if (countmax && ++count >= countmax)
Index: engine.h
===================================================================
RCS file: /cvs/src/usr.bin/systat/engine.h,v
retrieving revision 1.12
diff -u -p -r1.12 engine.h
--- engine.h    12 Jan 2020 20:51:08 -0000      1.12
+++ engine.h    1 Mar 2021 03:20:41 -0000
@@ -144,6 +144,8 @@ struct command *command_set(struct comma
 const char *message_set(const char *msg);
 
 void foreach_view(void (*callback)(field_view *));
+void show_help(void);
+void show_view(void);
 
 extern int sortdir;
 extern useconds_t udelay;
@@ -160,6 +162,8 @@ extern int columns, lines;
 extern int need_update;
 extern int need_sort;
 extern int separate_thousands;
+extern int viewmode;
+extern int sticky;
 
 extern volatile sig_atomic_t gotsig_close;
 extern volatile sig_atomic_t gotsig_resize;
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/systat/main.c,v
retrieving revision 1.73
diff -u -p -r1.73 main.c
--- main.c      30 Jan 2021 08:44:42 -0000      1.73
+++ main.c      1 Mar 2021 03:20:41 -0000
@@ -285,6 +285,14 @@ cmd_compat(const char *buf)
 
        if (strcasecmp(buf, "help") == 0) {
                show_help();
+               sticky = 0;
+               need_update = 1;
+               return;
+       }
+       if (strcasecmp(buf, "stickyhelp") == 0) {
+               show_help();
+               sticky = 1;
+               viewmode = 0;
                need_update = 1;
                return;
        }
@@ -359,10 +367,18 @@ keyboard_callback(int ch)
                /* FALLTHROUGH */
        case 'h':
                show_help();
+               sticky = 0;
+               need_update = 1;
+               break;
+       case 'H':
+               show_help();
+               sticky = 1;
+               viewmode = 0;
                need_update = 1;
                break;
        case CTRL_G:
                show_view();
+               viewmode = 1;
                need_update = 1;
                break;
        case 'l':
Index: systat.1
===================================================================
RCS file: /cvs/src/usr.bin/systat/systat.1,v
retrieving revision 1.119
diff -u -p -r1.119 systat.1
--- systat.1    22 Jun 2020 13:17:54 -0000      1.119
+++ systat.1    1 Mar 2021 03:20:41 -0000
@@ -175,6 +175,8 @@ line typed as a command.
 While entering a command the
 current character erase, word erase, and line kill characters
 may be used.
+.It Ic h
+Print the names of the available views on the command line.
 .It Ic o
 Select the next ordering which sorts the rows according to a
 combination of columns.
@@ -190,6 +192,9 @@ Quit
 Reverse the selected ordering if supported by the view.
 .It Ic s
 Change the screen refresh interval in seconds.
+.It Ic H
+Print the names of the available views on the command line.
+The display becomes sticky. Pressing h clears the sticky state.
 .It Ic \&,
 Print numbers with thousand separators, where applicable.
 .It Ic ^A | Aq Ic Home
@@ -203,6 +208,7 @@ Select the next view.
 .It Ic ^G
 Print the name of the current
 view being shown and the refresh interval.
+The display does not clear if sticky help is active.
 .It Ic ^L
 Refresh the screen.
 .It Ic ^N | Aq Ic down arrow
@@ -230,6 +236,9 @@ Quit
 .Nm .
 (This may be abbreviated to
 .Ic q . )
+.It Ic stickyhelp
+Print the names of the available views on the command line.
+The display becomes sticky. The help command clears the sticky state.
 .It Ic stop
 Stop refreshing the screen.
 .It Xo

Reply via email to