Terminal.Gui icon indicating copy to clipboard operation
Terminal.Gui copied to clipboard

In Curses driver, ESC has a built-in 200ms pause, which makes it hard to make ESC responsive

Open tig opened this issue 5 years ago • 11 comments
trafficstars

This is really noticeable in UI Catalog (sync latest to PR) where ESC is used to exit a Scenario.

On Linux (with Curses) it takes 1-2 seconds for the Scenario to close.

I looked at the Unix.MainLoop and Cruses code, but I can't tell why this is.

tig avatar May 17 '20 20:05 tig

I have also detected that. I think the cause is this on CursesDriver.

// Special handling for ESC, we want to try to catch ESC+letter to simulate alt-letter as well as Alt-Fkey
if (wch == 27) {
	Curses.timeout (200);

BDisp avatar May 17 '20 20:05 BDisp

Ahhh..

I've confirmed changing my code to look for Key.F1 works around this. So confirmed.

Updated bug description.

tig avatar May 17 '20 20:05 tig

@migueldeicaza,

On what systems does alt-letter and alt-fkey not work?

I think it's only very esoteric old stuff, right?

IOW, can we just remove this behavior or make it an opt-in option?

tig avatar May 17 '20 20:05 tig

@bdisp asked in #387: "Did you try that removing the timeout in #439 to see if it works without problems?"

Yes, and it removes the delay, but would break the "ESC-F" == "Alt-F" functionality.

tig avatar May 18 '20 18:05 tig

Assigning to @migueldeicaza since I think only he can make the call on whether this functionality is still needed in this day and age.

tig avatar May 19 '20 18:05 tig

I still rely entirely on ESC-letter on Mac, as generally those keyboard have the F keys needing Fn-Key, which is not easy to hit as ESC-letter :-)

migueldeicaza avatar May 20 '20 17:05 migueldeicaza

Man, you're old and rigid.

But, I guess you're probably not alone. I didn't realize folks still had those muscle-memories.

I think we're ok leaving this functionality in then. I already established that using ESC as the way to exit an app/screen can be replaced by CTRL-Q so I think we can just adopt that as the standard.

Right?

tig avatar May 20 '20 18:05 tig

This should not affect anyone on Windows, there I think we should make ESC immediate, as you typically have working F keys that have not been abused.

For Unix, the idiom is to use "ESC ESC" for a quick response.

migueldeicaza avatar May 20 '20 18:05 migueldeicaza

This should not affect anyone on Windows, there I think we should make ESC immediate, as you typically have working F keys that have not been abused.

For Unix, the idiom is to use "ESC ESC" for a quick response.

The problem is WSL. Via it, many people use Unix ON Windows.

If you run a Terminal.Gui app under WSL on Windows and you are not familiar with the "ESC as Control key" idiom, it just seems like hitting ESC is slow.

tig avatar May 20 '20 18:05 tig

+1 to this, or maybe making it configuration option? It took me significant time to figure out why it took so much time on my Mac, and I really believed whole app was slow (but my app wasn't much more than ESC).

So, if there was a way to set Terminal.GUI to stop waiting for ESC I'd call it quite good workaround, that would work for me 100%.

domints avatar Dec 02 '20 21:12 domints

The problem is that it leaves no option for those that use the terminal remotely, or without F keys (most Mac users do not have the F keys around to be used).

A configuration option would just hide the problem for the tester.

What we could do is perhaps have some heuristics, like for example, if we detect that we are running under WSL, not over SSH, we could make the delay shorter.

migueldeicaza avatar Dec 08 '20 03:12 migueldeicaza

@BDisp didn't you recently fix this?

tig avatar Sep 16 '22 18:09 tig

Yes but I think saw some changes on the timeout recently by you.

BDisp avatar Sep 16 '22 18:09 BDisp