Re: systat(1) sticky help

2021-05-29 Thread Alexander Bluhm
On Tue, Mar 09, 2021 at 07:33:29PM +0100, Martijn van Duren wrote:
> I send out an earlier version of this diff to Anindya with some positive
> feedback. Instead of claiming another binding, why not make help, order
> and view a toggle? I see no reason why this information should disappear
> on the next input.
> 
> Seems to work fine in my testing.
> 
> OK?

OK bluhm@

> martijn@
> 
> On Thu, 2021-03-04 at 22:47 -0800, Anindya Mukherjee wrote:
> > Hi,
> > 
> > I have reworked my proposed interface for sticky displays in systat
> > following earlier feedback. Thanks for that! It helped me rethink the
> > interface carefully.
> > 
> > In the current version, sticky mode has its own toggle: ^T. From a study
> > of the source and the man page it does not seem to be bound to anything
> > and, on my system at least, does not conflict with anything else. I
> > could add a dedicated command for it as well if that's useful. The
> > current version supports a sticky display for the view list, view mode
> > plus refresh interval, and available orderings.
> > 
> > I have tried the hotkeys for the various views as documented in the man
> > page (as well as some of the undocumented ones) and they seem to work. I
> > have also tried to make sure that the sticky displays don't interfere
> > with error messages. In future I would like to try to clean up the view
> > hotkeys, which conflict each other in some cases, and seem to be
> > undocumented. I found them useful; at least the ones that work. 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 -   1.27
> +++ engine.c  9 Mar 2021 18:32:24 -
> @@ -91,6 +91,8 @@ char cmdbuf[MAX_LINE_BUF];
>  int cmd_len = -1;
>  struct command *curr_cmd = NULL;
>  char *curr_message = NULL;
> +enum message_mode message_mode = MESSAGE_NONE;
> +int message_cont = 1;
>  
>  void print_cmdline(void);
>  
> @@ -1145,14 +1147,26 @@ command_set(struct command *cmd, const c
>   return prev;
>  }
>  
> +void
> +message_toggle(enum message_mode mode)
> +{
> + message_mode = message_mode != mode ? mode : MESSAGE_NONE;
> + need_update = 1;
> + message_cont = 1;
> +}
> +
>  const char *
> -message_set(const char *msg) {
> - char *prev = curr_message;
> - if (msg)
> +message_set(const char *msg)
> +{
> + free(curr_message);
> +
> + if (msg) {
>   curr_message = strdup(msg);
> - else
> + message_cont = 0;
> + } else {
>   curr_message = NULL;
> - free(prev);
> + message_cont = 1;
> + }
>   return NULL;
>  }
>  
> @@ -1361,6 +1375,22 @@ engine_loop(int countmax)
>   if (!averageonly ||
>   (averageonly && count == countmax - 1))
>   disp_update();
> + if (message_cont) {
> + switch (message_mode) {
> + case MESSAGE_NONE:
> + message_set(NULL);
> + break;
> + case MESSAGE_HELP:
> + show_help();
> + break;
> + case MESSAGE_VIEW:
> + show_view();
> + break;
> + case MESSAGE_ORDER:
> + show_order();
> + break;
> + }
> + }
>   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 -  1.12
> +++ engine.h  9 Mar 2021 18:32:24 -
> @@ -95,6 +95,12 @@ struct command {
>   void ( *exec)(const char *);
>  };
>  
> +enum message_mode {
> + MESSAGE_NONE,
> + MESSAGE_HELP,
> + MESSAGE_VIEW,
> + MESSAGE_ORDER
> +};
>  
>  void tb_start(void);
>  
> @@ -133,6 +139,9 @@ void prev_view(void);
>  int foreach_order(void (*callback)(order_type *));
>  void set_order(const char *opt);
>  void next_order(void);
> +void show_help(void);
> +void show_view(void);
> +void show_order(void);
>  
>  void setup_term(int maxpr);
>  int check_termcap(void);
> @@ -141,6 +150,7 @@ void engine_initialize(void);
>  void engine_loop(int countmax);
>  
>  struct command *command_set(struct command *cmd, const char *init);
> +void message_toggle(enum message_mode);
>  const char *message_set(const char *msg);

Re: systat(1) sticky help

2021-05-27 Thread Martijn van Duren
Any takers?

martijn@

On Tue, 2021-03-09 at 19:33 +0100, Martijn van Duren wrote:
> I send out an earlier version of this diff to Anindya with some positive
> feedback. Instead of claiming another binding, why not make help, order
> and view a toggle? I see no reason why this information should disappear
> on the next input.
> 
> Seems to work fine in my testing.
> 
> OK?
> 
> martijn@
> 
> On Thu, 2021-03-04 at 22:47 -0800, Anindya Mukherjee wrote:
> > Hi,
> > 
> > I have reworked my proposed interface for sticky displays in systat
> > following earlier feedback. Thanks for that! It helped me rethink the
> > interface carefully.
> > 
> > In the current version, sticky mode has its own toggle: ^T. From a study
> > of the source and the man page it does not seem to be bound to anything
> > and, on my system at least, does not conflict with anything else. I
> > could add a dedicated command for it as well if that's useful. The
> > current version supports a sticky display for the view list, view mode
> > plus refresh interval, and available orderings.
> > 
> > I have tried the hotkeys for the various views as documented in the man
> > page (as well as some of the undocumented ones) and they seem to work. I
> > have also tried to make sure that the sticky displays don't interfere
> > with error messages. In future I would like to try to clean up the view
> > hotkeys, which conflict each other in some cases, and seem to be
> > undocumented. I found them useful; at least the ones that work. 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.c6 Feb 2021 06:19:28 -   1.27
> +++ engine.c9 Mar 2021 18:32:24 -
> @@ -91,6 +91,8 @@ char cmdbuf[MAX_LINE_BUF];
>  int cmd_len = -1;
>  struct command *curr_cmd = NULL;
>  char *curr_message = NULL;
> +enum message_mode message_mode = MESSAGE_NONE;
> +int message_cont = 1;
>  
>  void print_cmdline(void);
>  
> @@ -1145,14 +1147,26 @@ command_set(struct command *cmd, const c
> return prev;
>  }
>  
> +void
> +message_toggle(enum message_mode mode)
> +{
> +   message_mode = message_mode != mode ? mode : MESSAGE_NONE;
> +   need_update = 1;
> +   message_cont = 1;
> +}
> +
>  const char *
> -message_set(const char *msg) {
> -   char *prev = curr_message;
> -   if (msg)
> +message_set(const char *msg)
> +{
> +   free(curr_message);
> +
> +   if (msg) {
> curr_message = strdup(msg);
> -   else
> +   message_cont = 0;
> +   } else {
> curr_message = NULL;
> -   free(prev);
> +   message_cont = 1;
> +   }
> return NULL;
>  }
>  
> @@ -1361,6 +1375,22 @@ engine_loop(int countmax)
> if (!averageonly ||
>     (averageonly && count == countmax - 1))
> disp_update();
> +   if (message_cont) {
> +   switch (message_mode) {
> +   case MESSAGE_NONE:
> +   message_set(NULL);
> +   break;
> +   case MESSAGE_HELP:
> +   show_help();
> +   break;
> +   case MESSAGE_VIEW:
> +   show_view();
> +   break;
> +   case MESSAGE_ORDER:
> +   show_order();
> +   break;
> +   }
> +   }
> 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.h12 Jan 2020 20:51:08 -  1.12
> +++ engine.h9 Mar 2021 18:32:24 -
> @@ -95,6 +95,12 @@ struct command {
> void ( *exec)(const char *);
>  };
>  
> +enum message_mode {
> +   MESSAGE_NONE,
> +   MESSAGE_HELP,
> +   MESSAGE_VIEW,
> +   MESSAGE_ORDER
> +};
>  
>  void tb_start(void);
>  
> @@ -133,6 +139,9 @@ void prev_view(void);
>  int foreach_order(void (*callback)(order_type *));
>  void set_order(const char *opt);
>  void next_order(void);
> +void show_help(void);
> +void show_view(void);
> +void show_order(void);
>  
>  void setup_term(int maxpr);
>  int check_termcap(void);
> @@ -141,6 +150,7 @@ void engine_initialize(void);
>  void engine_loop(int countmax);
>  
>  struct command *command_set(struct command *cmd, cons

Re: systat(1) sticky help

2021-05-10 Thread Anindya Mukherjee
I have been using this patch from martijn@ and find it really useful. Is
it possible to merge this? Thanks!

Regards,
Anindya

On Tue, Mar 09, 2021 at 07:33:29PM +0100, Martijn van Duren wrote:
> I send out an earlier version of this diff to Anindya with some positive
> feedback. Instead of claiming another binding, why not make help, order
> and view a toggle? I see no reason why this information should disappear
> on the next input.
> 
> Seems to work fine in my testing.
> 
> OK?
> 
> martijn@
> 
> On Thu, 2021-03-04 at 22:47 -0800, Anindya Mukherjee wrote:
> > Hi,
> > 
> > I have reworked my proposed interface for sticky displays in systat
> > following earlier feedback. Thanks for that! It helped me rethink the
> > interface carefully.
> > 
> > In the current version, sticky mode has its own toggle: ^T. From a study
> > of the source and the man page it does not seem to be bound to anything
> > and, on my system at least, does not conflict with anything else. I
> > could add a dedicated command for it as well if that's useful. The
> > current version supports a sticky display for the view list, view mode
> > plus refresh interval, and available orderings.
> > 
> > I have tried the hotkeys for the various views as documented in the man
> > page (as well as some of the undocumented ones) and they seem to work. I
> > have also tried to make sure that the sticky displays don't interfere
> > with error messages. In future I would like to try to clean up the view
> > hotkeys, which conflict each other in some cases, and seem to be
> > undocumented. I found them useful; at least the ones that work. 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 -   1.27
> +++ engine.c  9 Mar 2021 18:32:24 -
> @@ -91,6 +91,8 @@ char cmdbuf[MAX_LINE_BUF];
>  int cmd_len = -1;
>  struct command *curr_cmd = NULL;
>  char *curr_message = NULL;
> +enum message_mode message_mode = MESSAGE_NONE;
> +int message_cont = 1;
>  
>  void print_cmdline(void);
>  
> @@ -1145,14 +1147,26 @@ command_set(struct command *cmd, const c
>   return prev;
>  }
>  
> +void
> +message_toggle(enum message_mode mode)
> +{
> + message_mode = message_mode != mode ? mode : MESSAGE_NONE;
> + need_update = 1;
> + message_cont = 1;
> +}
> +
>  const char *
> -message_set(const char *msg) {
> - char *prev = curr_message;
> - if (msg)
> +message_set(const char *msg)
> +{
> + free(curr_message);
> +
> + if (msg) {
>   curr_message = strdup(msg);
> - else
> + message_cont = 0;
> + } else {
>   curr_message = NULL;
> - free(prev);
> + message_cont = 1;
> + }
>   return NULL;
>  }
>  
> @@ -1361,6 +1375,22 @@ engine_loop(int countmax)
>   if (!averageonly ||
>   (averageonly && count == countmax - 1))
>   disp_update();
> + if (message_cont) {
> + switch (message_mode) {
> + case MESSAGE_NONE:
> + message_set(NULL);
> + break;
> + case MESSAGE_HELP:
> + show_help();
> + break;
> + case MESSAGE_VIEW:
> + show_view();
> + break;
> + case MESSAGE_ORDER:
> + show_order();
> + break;
> + }
> + }
>   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 -  1.12
> +++ engine.h  9 Mar 2021 18:32:24 -
> @@ -95,6 +95,12 @@ struct command {
>   void ( *exec)(const char *);
>  };
>  
> +enum message_mode {
> + MESSAGE_NONE,
> + MESSAGE_HELP,
> + MESSAGE_VIEW,
> + MESSAGE_ORDER
> +};
>  
>  void tb_start(void);
>  
> @@ -133,6 +139,9 @@ void prev_view(void);
>  int foreach_order(void (*callback)(order_type *));
>  void set_order(const char *opt);
>  void next_order(void);
> +void show_help(void);
> +void show_view(void);
> +void show_order(void);
>  
>  void setup_term(int maxpr);
>  int check_termcap(void);
> @@ -141,6 +150,7 @@ void engine_initialize(void);
>  void engine_loop(int countmax);
>  
>  struct command *command_set(struct com

Re: systat(1) sticky help

2021-03-23 Thread Martijn van Duren
ping

On Tue, 2021-03-09 at 19:33 +0100, Martijn van Duren wrote:
> I send out an earlier version of this diff to Anindya with some positive
> feedback. Instead of claiming another binding, why not make help, order
> and view a toggle? I see no reason why this information should disappear
> on the next input.
> 
> Seems to work fine in my testing.
> 
> OK?
> 
> martijn@
> 
> On Thu, 2021-03-04 at 22:47 -0800, Anindya Mukherjee wrote:
> > Hi,
> > 
> > I have reworked my proposed interface for sticky displays in systat
> > following earlier feedback. Thanks for that! It helped me rethink the
> > interface carefully.
> > 
> > In the current version, sticky mode has its own toggle: ^T. From a study
> > of the source and the man page it does not seem to be bound to anything
> > and, on my system at least, does not conflict with anything else. I
> > could add a dedicated command for it as well if that's useful. The
> > current version supports a sticky display for the view list, view mode
> > plus refresh interval, and available orderings.
> > 
> > I have tried the hotkeys for the various views as documented in the man
> > page (as well as some of the undocumented ones) and they seem to work. I
> > have also tried to make sure that the sticky displays don't interfere
> > with error messages. In future I would like to try to clean up the view
> > hotkeys, which conflict each other in some cases, and seem to be
> > undocumented. I found them useful; at least the ones that work. 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.c6 Feb 2021 06:19:28 -   1.27
> +++ engine.c9 Mar 2021 18:32:24 -
> @@ -91,6 +91,8 @@ char cmdbuf[MAX_LINE_BUF];
>  int cmd_len = -1;
>  struct command *curr_cmd = NULL;
>  char *curr_message = NULL;
> +enum message_mode message_mode = MESSAGE_NONE;
> +int message_cont = 1;
>  
>  void print_cmdline(void);
>  
> @@ -1145,14 +1147,26 @@ command_set(struct command *cmd, const c
> return prev;
>  }
>  
> +void
> +message_toggle(enum message_mode mode)
> +{
> +   message_mode = message_mode != mode ? mode : MESSAGE_NONE;
> +   need_update = 1;
> +   message_cont = 1;
> +}
> +
>  const char *
> -message_set(const char *msg) {
> -   char *prev = curr_message;
> -   if (msg)
> +message_set(const char *msg)
> +{
> +   free(curr_message);
> +
> +   if (msg) {
> curr_message = strdup(msg);
> -   else
> +   message_cont = 0;
> +   } else {
> curr_message = NULL;
> -   free(prev);
> +   message_cont = 1;
> +   }
> return NULL;
>  }
>  
> @@ -1361,6 +1375,22 @@ engine_loop(int countmax)
> if (!averageonly ||
>     (averageonly && count == countmax - 1))
> disp_update();
> +   if (message_cont) {
> +   switch (message_mode) {
> +   case MESSAGE_NONE:
> +   message_set(NULL);
> +   break;
> +   case MESSAGE_HELP:
> +   show_help();
> +   break;
> +   case MESSAGE_VIEW:
> +   show_view();
> +   break;
> +   case MESSAGE_ORDER:
> +   show_order();
> +   break;
> +   }
> +   }
> 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.h12 Jan 2020 20:51:08 -  1.12
> +++ engine.h9 Mar 2021 18:32:24 -
> @@ -95,6 +95,12 @@ struct command {
> void ( *exec)(const char *);
>  };
>  
> +enum message_mode {
> +   MESSAGE_NONE,
> +   MESSAGE_HELP,
> +   MESSAGE_VIEW,
> +   MESSAGE_ORDER
> +};
>  
>  void tb_start(void);
>  
> @@ -133,6 +139,9 @@ void prev_view(void);
>  int foreach_order(void (*callback)(order_type *));
>  void set_order(const char *opt);
>  void next_order(void);
> +void show_help(void);
> +void show_view(void);
> +void show_order(void);
>  
>  void setup_term(int maxpr);
>  int check_termcap(void);
> @@ -141,6 +150,7 @@ void engine_initialize(void);
>  void engine_loop(int countmax);
>  
>  struct command *command_set(struct command *cmd, const char *init);
> 

Re: systat(1) sticky help

2021-03-09 Thread Martijn van Duren
I send out an earlier version of this diff to Anindya with some positive
feedback. Instead of claiming another binding, why not make help, order
and view a toggle? I see no reason why this information should disappear
on the next input.

Seems to work fine in my testing.

OK?

martijn@

On Thu, 2021-03-04 at 22:47 -0800, Anindya Mukherjee wrote:
> Hi,
> 
> I have reworked my proposed interface for sticky displays in systat
> following earlier feedback. Thanks for that! It helped me rethink the
> interface carefully.
> 
> In the current version, sticky mode has its own toggle: ^T. From a study
> of the source and the man page it does not seem to be bound to anything
> and, on my system at least, does not conflict with anything else. I
> could add a dedicated command for it as well if that's useful. The
> current version supports a sticky display for the view list, view mode
> plus refresh interval, and available orderings.
> 
> I have tried the hotkeys for the various views as documented in the man
> page (as well as some of the undocumented ones) and they seem to work. I
> have also tried to make sure that the sticky displays don't interfere
> with error messages. In future I would like to try to clean up the view
> hotkeys, which conflict each other in some cases, and seem to be
> undocumented. I found them useful; at least the ones that work. 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.c6 Feb 2021 06:19:28 -   1.27
+++ engine.c9 Mar 2021 18:32:24 -
@@ -91,6 +91,8 @@ char cmdbuf[MAX_LINE_BUF];
 int cmd_len = -1;
 struct command *curr_cmd = NULL;
 char *curr_message = NULL;
+enum message_mode message_mode = MESSAGE_NONE;
+int message_cont = 1;
 
 void print_cmdline(void);
 
@@ -1145,14 +1147,26 @@ command_set(struct command *cmd, const c
return prev;
 }
 
+void
+message_toggle(enum message_mode mode)
+{
+   message_mode = message_mode != mode ? mode : MESSAGE_NONE;
+   need_update = 1;
+   message_cont = 1;
+}
+
 const char *
-message_set(const char *msg) {
-   char *prev = curr_message;
-   if (msg)
+message_set(const char *msg)
+{
+   free(curr_message);
+
+   if (msg) {
curr_message = strdup(msg);
-   else
+   message_cont = 0;
+   } else {
curr_message = NULL;
-   free(prev);
+   message_cont = 1;
+   }
return NULL;
 }
 
@@ -1361,6 +1375,22 @@ engine_loop(int countmax)
if (!averageonly ||
(averageonly && count == countmax - 1))
disp_update();
+   if (message_cont) {
+   switch (message_mode) {
+   case MESSAGE_NONE:
+   message_set(NULL);
+   break;
+   case MESSAGE_HELP:
+   show_help();
+   break;
+   case MESSAGE_VIEW:
+   show_view();
+   break;
+   case MESSAGE_ORDER:
+   show_order();
+   break;
+   }
+   }
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.h12 Jan 2020 20:51:08 -  1.12
+++ engine.h9 Mar 2021 18:32:24 -
@@ -95,6 +95,12 @@ struct command {
void ( *exec)(const char *);
 };
 
+enum message_mode {
+   MESSAGE_NONE,
+   MESSAGE_HELP,
+   MESSAGE_VIEW,
+   MESSAGE_ORDER
+};
 
 void tb_start(void);
 
@@ -133,6 +139,9 @@ void prev_view(void);
 int foreach_order(void (*callback)(order_type *));
 void set_order(const char *opt);
 void next_order(void);
+void show_help(void);
+void show_view(void);
+void show_order(void);
 
 void setup_term(int maxpr);
 int check_termcap(void);
@@ -141,6 +150,7 @@ void engine_initialize(void);
 void engine_loop(int countmax);
 
 struct command *command_set(struct command *cmd, const char *init);
+void message_toggle(enum message_mode);
 const char *message_set(const char *msg);
 
 void foreach_view(void (*callback)(field_view *));
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 

Re: systat(1) sticky help

2021-03-04 Thread Anindya Mukherjee
Hi,

I have reworked my proposed interface for sticky displays in systat
following earlier feedback. Thanks for that! It helped me rethink the
interface carefully.

In the current version, sticky mode has its own toggle: ^T. From a study
of the source and the man page it does not seem to be bound to anything
and, on my system at least, does not conflict with anything else. I
could add a dedicated command for it as well if that's useful. The
current version supports a sticky display for the view list, view mode
plus refresh interval, and available orderings.

I have tried the hotkeys for the various views as documented in the man
page (as well as some of the undocumented ones) and they seem to work. I
have also tried to make sure that the sticky displays don't interfere
with error messages. In future I would like to try to clean up the view
hotkeys, which conflict each other in some cases, and seem to be
undocumented. I found them useful; at least the ones that work. 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.c6 Feb 2021 06:19:28 -   1.27
+++ engine.c5 Mar 2021 02:35:36 -
@@ -70,6 +70,8 @@ volatile sig_atomic_t gotsig_alarm = 0;
 int need_update = 0;
 int need_sort = 0;
 int separate_thousands = 0;
+enum sticky_mode sticky_mode = STICKY_NONE;
+int sticky = 0;
 
 SCREEN *screen;
 
@@ -1139,7 +1141,15 @@ command_set(struct command *cmd, const c
cmdbuf[0] = 0;
}
}
-   message_set(NULL);
+
+   if (curr_message != NULL) {
+   if (!sticky) {
+   message_set(NULL);
+   sticky_mode = STICKY_NONE;
+   } else if (sticky_mode == STICKY_NONE)
+   message_set(NULL);
+   }
+
curr_cmd = cmd;
need_update = 1;
return prev;
@@ -1165,7 +1175,10 @@ print_cmdline(void)
attroff(A_STANDOUT);
printw("%s", cmdbuf);
} else if (curr_message) {
-   mvprintw(home_line, 0, "> %s", curr_message);
+   if (sticky)
+   mvprintw(home_line, 0, "*> %s", curr_message);
+   else
+   mvprintw(home_line, 0, "> %s", curr_message);
}
clrtoeol();
 }
@@ -1233,8 +1246,12 @@ keyboard(void)
if (curr_mgr->key_fn(ch))
return;
 
-   if (curr_message != NULL) {
-   if (ch > 0) {
+   if (curr_message != NULL && ch > 0) {
+   if (!sticky) {
+   message_set(NULL);
+   sticky_mode = STICKY_NONE;
+   need_update = 1;
+   } else if (sticky_mode == STICKY_NONE) {
message_set(NULL);
need_update = 1;
}
@@ -1359,8 +1376,24 @@ engine_loop(int countmax)
if (need_update) {
erase();
if (!averageonly ||
-   (averageonly && count == countmax - 1))
+   (averageonly && count == countmax - 1)) {
disp_update();
+   if (interactive && sticky) {
+   switch (sticky_mode) {
+   case STICKY_NONE:
+   break;
+   case STICKY_HELP:
+   show_help();
+   break;
+   case STICKY_VIEW:
+   show_view();
+   break;
+   case STICKY_ORDER:
+   show_order();
+   break;
+   }
+   }
+   }
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.h12 Jan 2020 20:51:08 -  1.12
+++ engine.h5 Mar 2021 02:35:36 -
@@ -36,6 +36,7 @@
 #define CTRL_L  12
 #define CTRL_N  14
 #define CTRL_P  16
+#define CTRL_T  20
 #define CTRL_V  22
 
 #define META_V  246
@@ -95,9 +96,9 @@ struct command {
void ( *exec)(const char *);
 };
 
+enum sticky_mode {STICKY_NONE, STICKY_HELP, STICKY_VIEW, STICKY_ORDER};
 
 void tb_start(void);
-
 void tb_end(void);
 
 int tbprintf(

Re: systat(1) sticky help

2021-02-28 Thread Martijn van Duren
On Sun, 2021-02-28 at 23:03 -0800, Anindya Mukherjee wrote:
> Hi,
> 
> Thanks for the feedback. I see your point. Perhaps it would be better to
> have a separate "stickiness" toggle and not tie it to the help or the
> view name display functions. For example, pressing 't' could toggle it
> on and then pressing 'h' or Ctrl-G would make the display stick.
> Pressing 't' again would toggle it off, and then the display would get
> cleared normally.

Something like that seems better, but keep in mind that the single key
bindings within systat is a mess: 't' might already be allocated by one
of the views. When submitting your followup, try to make sure that you
considered all possible issues, including the keybindings, and show
how you came to your conclusion.
> 
> Regards,
> Anindya
> 
> On Mon, Mar 01, 2021 at 07:49:49AM +0100, Martijn van Duren wrote:
> > Although the feature *might* be useful (just woken up, so haven't given
> > it too much thought), the bindings have some problems and need to be
> > reworked if we decide to get this in. Problems that I see from just a
> > few short tests (so there might be others):
> > - Entering sticky: H, which also enters help, which is annoying if I
> >   want sticky ^G.
> > - Clearing sticky: h, which also displays help, which if I come from
> >   ^G is not what I want and if I'm in help is confusing, because I want
> >   to get rid of it.
> > 
> > martijn@
> > 
> > On Sun, 2021-02-28 at 19:40 -0800, Anindya Mukherjee wrote:
> > > 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.c6 Feb 2021 06:19:28 -   1.27
> > > +++ engine.c1 Mar 2021 03:20:41 -
> > > @@ -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.h12 Jan 2020 20:51:08 -  1.12
> > > +++ engine.h1 Mar 2021 03:20:41 -
> > > @@ -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;
> > > 

Re: systat(1) sticky help

2021-02-28 Thread Anindya Mukherjee
Hi,

Thanks for the feedback. I see your point. Perhaps it would be better to
have a separate "stickiness" toggle and not tie it to the help or the
view name display functions. For example, pressing 't' could toggle it
on and then pressing 'h' or Ctrl-G would make the display stick.
Pressing 't' again would toggle it off, and then the display would get
cleared normally.

Regards,
Anindya

On Mon, Mar 01, 2021 at 07:49:49AM +0100, Martijn van Duren wrote:
> Although the feature *might* be useful (just woken up, so haven't given
> it too much thought), the bindings have some problems and need to be
> reworked if we decide to get this in. Problems that I see from just a
> few short tests (so there might be others):
> - Entering sticky: H, which also enters help, which is annoying if I
>   want sticky ^G.
> - Clearing sticky: h, which also displays help, which if I come from
>   ^G is not what I want and if I'm in help is confusing, because I want
>   to get rid of it.
> 
> martijn@
> 
> On Sun, 2021-02-28 at 19:40 -0800, Anindya Mukherjee wrote:
> > 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.c6 Feb 2021 06:19:28 -   1.27
> > +++ engine.c1 Mar 2021 03:20:41 -
> > @@ -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.h12 Jan 2020 20:51:08 -  1.12
> > +++ engine.h1 Mar 2021 03:20:41 -
> > @@ -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 -  1.73
> > +++ main.c  1 Mar 2021 03:20:41 -
> > @@ -285,

Re: systat(1) sticky help

2021-02-28 Thread Martijn van Duren
Although the feature *might* be useful (just woken up, so haven't given
it too much thought), the bindings have some problems and need to be
reworked if we decide to get this in. Problems that I see from just a
few short tests (so there might be others):
- Entering sticky: H, which also enters help, which is annoying if I
  want sticky ^G.
- Clearing sticky: h, which also displays help, which if I come from
  ^G is not what I want and if I'm in help is confusing, because I want
  to get rid of it.

martijn@

On Sun, 2021-02-28 at 19:40 -0800, Anindya Mukherjee wrote:
> 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.c6 Feb 2021 06:19:28 -   1.27
> +++ engine.c1 Mar 2021 03:20:41 -
> @@ -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.h12 Jan 2020 20:51:08 -  1.12
> +++ engine.h1 Mar 2021 03:20:41 -
> @@ -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 -  1.73
> +++ main.c  1 Mar 2021 03:20:41 -
> @@ -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':
>

systat(1) sticky help

2021-02-28 Thread Anindya Mukherjee
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.c6 Feb 2021 06:19:28 -   1.27
+++ engine.c1 Mar 2021 03:20:41 -
@@ -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.h12 Jan 2020 20:51:08 -  1.12
+++ engine.h1 Mar 2021 03:20:41 -
@@ -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 -  1.73
+++ main.c  1 Mar 2021 03:20:41 -
@@ -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.122 Jun 2020 13:17:54 -  1.119
+++ systat.11 Mar 2021 03:20:41 -
@@ -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