2
0
Эх сурвалжийг харах

Fixes #1969. ESC on CursesDriver take to long to being processed. (#1970)

* Fixes #1969. ESC on CursesDriver take to long to being processed.

* Increasing set_escdelay and timeout values to ensure precessing any more long delay.
BDisp 2 жил өмнө
parent
commit
e767ae14eb

+ 2 - 1
Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

@@ -663,7 +663,7 @@ namespace Terminal.Gui {
 
 			// 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);
+				Curses.timeout (10);
 
 				code = Curses.get_wch (out int wch2);
 
@@ -820,6 +820,7 @@ namespace Terminal.Gui {
 				//Console.Out.Flush ();
 
 				window = Curses.initscr ();
+				Curses.set_escdelay (10);
 			} catch (Exception e) {
 				throw new Exception ($"Curses failed to initialize, the exception is: {e.Message}");
 			}

+ 4 - 0
Terminal.Gui/ConsoleDrivers/CursesDriver/binding.cs

@@ -330,6 +330,7 @@ namespace Unix.Terminal {
 		static public int reset_shell_mode () => methods.reset_shell_mode ();
 		static public int savetty () => methods.savetty ();
 		static public int resetty () => methods.resetty ();
+		static public int set_escdelay (int size) => methods.set_escdelay (size);
 	}
 
 #pragma warning disable RCS1102 // Make class static.
@@ -405,6 +406,7 @@ namespace Unix.Terminal {
 		public delegate int reset_shell_mode ();
 		public delegate int savetty ();
 		public delegate int resetty ();
+		public delegate int set_escdelay (int size);
 	}
 
 	internal class NativeMethods {
@@ -478,6 +480,7 @@ namespace Unix.Terminal {
 		public readonly Delegates.reset_shell_mode reset_shell_mode;
 		public readonly Delegates.savetty savetty;
 		public readonly Delegates.resetty resetty;
+		public readonly Delegates.set_escdelay set_escdelay;
 		public UnmanagedLibrary UnmanagedLibrary;
 
 		public NativeMethods (UnmanagedLibrary lib)
@@ -553,6 +556,7 @@ namespace Unix.Terminal {
 			reset_shell_mode = lib.GetNativeMethodDelegate<Delegates.reset_shell_mode> ("reset_shell_mode");
 			savetty = lib.GetNativeMethodDelegate<Delegates.savetty> ("savetty");
 			resetty = lib.GetNativeMethodDelegate<Delegates.resetty> ("resetty");
+			set_escdelay = lib.GetNativeMethodDelegate<Delegates.set_escdelay> ("set_escdelay");
 		}
 	}
 #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member