Re: systat.1: Trim ":" description, support line kill character

2020-06-23 Thread Klemens Nanni
On Mon, Jun 22, 2020 at 08:57:43PM -0600, Theo de Raadt wrote:
> In OpenBSD, the erase character is ^?
> 
> ^H is accepted in a few places, like here (because of CTRL_H) but
> it is absolutely not the canonical tty 'character erase' character,
> which is implied in your text by placing it next to kill and the
> canonical tty werase default ^U
Right, ^H works here and there but erase is in fact ^?.

^U is usually line kill, not word erase, no?

> It was vague, and I guess OK.  But your increasing precision is making
> it wrong.
Just add ^U as canonical line kill and leave the manual as is.

Feedback? OK?


Index: engine.c
===
RCS file: /cvs/src/usr.bin/systat/engine.c,v
retrieving revision 1.25
diff -u -p -r1.25 engine.c
--- engine.c12 Jan 2020 20:51:08 -  1.25
+++ engine.c22 Jun 2020 13:39:51 -
@@ -1204,6 +1204,7 @@ cmd_keyboard(int ch)
break;
case 0x1b:
case CTRL_G:
+   case CTRL_U:
if (cmd_len > 0) {
cmdbuf[0] = '\0';
cmd_len = 0;
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.h22 Jun 2020 13:39:52 -
@@ -36,6 +36,7 @@
 #define CTRL_L  12
 #define CTRL_N  14
 #define CTRL_P  16
+#define CTRL_U  21
 #define CTRL_V  22
 
 #define META_V  246



Re: systat.1: Trim ":" description, support line kill character

2020-06-22 Thread Theo de Raadt
In OpenBSD, the erase character is ^?

^H is accepted in a few places, like here (because of CTRL_H) but
it is absolutely not the canonical tty 'character erase' character,
which is implied in your text by placing it next to kill and the
canonical tty werase default ^U

It was vague, and I guess OK.  But your increasing precision is making
it wrong.

Klemens Nanni  wrote:

> On Mon, Jun 22, 2020 at 06:33:30PM -0600, Theo de Raadt wrote:
> > > +character erase (^H) and line kill (^U) characters
> > 
> > ^H is wrong
> How so?  It is currently hardcoded as such in engine.c:cmd_keyboard():
> 
> 1188 switch (ch) {
> 1189 case KEY_ENTER:
> 1190 case 0x0a:
> 1191 case 0x0d:
> 1192 {
> 1193 struct command * c = command_set(NULL, NULL);
> 1194 c->exec(cmdbuf);
> 1195 break;
> 1196 }
> 1197 case KEY_BACKSPACE:
> 1198 case KEY_DC:
> 1199 case CTRL_H:
> 1200 if (cmd_len > 0) {
> 1201 cmdbuf[--cmd_len] = 0;
> 1202 } else
> 1203 beep();
> 1204 break;
> 1205 case 0x1b:
> 1206 case CTRL_G:
> 1207 if (cmd_len > 0) {
> 1208 cmdbuf[0] = '\0';
> 1209 cmd_len = 0;
> 1210 } else
> 1211 command_set(NULL, NULL);
> 1212 break;
> 1213 default:
> 1214 break;
> 1215 }
> 1216 }
> 



Re: systat.1: Trim ":" description, support line kill character

2020-06-22 Thread Klemens Nanni
On Mon, Jun 22, 2020 at 06:33:30PM -0600, Theo de Raadt wrote:
> > +character erase (^H) and line kill (^U) characters
> 
> ^H is wrong
How so?  It is currently hardcoded as such in engine.c:cmd_keyboard():

1188 switch (ch) {
1189 case KEY_ENTER:
1190 case 0x0a:
1191 case 0x0d:
1192 {
1193 struct command * c = command_set(NULL, NULL);
1194 c->exec(cmdbuf);
1195 break;
1196 }
1197 case KEY_BACKSPACE:
1198 case KEY_DC:
1199 case CTRL_H:
1200 if (cmd_len > 0) {
1201 cmdbuf[--cmd_len] = 0;
1202 } else
1203 beep();
1204 break;
1205 case 0x1b:
1206 case CTRL_G:
1207 if (cmd_len > 0) {
1208 cmdbuf[0] = '\0';
1209 cmd_len = 0;
1210 } else
1211 command_set(NULL, NULL);
1212 break;
1213 default:
1214 break;
1215 }
1216 }



Re: systat.1: Trim ":" description, support line kill character

2020-06-22 Thread Theo de Raadt
> +character erase (^H) and line kill (^U) characters

^H is wrong



Re: systat.1: Trim ":" description, support line kill character

2020-06-22 Thread Klemens Nanni
On Mon, Jun 22, 2020 at 07:13:30AM +0100, Jason McIntyre wrote:
> how will people be able to find this if we don;t document it? from a
> brief skim of docs which may hold answers, i still can;t find where
> these values are documented.
Fair point, I removed them because they imply that systat honours
whatever keys control character are bound to, even though it in fact
hardcodes keys such as ^H for character kill and ^G for line kill.

top(1)'s INTERACTIVE MODE section for example ends with

While typing this information in, the user's erase and kill
keys (as set up by the command stty(1)) are recognized, and a newline
terminates the input.

and this indeed correct for top, but systat(1) behaves differently as
can be easily observed when for example binding character kill to @
instead of ^?:

$ stty erase @
$ top
$ systat

Then use any interactive menu and note how in top @ now erases the
last character while backspace prints "^?", whereas in systat @ still
prints "@" and backspace still erase the last character.

> couldn;t we document these work and what the defaults are? it seems
> handy.
Here's an updated diff that adds ^U (default control character for line
kill), documents the two hardcoded keys as such while removing the lie
about unimplemented word kill.

Is that any better?


Index: engine.c
===
RCS file: /cvs/src/usr.bin/systat/engine.c,v
retrieving revision 1.25
diff -u -p -r1.25 engine.c
--- engine.c12 Jan 2020 20:51:08 -  1.25
+++ engine.c22 Jun 2020 13:39:51 -
@@ -1204,6 +1204,7 @@ cmd_keyboard(int ch)
break;
case 0x1b:
case CTRL_G:
+   case CTRL_U:
if (cmd_len > 0) {
cmdbuf[0] = '\0';
cmd_len = 0;
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.h22 Jun 2020 13:39:52 -
@@ -36,6 +36,7 @@
 #define CTRL_L  12
 #define CTRL_N  14
 #define CTRL_P  16
+#define CTRL_U  21
 #define CTRL_V  22
 
 #define META_V  246
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.123 Jun 2020 00:26:43 -
@@ -173,7 +173,7 @@ These are:
 Move the cursor to the command line and interpret the input
 line typed as a command.
 While entering a command the
-current character erase, word erase, and line kill characters
+character erase (^H) and line kill (^U) characters
 may be used.
 .It Ic o
 Select the next ordering which sorts the rows according to a



Re: systat.1: Trim ":" description, support line kill character

2020-06-22 Thread Jason McIntyre
On Mon, Jun 22, 2020 at 05:49:43AM +0200, Klemens Nanni wrote:
> The manual's wording is untouched since import in 1995, engine.c however
> came to be in 2008 as "New display engine for systat" from canacar.
> 
> While characte erase (^h) works, word erase (^w) is not implemented and
> line kill (^u) is supported but as ^g instead.
> 
> I see no value in documenting this either way, so remove the lines from
> the manual but also support the actual line kill character for.
> 
> Feedback? OK?
> 

morning.

how will people be able to find this if we don;t document it? from a
brief skim of docs which may hold answers, i still can;t find where
these values are documented.

couldn;t we document these work and what the defaults are? it seems
handy.

jmc

> 
> Index: engine.c
> ===
> RCS file: /cvs/src/usr.bin/systat/engine.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 engine.c
> --- engine.c  12 Jan 2020 20:51:08 -  1.25
> +++ engine.c  22 Jun 2020 03:35:40 -
> @@ -1204,6 +1204,7 @@ cmd_keyboard(int ch)
>   break;
>   case 0x1b:
>   case CTRL_G:
> + case CTRL_U:
>   if (cmd_len > 0) {
>   cmdbuf[0] = '\0';
>   cmd_len = 0;
> 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  22 Jun 2020 03:36:21 -
> @@ -36,6 +36,7 @@
>  #define CTRL_L  12
>  #define CTRL_N  14
>  #define CTRL_P  16
> +#define CTRL_U  21
>  #define CTRL_V  22
>  
>  #define META_V  246
> Index: systat.1
> ===
> RCS file: /cvs/src/usr.bin/systat/systat.1,v
> retrieving revision 1.117
> diff -u -p -r1.117 systat.1
> --- systat.1  23 Apr 2020 07:57:27 -  1.117
> +++ systat.1  22 Jun 2020 03:09:25 -
> @@ -172,9 +172,6 @@ These are:
>  .It Ic \&:
>  Move the cursor to the command line and interpret the input
>  line typed as a command.
> -While entering a command the
> -current character erase, word erase, and line kill characters
> -may be used.
>  .It Ic o
>  Select the next ordering which sorts the rows according to a
>  combination of columns.
>