From f7e9ccc7666c6d17c5aad93c69dd737244afe093 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sun, 24 May 2020 14:04:58 +0100 Subject: [PATCH 1/2] Added F11 and F12 keys #220. Changed keyDownHandler to before keyHandler. --- Terminal.Gui/Drivers/CursesDriver.cs | 2 ++ Terminal.Gui/Drivers/WindowsDriver.cs | 4 ++-- Terminal.Gui/Event.cs | 8 ++++++++ Terminal.Gui/MonoCurses/constants.cs | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Drivers/CursesDriver.cs b/Terminal.Gui/Drivers/CursesDriver.cs index 2e8e7059a..af5819ff2 100644 --- a/Terminal.Gui/Drivers/CursesDriver.cs +++ b/Terminal.Gui/Drivers/CursesDriver.cs @@ -136,6 +136,8 @@ namespace Terminal.Gui { case Curses.KeyF8: return Key.F8; case Curses.KeyF9: return Key.F9; case Curses.KeyF10: return Key.F10; + case Curses.KeyF11: return Key.F11; + case Curses.KeyF12: return Key.F12; case Curses.KeyUp: return Key.CursorUp; case Curses.KeyDown: return Key.CursorDown; case Curses.KeyLeft: return Key.CursorLeft; diff --git a/Terminal.Gui/Drivers/WindowsDriver.cs b/Terminal.Gui/Drivers/WindowsDriver.cs index ea71233ac..439f0fea3 100644 --- a/Terminal.Gui/Drivers/WindowsDriver.cs +++ b/Terminal.Gui/Drivers/WindowsDriver.cs @@ -685,8 +685,8 @@ namespace Terminal.Gui { } else { if (inputEvent.KeyEvent.bKeyDown) { // Key Down - Fire KeyDown Event and KeyStroke (ProcessKey) Event - keyHandler (new KeyEvent (map)); keyDownHandler (new KeyEvent (map)); + keyHandler (new KeyEvent (map)); } else { keyUpHandler (new KeyEvent (map)); } @@ -1016,7 +1016,7 @@ namespace Terminal.Gui { return (Key)((uint)keyInfo.KeyChar); } - if (key >= ConsoleKey.F1 && key <= ConsoleKey.F10) { + if (key >= ConsoleKey.F1 && key <= ConsoleKey.F12) { var delta = key - ConsoleKey.F1; return (Key)((int)Key.F1 + delta); diff --git a/Terminal.Gui/Event.cs b/Terminal.Gui/Event.cs index d06897675..3ef750738 100644 --- a/Terminal.Gui/Event.cs +++ b/Terminal.Gui/Event.cs @@ -272,6 +272,14 @@ namespace Terminal.Gui { /// F10, /// + /// F11 key. + /// + F11, + /// + /// F12 key. + /// + F12, + /// /// The key code for the user pressing the tab key (forwards tab key). /// Tab, diff --git a/Terminal.Gui/MonoCurses/constants.cs b/Terminal.Gui/MonoCurses/constants.cs index 8eed47967..15d6163c9 100644 --- a/Terminal.Gui/MonoCurses/constants.cs +++ b/Terminal.Gui/MonoCurses/constants.cs @@ -112,6 +112,8 @@ namespace Unix.Terminal { public const int KeyF8 = unchecked((int)0x110); public const int KeyF9 = unchecked((int)0x111); public const int KeyF10 = unchecked((int)0x112); + public const int KeyF11 = unchecked((int)0x113); + public const int KeyF12 = unchecked((int)0x114); public const int KeyResize = unchecked((int)0x19a); public const int ShiftKeyUp = unchecked((int)0x151); public const int ShiftKeyDown = unchecked((int)0x150); From f1c6218ad6642d4abde0d1c26affa569e1b4f3f2 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sun, 24 May 2020 16:00:52 +0100 Subject: [PATCH 2/2] Added a Key.Tab to Unix. Fixes https://github.com/migueldeicaza/gui.cs/issues/531#issuecomment-633238032 --- Terminal.Gui/Drivers/CursesDriver.cs | 9 ++++++++- Terminal.Gui/MonoCurses/constants.cs | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Terminal.Gui/Drivers/CursesDriver.cs b/Terminal.Gui/Drivers/CursesDriver.cs index af5819ff2..95c78cfd0 100644 --- a/Terminal.Gui/Drivers/CursesDriver.cs +++ b/Terminal.Gui/Drivers/CursesDriver.cs @@ -148,6 +148,7 @@ namespace Terminal.Gui { case Curses.KeyPPage: return Key.PageUp; case Curses.KeyDeleteChar: return Key.DeleteChar; case Curses.KeyInsertChar: return Key.InsertChar; + case Curses.KeyTab: return Key.Tab; case Curses.KeyBackTab: return Key.BackTab; case Curses.KeyBackspace: return Key.Backspace; case Curses.ShiftKeyUp: return Key.CursorUp | Key.ShiftMask; @@ -420,12 +421,18 @@ namespace Terminal.Gui { } else { keyHandler (new KeyEvent (Key.Esc)); } + } else if (wch == Curses.KeyTab) { + keyHandler (new KeyEvent (MapCursesKey (wch))); } else { keyHandler (new KeyEvent ((Key)wch)); } // Cause OnKeyUp and OnKeyPressed. Note that the special handling for ESC above // will not impact KeyUp. - keyUpHandler (new KeyEvent ((Key)wch)); + if (wch == Curses.KeyTab) { + keyUpHandler (new KeyEvent (MapCursesKey (wch))); + } else { + keyUpHandler (new KeyEvent ((Key)wch)); + } } Action mouseHandler; diff --git a/Terminal.Gui/MonoCurses/constants.cs b/Terminal.Gui/MonoCurses/constants.cs index 15d6163c9..082db0d1c 100644 --- a/Terminal.Gui/MonoCurses/constants.cs +++ b/Terminal.Gui/MonoCurses/constants.cs @@ -101,6 +101,7 @@ namespace Unix.Terminal { public const int KeyEnd = unchecked((int)0x168); public const int KeyDeleteChar = unchecked((int)0x14a); public const int KeyInsertChar = unchecked((int)0x14b); + public const int KeyTab = unchecked((int)0x009); public const int KeyBackTab = unchecked((int)0x161); public const int KeyF1 = unchecked((int)0x109); public const int KeyF2 = unchecked((int)0x10a);