All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
@ 2016-10-30 11:38 Samuel Thibault
  2016-10-30 11:46 ` [Qemu-devel] [PATCH] curses: support wide input Samuel Thibault
  0 siblings, 1 reply; 12+ messages in thread
From: Samuel Thibault @ 2016-10-30 11:38 UTC (permalink / raw)
  To: qemu-devel, kraxel

By default, curses will only report single ESC key event after 1s delay,
since ESC is also used for keypad escape sequences. This however makes users
believe that ESC is not working. Reducing to 0.2s provides good enough user
experience, while still allowing 200ms for keypad sequences to get in, which
should be more than enough.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
rebased on master

diff --git a/ui/curses.c b/ui/curses.c
index 2e132a7..3599295 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -216,7 +216,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
         keycode = curses2keycode[chr];
         keycode_alt = 0;
 
-        /* alt key */
+        /* alt or esc key */
         if (keycode == 1) {
             int nextchr = getch();
 
@@ -345,6 +345,7 @@ static void curses_setup(void)
     initscr(); noecho(); intrflush(stdscr, FALSE);
     nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
     start_color(); raw(); scrollok(stdscr, FALSE);
+    set_escdelay(200);
 
     /* Make color pair to match color format (3bits bg:3bits fg) */
     for (i = 0; i < 64; i++) {

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH] curses: support wide input
  2016-10-30 11:38 [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s Samuel Thibault
@ 2016-10-30 11:46 ` Samuel Thibault
  0 siblings, 0 replies; 12+ messages in thread
From: Samuel Thibault @ 2016-10-30 11:46 UTC (permalink / raw)
  To: qemu-devel, kraxel

This makes use of wide curses functions instead of 8bit functions. This
allows to type e.g. accented letters.

Unfortunately, key codes are then returned with values that could be
confused with wide characters by ncurses, so we need to add a maybe_keycode
variable to know whether the returned value is a key code or a character
(wide support), or possibly both (non-wide support).

The translation tables thus also need to be separated into key code
translation and character translation.  The curses2foo helper makes it easier
to use them.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
This is to be applied on top of the escdelay patch: the mere comment
modification in there was what was making this patch fail to apply.

diff --git a/ui/curses.c b/ui/curses.c
index f839a9d..441cc93 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -43,6 +43,12 @@
 #define FONT_HEIGHT 16
 #define FONT_WIDTH 8
 
+enum maybe_keycode {
+    CURSES_KEYCODE,
+    CURSES_CHAR,
+    CURSES_CHAR_OR_KEYCODE,
+};
+
 static DisplayChangeListener *dcl;
 static console_ch_t screen[160 * 100];
 static WINDOW *screenpad = NULL;
@@ -51,6 +57,23 @@ static int px, py, sminx, sminy, smaxx, smaxy;
 
 console_ch_t vga_to_curses[256];
 
