diff --git a/src/Consolonia.GuiCS/binding.cs b/src/Consolonia.GuiCS/binding.cs index 043a8206..c26cb218 100644 --- a/src/Consolonia.GuiCS/binding.cs +++ b/src/Consolonia.GuiCS/binding.cs @@ -98,27 +98,27 @@ static void FindNCurses () cols_ptr = get_ptr ("COLS"); } - static public Window initscr () - { - setlocale (LC_ALL, ""); - FindNCurses (); - - // Prevents the terminal from being locked after exiting. - reset_shell_mode (); - - main_window = new Window (methods.initscr ()); - try { - console_sharp_get_dims (out lines, out cols); - } catch (DllNotFoundException) { - endwin (); - Console.Error.WriteLine ("Unable to find the @MONO_CURSES@ native library\n" + - "this is different than the managed mono-curses.dll\n\n" + - "Typically you need to install to a LD_LIBRARY_PATH directory\n" + - "or DYLD_LIBRARY_PATH directory or run /sbin/ldconfig"); - Environment.Exit (1); + static public Window initscr () + { + setlocale (LC_ALL, ""); + FindNCurses (); + + // Prevents the terminal from being locked after exiting. + reset_shell_mode (); + + main_window = new Window (methods.initscr ()); + try { + console_sharp_get_dims (out lines, out cols); + } catch (DllNotFoundException) { + endwin (); + Console.Error.WriteLine ("Unable to find the @MONO_CURSES@ native library\n" + + "this is different than the managed mono-curses.dll\n\n" + + "Typically you need to install to a LD_LIBRARY_PATH directory\n" + + "or DYLD_LIBRARY_PATH directory or run /sbin/ldconfig"); + Environment.Exit (1); + } + return main_window; } - return main_window; - } public static int Lines { get { diff --git a/src/Consolonia.PlatformSupport/CursesConsole.cs b/src/Consolonia.PlatformSupport/CursesConsole.cs index d305f2c8..bffc980f 100644 --- a/src/Consolonia.PlatformSupport/CursesConsole.cs +++ b/src/Consolonia.PlatformSupport/CursesConsole.cs @@ -65,7 +65,18 @@ private static readonly FlagTranslator (Key.Space, ConsoleKey.Spacebar), (Key.Tab, ConsoleKey.Tab), // Proposed by ChatGPT, I've found supporting source: https://devblogs.microsoft.com/dotnet/console-readkey-improvements-in-net-7/ - (Key.Unknown, ConsoleKey.NoName) + (Key.Unknown, ConsoleKey.NoName), + ((Key)46, ConsoleKey.OemPeriod), + // rest is by chatGPT + ((Key)44, ConsoleKey.OemComma), + ((Key)59, ConsoleKey.Oem1), + ((Key)47, ConsoleKey.Oem2), // Oem2 usually represents the '/' key + ((Key)92, ConsoleKey.Oem5), // Oem5 usually represents the '\\' key + ((Key)61, ConsoleKey.OemPlus), // OemPlus might be used for both '=' and '+' + ((Key)45, ConsoleKey.OemMinus), + ((Key)91, ConsoleKey.Oem4), // '[' key + ((Key)93, ConsoleKey.Oem6), // ']' key + ((Key)39, ConsoleKey.Oem7) // '\'' key }); private static readonly FlagTranslator @@ -389,6 +400,10 @@ private void RaiseKeyPressInternal(Key key) char character; ConsoleKey consoleKey = KeyFlagTranslator.Translate(key & ~Key.CtrlMask & ~Key.ShiftMask & ~Key.AltMask, true); + + if (consoleKey == ConsoleKey.NoName) + return; + if (consoleKey == default) { bool _ = Enum.TryParse(key.ToString(), true, out consoleKey);