From c4588b3a974468f19b5f9bb0b7ae6e8589714773 Mon Sep 17 00:00:00 2001 From: BDisp Date: Mon, 25 May 2020 22:51:34 +0100 Subject: [PATCH] Added keyDownHandler to Unix --- Terminal.Gui/Drivers/CursesDriver.cs | 6 ++++-- Terminal.Gui/MonoCurses/mainloop.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Terminal.Gui/Drivers/CursesDriver.cs b/Terminal.Gui/Drivers/CursesDriver.cs index 1d2fed102..830599e51 100644 --- a/Terminal.Gui/Drivers/CursesDriver.cs +++ b/Terminal.Gui/Drivers/CursesDriver.cs @@ -369,7 +369,7 @@ namespace Terminal.Gui { }; } - void ProcessInput (Action keyHandler, Action keyUpHandler, Action mouseHandler) + void ProcessInput (Action keyHandler, Action keyDownHandler, Action keyUpHandler, Action mouseHandler) { int wch; var code = Curses.get_wch (out wch); @@ -422,8 +422,10 @@ namespace Terminal.Gui { keyHandler (new KeyEvent (Key.Esc)); } } else if (wch == Curses.KeyTab) { + keyDownHandler (new KeyEvent (MapCursesKey (wch))); keyHandler (new KeyEvent (MapCursesKey (wch))); } else { + keyDownHandler (new KeyEvent ((Key)wch)); keyHandler (new KeyEvent ((Key)wch)); } // Cause OnKeyUp and OnKeyPressed. Note that the special handling for ESC above @@ -446,7 +448,7 @@ namespace Terminal.Gui { this.mainLoop = mainLoop; (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; }); diff --git a/Terminal.Gui/MonoCurses/mainloop.cs b/Terminal.Gui/MonoCurses/mainloop.cs index 2edc819f7..4bc95fba5 100644 --- a/Terminal.Gui/MonoCurses/mainloop.cs +++ b/Terminal.Gui/MonoCurses/mainloop.cs @@ -208,7 +208,7 @@ namespace Mono.Terminal { while (true) { n = poll (pollmap, (uint)pollmap.Length, 0); - if (pollmap != null) { + if (n > 0) { break; } if (mainLoop.idleHandlers.Count > 0 || CkeckTimeout (wait, ref pollTimeout)) { @@ -472,7 +472,7 @@ namespace Mono.Terminal { running = false; driver.Wakeup (); } - + /// /// Determines whether there are pending events to be processed. ///