+static wint_t console_getch(int *maybe_keycode)
+{
+    wint_t ret;
+    switch (get_wch(&ret)) {
+    case KEY_CODE_YES:
+        *maybe_keycode = CURSES_KEYCODE;
+        break;
+    case OK:
+        *maybe_keycode = CURSES_CHAR;
+        break;
+    case ERR:
+        ret = -1;
+        break;
+    }
+    return ret;
+}
+
 static void curses_update(DisplayChangeListener *dcl,
                           int x, int y, int w, int h)
 {
@@ -186,9 +209,37 @@ static void curses_cursor_position(DisplayChangeListener *dcl,
 
 static kbd_layout_t *kbd_layout = NULL;
 
+static int curses2foo(const int _curses2foo[], const int _curseskey2foo[],
+                      int chr, int maybe_keycode)
+{
+    int ret = -1;
+    if (maybe_keycode == CURSES_CHAR) {
+        if (chr < CURSES_CHARS) {
+            ret = _curses2foo[chr];
+        }
+    } else {
+        if (chr < CURSES_KEYS) {
+            ret = _curseskey2foo[chr];
+        }
+        if (ret == -1 && maybe_keycode == CURSES_CHAR_OR_KEYCODE &&
+            chr < CURSES_CHARS) {
+            ret = _curses2foo[chr];
+        }
+    }
+    return ret;
+}
+
+#define curses2keycode(chr, maybe_keycode) \
+    curses2foo(_curses2keycode, _curseskey2keycode, chr, maybe_keycode)
+#define curses2keysym(chr, maybe_keycode) \
+    curses2foo(_curses2keysym, _curseskey2keysym, chr, maybe_keycode)
+#define curses2qemu(chr, maybe_keycode) \
+    curses2foo(_curses2qemu, _curseskey2qemu, chr, maybe_keycode)
+
 static void curses_refresh(DisplayChangeListener *dcl)
 {
     int chr, keysym, keycode, keycode_alt;
+    int maybe_keycode;
 
     curses_winch_check();
 
@@ -204,14 +255,14 @@ static void curses_refresh(DisplayChangeListener *dcl)
 
     while (1) {
         /* while there are any pending key strokes to process */
-        chr = getch();
+        chr = console_getch(&maybe_keycode);
 
-        if (chr == ERR)
+        if (chr == -1)
             break;
 
 #ifdef KEY_RESIZE
         /* this shouldn't occur when we use a custom SIGWINCH handler */
-        if (chr == KEY_RESIZE) {
+        if (maybe_keycode != 0 && chr == KEY_RESIZE) {
             clear();
             refresh();
             curses_calc_pad();
@@ -220,17 +271,19 @@ static void curses_refresh(DisplayChangeListener *dcl)
         }
 #endif
 
-        keycode = curses2keycode[chr];
+        keycode = curses2keycode(chr, maybe_keycode);
         keycode_alt = 0;
 
         /* alt or esc key */
         if (keycode == 1) {
-            int nextchr = getch();
+            int next_maybe_keycode;
+            int nextchr = console_getch(&next_maybe_keycode);
 
-            if (nextchr != ERR) {
+            if (nextchr != -1) {
                 chr = nextchr;
+                maybe_keycode = next_maybe_keycode;
                 keycode_alt = ALT;
-                keycode = curses2keycode[chr];
+                keycode = curses2keycode(chr, maybe_keycode);
 
                 if (keycode != -1) {
                     keycode |= ALT;
@@ -250,9 +303,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
         }
 
         if (kbd_layout) {
-            keysym = -1;
-            if (chr < CURSES_KEYS)
-                keysym = curses2keysym[chr];
+            keysym = curses2keysym(chr, maybe_keycode);
 
             if (keysym == -1) {
                 if (chr < ' ') {
@@ -317,10 +368,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
                 qemu_input_event_send_key_delay(0);
             }
         } else {
-            keysym = -1;
-            if (chr < CURSES_KEYS) {
-                keysym = curses2qemu[chr];
-            }
+            keysym = curses2qemu(chr, maybe_keycode);
             if (keysym == -1)
                 keysym = chr;
 
diff --git a/ui/curses_keys.h b/ui/curses_keys.h
index e39ef9e..ba561f1 100644
--- a/ui/curses_keys.h
+++ b/ui/curses_keys.h
@@ -49,22 +49,28 @@
 /* curses won't detect a Control + Alt + 1, so use Alt + 1 */
 #define QEMU_KEY_CONSOLE0   (2 | ALT)   /* (curses2keycode['1'] | ALT) */
 
+#define CURSES_CHARS        0x100       /* Support latin1 only */
 #define CURSES_KEYS         KEY_MAX     /* KEY_MAX defined in <curses.h> */
 
-static const int curses2keysym[CURSES_KEYS] = {
-    [0 ... (CURSES_KEYS - 1)] = -1,
+static const int _curses2keysym[CURSES_CHARS] = {
+    [0 ... (CURSES_CHARS - 1)] = -1,
 
     [0x7f] = KEY_BACKSPACE,
     ['\r'] = KEY_ENTER,
     ['\n'] = KEY_ENTER,
     [27] = 27,
+};
+
+static const int _curseskey2keysym[CURSES_KEYS] = {
+    [0 ... (CURSES_KEYS - 1)] = -1,
+
     [KEY_BTAB] = '\t' | KEYSYM_SHIFT,
     [KEY_SPREVIOUS] = KEY_PPAGE | KEYSYM_SHIFT,
     [KEY_SNEXT] = KEY_NPAGE | KEYSYM_SHIFT,
 };
 
-static const int curses2keycode[CURSES_KEYS] = {
-    [0 ... (CURSES_KEYS - 1)] = -1,
+static const int _curses2keycode[CURSES_CHARS] = {
+    [0 ... (CURSES_CHARS - 1)] = -1,
 
     [0x01b] = 1, /* Escape */
     ['1'] = 2,
@@ -80,7 +86,6 @@ static const int curses2keycode[CURSES_KEYS] = {
     ['-'] = 12,
     ['='] = 13,
     [0x07f] = 14, /* Backspace */
-    [KEY_BACKSPACE] = 14, /* Backspace */
 
     ['\t'] = 15, /* Tab */
     ['q'] = 16,
@@ -97,7 +102,6 @@ static const int curses2keycode[CURSES_KEYS] = {
     [']'] = 27,
     ['\n'] = 28, /* Return */
     ['\r'] = 28, /* Return */
-    [KEY_ENTER] = 28, /* Return */
 
     ['a'] = 30,
     ['s'] = 31,
@@ -126,33 +130,6 @@ static const int curses2keycode[CURSES_KEYS] = {
 
     [' '] = 57,
 
-    [KEY_F(1)] = 59, /* Function Key 1 */
-    [KEY_F(2)] = 60, /* Function Key 2 */
-    [KEY_F(3)] = 61, /* Function Key 3 */
-    [KEY_F(4)] = 62, /* Function Key 4 */
-    [KEY_F(5)] = 63, /* Function Key 5 */
-    [KEY_F(6)] = 64, /* Function Key 6 */
-    [KEY_F(7)] = 65, /* Function Key 7 */
-    [KEY_F(8)] = 66, /* Function Key 8 */
-    [KEY_F(9)] = 67, /* Function Key 9 */
-    [KEY_F(10)] = 68, /* Function Key 10 */
-    [KEY_F(11)] = 87, /* Function Key 11 */
-    [KEY_F(12)] = 88, /* Function Key 12 */
-
-    [KEY_HOME] = 71 | GREY, /* Home */
-    [KEY_UP] = 72 | GREY, /* Up Arrow */
-    [KEY_PPAGE] = 73 | GREY, /* Page Up */
-    [KEY_LEFT] = 75 | GREY, /* Left Arrow */
-    [KEY_RIGHT] = 77 | GREY, /* Right Arrow */
-    [KEY_END] = 79 | GREY, /* End */
-    [KEY_DOWN] = 80 | GREY, /* Down Arrow */
-    [KEY_NPAGE] = 81 | GREY, /* Page Down */
-    [KEY_IC] = 82 | GREY, /* Insert */
-    [KEY_DC] = 83 | GREY, /* Delete */
-
-    [KEY_SPREVIOUS] = 73 | GREY | SHIFT, /* Shift + Page Up */
-    [KEY_SNEXT] = 81 | GREY | SHIFT, /* Shift + Page Down */
-
     ['!'] = 2 | SHIFT,
     ['@'] = 3 | SHIFT,
     ['#'] = 4 | SHIFT,
@@ -166,7 +143,6 @@ static const int curses2keycode[CURSES_KEYS] = {
     ['_'] = 12 | SHIFT,
     ['+'] = 13 | SHIFT,
 
-    [KEY_BTAB] = 15 | SHIFT, /* Shift + Tab */
     ['Q'] = 16 | SHIFT,
     ['W'] = 17 | SHIFT,
     ['E'] = 18 | SHIFT,
@@ -205,19 +181,6 @@ static const int curses2keycode[CURSES_KEYS] = {
     ['>'] = 52 | SHIFT,
     ['?'] = 53 | SHIFT,
 
-    [KEY_F(13)] = 59 | SHIFT, /* Shift + Function Key 1 */
-    [KEY_F(14)] = 60 | SHIFT, /* Shift + Function Key 2 */
-    [KEY_F(15)] = 61 | SHIFT, /* Shift + Function Key 3 */
-    [KEY_F(16)] = 62 | SHIFT, /* Shift + Function Key 4 */
-    [KEY_F(17)] = 63 | SHIFT, /* Shift + Function Key 5 */
-    [KEY_F(18)] = 64 | SHIFT, /* Shift + Function Key 6 */
-    [KEY_F(19)] = 65 | SHIFT, /* Shift + Function Key 7 */
-    [KEY_F(20)] = 66 | SHIFT, /* Shift + Function Key 8 */
-    [KEY_F(21)] = 67 | SHIFT, /* Shift + Function Key 9 */
-    [KEY_F(22)] = 68 | SHIFT, /* Shift + Function Key 10 */
-    [KEY_F(23)] = 69 | SHIFT, /* Shift + Function Key 11 */
-    [KEY_F(24)] = 70 | SHIFT, /* Shift + Function Key 12 */
-
     ['Q' - '@'] = 16 | CNTRL, /* Control + q */
     ['W' - '@'] = 17 | CNTRL, /* Control + w */
     ['E' - '@'] = 18 | CNTRL, /* Control + e */
@@ -249,13 +212,67 @@ static const int curses2keycode[CURSES_KEYS] = {
 
 };
 
-static const int curses2qemu[CURSES_KEYS] = {
+static const int _curseskey2keycode[CURSES_KEYS] = {
     [0 ... (CURSES_KEYS - 1)] = -1,
 
+    [KEY_BACKSPACE] = 14, /* Backspace */
+
+    [KEY_ENTER] = 28, /* Return */
+
+    [KEY_F(1)] = 59, /* Function Key 1 */
+    [KEY_F(2)] = 60, /* Function Key 2 */
+    [KEY_F(3)] = 61, /* Function Key 3 */
+    [KEY_F(4)] = 62, /* Function Key 4 */
+    [KEY_F(5)] = 63, /* Function Key 5 */
+    [KEY_F(6)] = 64, /* Function Key 6 */
+    [KEY_F(7)] = 65, /* Function Key 7 */
+    [KEY_F(8)] = 66, /* Function Key 8 */
+    [KEY_F(9)] = 67, /* Function Key 9 */
+    [KEY_F(10)] = 68, /* Function Key 10 */
+    [KEY_F(11)] = 87, /* Function Key 11 */
+    [KEY_F(12)] = 88, /* Function Key 12 */
+
+    [KEY_HOME] = 71 | GREY, /* Home */
+    [KEY_UP] = 72 | GREY, /* Up Arrow */
+    [KEY_PPAGE] = 73 | GREY, /* Page Up */
+    [KEY_LEFT] = 75 | GREY, /* Left Arrow */
+    [KEY_RIGHT] = 77 | GREY, /* Right Arrow */
+    [KEY_END] = 79 | GREY, /* End */
+    [KEY_DOWN] = 80 | GREY, /* Down Arrow */
+    [KEY_NPAGE] = 81 | GREY, /* Page Down */
+    [KEY_IC] = 82 | GREY, /* Insert */
+    [KEY_DC] = 83 | GREY, /* Delete */
+
+    [KEY_SPREVIOUS] = 73 | GREY | SHIFT, /* Shift + Page Up */
+    [KEY_SNEXT] = 81 | GREY | SHIFT, /* Shift + Page Down */
+
+    [KEY_BTAB] = 15 | SHIFT, /* Shift + Tab */
+
+    [KEY_F(13)] = 59 | SHIFT, /* Shift + Function Key 1 */
+    [KEY_F(14)] = 60 | SHIFT, /* Shift + Function Key 2 */
+    [KEY_F(15)] = 61 | SHIFT, /* Shift + Function Key 3 */
+    [KEY_F(16)] = 62 | SHIFT, /* Shift + Function Key 4 */
+    [KEY_F(17)] = 63 | SHIFT, /* Shift + Function Key 5 */
+    [KEY_F(18)] = 64 | SHIFT, /* Shift + Function Key 6 */
+    [KEY_F(19)] = 65 | SHIFT, /* Shift + Function Key 7 */
+    [KEY_F(20)] = 66 | SHIFT, /* Shift + Function Key 8 */
+    [KEY_F(21)] = 67 | SHIFT, /* Shift + Function Key 9 */
+    [KEY_F(22)] = 68 | SHIFT, /* Shift + Function Key 10 */
+    [KEY_F(23)] = 69 | SHIFT, /* Shift + Function Key 11 */
+    [KEY_F(24)] = 70 | SHIFT, /* Shift + Function Key 12 */
+};
+
+static const int _curses2qemu[CURSES_CHARS] = {
+    [0 ... (CURSES_CHARS - 1)] = -1,
+
     ['\n'] = '\n',
     ['\r'] = '\n',
 
     [0x07f] = QEMU_KEY_BACKSPACE,
+};
+
+static const int _curseskey2qemu[CURSES_KEYS] = {
+    [0 ... (CURSES_KEYS - 1)] = -1,
 
     [KEY_DOWN] = QEMU_KEY_DOWN,
     [KEY_UP] = QEMU_KEY_UP,

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
  2019-03-03 17:11 ` Warner Losh
@ 2019-03-03 17:26   ` Samuel Thibault
  0 siblings, 0 replies; 12+ messages in thread
From: Samuel Thibault @ 2019-03-03 17:26 UTC (permalink / raw)
  To: Warner Losh; +Cc: QEMU Developers, Gerd Hoffmann

Warner Losh, le dim. 03 mars 2019 10:11:52 -0700, a ecrit:
> On Sun, Mar 3, 2019, 12:45 AM Samuel Thibault <[1]samuel.thibault@ens-lyon.org>
> wrote:
> 
>     By default, curses will only report single ESC key event after 1s delay,
>     since ESC is also used for keypad escape sequences. This however makes
>     users
>     believe that ESC is not working. Reducing to 0.2s provides good enough user
>     experience, while still allowing 200ms for keypad sequences to get in,
>     which
>     should be more than enough.
> 
> How did you come up with this number?

Since the default was very long, I chose a value that felt fast enough
for the user.

> Still seems a bit long for the ESC ESC case where the user hits ESC
> twice in quick succession.

Right, there might be such double-press.

> Even back in the day, terminals would send the characters back to back
> at 1200 baud, which is 8ms per character. 32ms is 4x that, 32x 9600
> baud rates. 25 or 50ms is suggested from these figures.

Alright, let's try 25 then.

Samuel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
  2019-03-03  6:14 [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s Samuel Thibault
@ 2019-03-03 17:11 ` Warner Losh
  2019-03-03 17:26   ` Samuel Thibault
  0 siblings, 1 reply; 12+ messages in thread
From: Warner Losh @ 2019-03-03 17:11 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: QEMU Developers, Gerd Hoffmann

On Sun, Mar 3, 2019, 12:45 AM Samuel Thibault <samuel.thibault@ens-lyon.org>
wrote:

> By default, curses will only report single ESC key event after 1s delay,
> since ESC is also used for keypad escape sequences. This however makes
> users
> believe that ESC is not working. Reducing to 0.2s provides good enough user
> experience, while still allowing 200ms for keypad sequences to get in,
> which
> should be more than enough.
>

How did you come up with this number? Still seems a bit long for the ESC
ESC case where the user hits ESC twice in quick succession. Even back in
the day, terminals would send the characters back to back at 1200 baud,
which is 8ms per character. 32ms is 4x that, 32x 9600 baud rates. 25 or
50ms is suggested from these figures.

Warner

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
>  ui/curses.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/ui/curses.c b/ui/curses.c
> index 6e0091c3b2..700315bc09 100644
> --- a/ui/curses.c
> +++ b/ui/curses.c
> @@ -231,7 +231,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
>          keycode = curses2keycode[chr];
>          keycode_alt = 0;
>
> -        /* alt key */
> +        /* alt or esc key */
>          if (keycode == 1) {
>              int nextchr = getch();
>
> @@ -361,6 +361,7 @@ static void curses_setup(void)
>      initscr(); noecho(); intrflush(stdscr, FALSE);
>      nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
>      start_color(); raw(); scrollok(stdscr, FALSE);
> +    set_escdelay(200);
>
>      /* Make color pair to match color format (3bits bg:3bits fg) */
>      for (i = 0; i < 64; i++) {
> --
> 2.20.1
>
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
@ 2019-03-03  6:14 Samuel Thibault
  2019-03-03 17:11 ` Warner Losh
  0 siblings, 1 reply; 12+ messages in thread
From: Samuel Thibault @ 2019-03-03  6:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: Samuel Thibault, Gerd Hoffmann

By default, curses will only report single ESC key event after 1s delay,
since ESC is also used for keypad escape sequences. This however makes users
believe that ESC is not working. Reducing to 0.2s provides good enough user
experience, while still allowing 200ms for keypad sequences to get in, which
should be more than enough.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 ui/curses.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ui/curses.c b/ui/curses.c
index 6e0091c3b2..700315bc09 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -231,7 +231,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
         keycode = curses2keycode[chr];
         keycode_alt = 0;
 
-        /* alt key */
+        /* alt or esc key */
         if (keycode == 1) {
             int nextchr = getch();
 
@@ -361,6 +361,7 @@ static void curses_setup(void)
     initscr(); noecho(); intrflush(stdscr, FALSE);
     nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
     start_color(); raw(); scrollok(stdscr, FALSE);
+    set_escdelay(200);
 
     /* Make color pair to match color format (3bits bg:3bits fg) */
     for (i = 0; i < 64; i++) {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
  2016-10-26 12:51     ` Gerd Hoffmann
@ 2016-10-26 15:20       ` Samuel Thibault
  0 siblings, 0 replies; 12+ messages in thread
From: Samuel Thibault @ 2016-10-26 15:20 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Peter Maydell, QEMU Developers

Gerd Hoffmann, on Wed 26 Oct 2016 14:51:00 +0200, wrote:
> On Sa, 2016-10-15 at 19:24 +0200, Samuel Thibault wrote:
> > Peter Maydell, on Wed 22 Jun 2016 21:49:04 +0100, wrote:
> > > On 22 June 2016 at 16:44, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> > > > By default, curses will only report single ESC key event after 1s delay,
> > > > since ESC is also used for keypad escape sequences. This however makes users
> > > > believe that ESC is not working. Reducing to 0.2s provides good enough user
> > > > experience, while still allowing 200ms for keypad sequences to get in, which
> > > > should be more than enough.
> > > 
> > > That the default delay is this massive seems like a bug in curses,
> > > but I don't suppose it's likely to be changed at this point :-(
> > 
> > So, could this be applied?  Otherwise e.g. DOS applications ESC actions
> > are very slugguish and thus look bogus in the ncurses UI.
> 
> Somehow slipped through and not in my qemu-devel folder any more.
> Can you resend?

I have bounced it, (its "Date:" is 22 Jun 2016).

Samuel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
  2016-10-15 17:24   ` Samuel Thibault
@ 2016-10-26 12:51     ` Gerd Hoffmann
  2016-10-26 15:20       ` Samuel Thibault
  0 siblings, 1 reply; 12+ messages in thread
From: Gerd Hoffmann @ 2016-10-26 12:51 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: Peter Maydell, QEMU Developers

On Sa, 2016-10-15 at 19:24 +0200, Samuel Thibault wrote:
> Hello,
> 
> Peter Maydell, on Wed 22 Jun 2016 21:49:04 +0100, wrote:
> > On 22 June 2016 at 16:44, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> > > By default, curses will only report single ESC key event after 1s delay,
> > > since ESC is also used for keypad escape sequences. This however makes users
> > > believe that ESC is not working. Reducing to 0.2s provides good enough user
> > > experience, while still allowing 200ms for keypad sequences to get in, which
> > > should be more than enough.
> > 
> > That the default delay is this massive seems like a bug in curses,
> > but I don't suppose it's likely to be changed at this point :-(
> 
> So, could this be applied?  Otherwise e.g. DOS applications ESC actions
> are very slugguish and thus look bogus in the ncurses UI.

Somehow slipped through and not in my qemu-devel folder any more.
Can you resend?

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
  2016-06-22 20:49 ` Peter Maydell
  2016-06-22 21:06   ` Samuel Thibault
@ 2016-10-15 17:24   ` Samuel Thibault
  2016-10-26 12:51     ` Gerd Hoffmann
  1 sibling, 1 reply; 12+ messages in thread
From: Samuel Thibault @ 2016-10-15 17:24 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Gerd Hoffmann

Hello,

Peter Maydell, on Wed 22 Jun 2016 21:49:04 +0100, wrote:
> On 22 June 2016 at 16:44, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> > By default, curses will only report single ESC key event after 1s delay,
> > since ESC is also used for keypad escape sequences. This however makes users
> > believe that ESC is not working. Reducing to 0.2s provides good enough user
> > experience, while still allowing 200ms for keypad sequences to get in, which
> > should be more than enough.
> 
> That the default delay is this massive seems like a bug in curses,
> but I don't suppose it's likely to be changed at this point :-(

So, could this be applied?  Otherwise e.g. DOS applications ESC actions
are very slugguish and thus look bogus in the ncurses UI.

Samuel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
  2016-06-22 21:06   ` Samuel Thibault
@ 2016-06-22 21:11     ` Peter Maydell
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Maydell @ 2016-06-22 21:11 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: QEMU Developers, Gerd Hoffmann

On 22 June 2016 at 22:06, Samuel Thibault <samuel.thibault@gnu.org> wrote:
> Peter Maydell, on Wed 22 Jun 2016 21:49:04 +0100, wrote:
>> On 22 June 2016 at 16:44, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
>> > By default, curses will only report single ESC key event after 1s delay,
>> > since ESC is also used for keypad escape sequences. This however makes users
>> > believe that ESC is not working. Reducing to 0.2s provides good enough user
>> > experience, while still allowing 200ms for keypad sequences to get in, which
>> > should be more than enough.
>>
>> That the default delay is this massive seems like a bug in curses,
>
> I guess it's a "feature" due to old sluggish terminals.

Even the old mechanical terminals like the ASR33 could do
at least five or six characters a second :-)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
  2016-06-22 20:49 ` Peter Maydell
@ 2016-06-22 21:06   ` Samuel Thibault
  2016-06-22 21:11     ` Peter Maydell
  2016-10-15 17:24   ` Samuel Thibault
  1 sibling, 1 reply; 12+ messages in thread
From: Samuel Thibault @ 2016-06-22 21:06 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Gerd Hoffmann

Peter Maydell, on Wed 22 Jun 2016 21:49:04 +0100, wrote:
> On 22 June 2016 at 16:44, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> > By default, curses will only report single ESC key event after 1s delay,
> > since ESC is also used for keypad escape sequences. This however makes users
> > believe that ESC is not working. Reducing to 0.2s provides good enough user
> > experience, while still allowing 200ms for keypad sequences to get in, which
> > should be more than enough.
> 
> That the default delay is this massive seems like a bug in curses,

I guess it's a "feature" due to old sluggish terminals.

Samuel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
  2016-06-22 15:44 Samuel Thibault
@ 2016-06-22 20:49 ` Peter Maydell
  2016-06-22 21:06   ` Samuel Thibault
  2016-10-15 17:24   ` Samuel Thibault
  0 siblings, 2 replies; 12+ messages in thread
From: Peter Maydell @ 2016-06-22 20:49 UTC (permalink / raw)
  To: Samuel Thibault; +Cc: QEMU Developers, Gerd Hoffmann

On 22 June 2016 at 16:44, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
> By default, curses will only report single ESC key event after 1s delay,
> since ESC is also used for keypad escape sequences. This however makes users
> believe that ESC is not working. Reducing to 0.2s provides good enough user
> experience, while still allowing 200ms for keypad sequences to get in, which
> should be more than enough.

That the default delay is this massive seems like a bug in curses,
but I don't suppose it's likely to be changed at this point :-(

-- PMM

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s
@ 2016-06-22 15:44 Samuel Thibault
  2016-06-22 20:49 ` Peter Maydell
  0 siblings, 1 reply; 12+ messages in thread
From: Samuel Thibault @ 2016-06-22 15:44 UTC (permalink / raw)
  To: qemu-devel, kraxel; +Cc: Samuel Thibault

By default, curses will only report single ESC key event after 1s delay,
since ESC is also used for keypad escape sequences. This however makes users
believe that ESC is not working. Reducing to 0.2s provides good enough user
experience, while still allowing 200ms for keypad sequences to get in, which
should be more than enough.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 ui/curses.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ui/curses.c b/ui/curses.c
index b475589..49d3ce6 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -222,7 +222,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
         keycode = curses2keycode[chr];
         keycode_alt = 0;
 
-        /* alt key */
+        /* alt or esc key */
         if (keycode == 1) {
             nextchr = getch();
 
@@ -349,6 +349,7 @@ static void curses_setup(void)
     initscr(); noecho(); intrflush(stdscr, FALSE);
     nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
     start_color(); raw(); scrollok(stdscr, FALSE);
+    set_escdelay(200);
 
     /* Make color pair to match color format (3bits bg:3bits fg) */
     for (i = 0; i < 64; i++) {
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-03-03 17:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-30 11:38 [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s Samuel Thibault
2016-10-30 11:46 ` [Qemu-devel] [PATCH] curses: support wide input Samuel Thibault
  -- strict thread matches above, loose matches on Subject: below --
2019-03-03  6:14 [Qemu-devel] [PATCH] Reduce curses escdelay from 1s to 0.2s Samuel Thibault
2019-03-03 17:11 ` Warner Losh
2019-03-03 17:26   ` Samuel Thibault
2016-06-22 15:44 Samuel Thibault
2016-06-22 20:49 ` Peter Maydell
2016-06-22 21:06   ` Samuel Thibault
2016-06-22 21:11     ` Peter Maydell
2016-10-15 17:24   ` Samuel Thibault
2016-10-26 12:51     ` Gerd Hoffmann
2016-10-26 15:20       ` Samuel Thibault

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.