Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Escape behavior with "Single Press" off #36

Open
proski opened this issue Jan 26, 2023 · 1 comment
Open

Inconsistent Escape behavior with "Single Press" off #36

proski opened this issue Jan 26, 2023 · 1 comment

Comments

@proski
Copy link

proski commented Jan 26, 2023

The behavior of Escape is incorrect when the "Single Press" option in turned off. It's different from Linux, making it hard to have consistent muscle memory.

Here's what the manual page says:

Esc key mode.

By default, Midnight Commander treats the Esc key as a key prefix. Therefore, you should press Esc code twice to exit a dialog. But there is a possibility to use a single press of Esc key for that action.

Single press. By default this option is disabled. If you'll enable it, the Esc key will act as a prefix key for set up time interval (see Timeout option below), and if no extra keys have arrived, then the Esc key is interpreted as a cancel key (Esc Esc).

Timeout. This options is used to setup the time interval (in microseconds) for single press of Esc key. By default, this interval is one second (1000000 microseconds). Also the timeout can be set via KEYBOARD_KEY_TIMEOUT_US environment variable (also in microseconds), which has higher priority than Timeout option value.

So my expectation is that when "Single Press" is off, the behavior is the same as with "Single Press" on and infinitely large timeout. That's what I see on Linux.

But the actual behavior on Windows is different. When "Single Press" is off, a single Escape is treated as Escape immediately. It as if "Single Press" is on and the timeout is 0. For instance, I cannot use Escape followed by 0 to exit MC no matter how fast I press one key after the other.

If it's tricky to implement the infinite timeout, please use a very large timeout, e.g. 1 billion microseconds (1000 seconds).

I'm OK with changing the default to "Single Press" on with a very short timeout (e.g. 1 millisecond) so that Windows-only users don't have to wait or press Escape twice.

It's confusing to have settings do something different from what they should do.

@adamyg
Copy link
Owner

adamyg commented Apr 2, 2024

Current logic, on ESCAPE:

  • off; return ESCAPE.

  • on (aka old_esc_mode);

>    timeout = INFINITE
>    wait for next key (timeout)
>        if key-down:
>            if escape-special;
>               consume key-down
>               return escaped
>            if Unicode
>              return escape
>            consume key-down
>        if key-up:
>            if (key == ESCAPE)
>               timeout =  KEYBOARD_KEY_TIMEOUT_US (default 1 second)

As such access to specials can be achieved using either

  1. [ESC-down] + [special-down];
  2. [ESC-press] + [special-down], within KEYBOARD_KEY_TIMEOUT_US timeout.

KEYBOARD_KEY_TIMEOUT_US:
This options is used to setup the time interval (in microseconds) for single press of Esc key. By default, this interval is one second (1000000 microseconds). Also the timeout can be set via KEYBOARD_KEY_TIMEOUT_US environment variable (also in microseconds), which has higher priority than Timeout option value.

Considering

  • allowing [ESC-down] + [special-down] is either mode; ESC report delayed until next up/down event.
  • additional compat ESC mode; emulating terminal ESC semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants