Browse Source

Added keyDownHandler to Unix

BDisp 5 years ago
parent
commit
c4588b3a97
2 changed files with 6 additions and 4 deletions
  1. 4 2
      Terminal.Gui/Drivers/CursesDriver.cs
  2. 2 2
      Terminal.Gui/MonoCurses/mainloop.cs

+ 4 - 2
Terminal.Gui/Drivers/CursesDriver.cs

@@ -369,7 +369,7 @@ namespace Terminal.Gui {
 			};
 			};
 		}
 		}
 
 
-		void ProcessInput (Action<KeyEvent> keyHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler)
+		void ProcessInput (Action<KeyEvent> keyHandler, Action<KeyEvent> keyDownHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler)
 		{
 		{
 			int wch;
 			int wch;
 			var code = Curses.get_wch (out wch);
 			var code = Curses.get_wch (out wch);
@@ -422,8 +422,10 @@ namespace Terminal.Gui {
 					keyHandler (new KeyEvent (Key.Esc));
 					keyHandler (new KeyEvent (Key.Esc));
 				}
 				}
 			} else if (wch == Curses.KeyTab) {
 			} else if (wch == Curses.KeyTab) {
+				keyDownHandler (new KeyEvent (MapCursesKey (wch)));
 				keyHandler (new KeyEvent (MapCursesKey (wch)));
 				keyHandler (new KeyEvent (MapCursesKey (wch)));
 			} else {
 			} else {
+				keyDownHandler (new KeyEvent ((Key)wch));
 				keyHandler (new KeyEvent ((Key)wch));
 				keyHandler (new KeyEvent ((Key)wch));
 			}
 			}
 			// Cause OnKeyUp and OnKeyPressed. Note that the special handling for ESC above 
 			// Cause OnKeyUp and OnKeyPressed. Note that the special handling for ESC above 
@@ -446,7 +448,7 @@ namespace Terminal.Gui {
 			this.mainLoop = mainLoop;
 			this.mainLoop = mainLoop;
 
 
 			(mainLoop.Driver as Mono.Terminal.UnixMainLoop).AddWatch (0, Mono.Terminal.UnixMainLoop.Condition.PollIn, x => {
 			(mainLoop.Driver as Mono.Terminal.UnixMainLoop).AddWatch (0, Mono.Terminal.UnixMainLoop.Condition.PollIn, x => {
-				ProcessInput (keyHandler, keyUpHandler, mouseHandler);
+				ProcessInput (keyHandler, keyDownHandler, keyUpHandler, mouseHandler);
 				return true;
 				return true;
 			});
 			});
 
 

+ 2 - 2
Terminal.Gui/MonoCurses/mainloop.cs

@@ -208,7 +208,7 @@ namespace Mono.Terminal {
 
 
 			while (true) {
 			while (true) {
 				n = poll (pollmap, (uint)pollmap.Length, 0);
 				n = poll (pollmap, (uint)pollmap.Length, 0);
-				if (pollmap != null) {
+				if (n > 0) {
 					break;
 					break;
 				}
 				}
 				if (mainLoop.idleHandlers.Count > 0 || CkeckTimeout (wait, ref pollTimeout)) {
 				if (mainLoop.idleHandlers.Count > 0 || CkeckTimeout (wait, ref pollTimeout)) {
@@ -472,7 +472,7 @@ namespace Mono.Terminal {
 			running = false;
 			running = false;
 			driver.Wakeup ();
 			driver.Wakeup ();
 		}
 		}
-		
+
 		/// <summary>
 		/// <summary>
 		///   Determines whether there are pending events to be processed.
 		///   Determines whether there are pending events to be processed.
 		/// </summary>
 		/// </summary>