magiblot / turbo

An experimental text editor based on Scintilla and Turbo Vision.
Other
466 stars 36 forks source link

consider switching from Alt-X to Ctrl-X as exit hotkey #58

Open unxed opened 1 year ago

unxed commented 1 year ago

If you are using more then one keyboard layout, to exit turbo you should:

  1. Look what keyboard layout is currently selected
  2. Switch to Latin layout if non-Latin is selected
  3. Press Alt-X

Too complicated path for the most frequently used hot key.

But Ctrl key combinations are working in any keyboard layout (both in GNOME Terminal and in far2l tty extensions mode). So maybe it's a good idea to switch to Ctrl-X as exit key combination? Also all other character-based hotkeys are already using Ctrl, so it would be consistent to use Ctrl for exit hot key also.

If Alt-X is needed for compatibility with old good Turbo Vision, both combinations may be enabled at the same time.

We may also just use Esc as intuitive exit hot key because it is not used currently in plain edition mode.

unxed commented 1 year ago

Currently I am using this hack to be able to open menu on pressing something like Alt+F in non-Latin keyboard layouts. Not ideal, but you can use arrow keys to navigate after it at least. And at least Alt+non-latin-letter stops putting chars in editor after it.

diff --git a/source/platform/far2l.cpp b/source/platform/far2l.cpp
--- a/source/platform/far2l.cpp
+++ b/source/platform/far2l.cpp
@@ -78,6 +78,13 @@ ParseResult parseFar2lInput(GetChBuf &buf, TEvent &ev, InputState &state) noexce
             memcpy(&kev.dwControlKeyState, &out[6],  4);
             memcpy(&kev.uChar.UnicodeChar, &out[10], 4);

+            if ((kev.dwControlKeyState == 2) && (kev.uChar.UnicodeChar > 255)) {
+                // simulate "open menu" hotkey
+                // to get into menu then trying to use menu hotkey on non-latin kb layouts
+                kev.dwControlKeyState = 0;
+                kev.wVirtualKeyCode = VK_F12;
+            }
+
             if (uint16_t keyCode = virtualKeyCodeToKeyCode[kev.wVirtualKeyCode])
             {
                 kev.wVirtualScanCode = keyCode >> 8;
magiblot commented 1 year ago

Hi @unxed!

You are right, I hadn't considered this case.

Of course, Ctrl+X shall remain assigned to Cut. The whole point of Turbo is to make it user-friendly for people used to GUI editors. Taking this into account, the shortcut for Close should then be Ctrl+Q. We will have to find a new shortcut for Toggle Comment, though, which is currently assigned to Ctrl+Q.

unxed commented 1 year ago

Also, what about switching from F12 to F9 as menu activation hot key? It's used by Norton Commander, Midnight Commander, Far Manager. Quite popular programs, so users do not have to relearn.

unxed commented 1 year ago

Another idea: pressing Ctrl+W with no open editor windows may mean "exit turbo".

magiblot commented 1 year ago

I have added Ctrl+Q as a shortcut for Exit (Alt+X is still valid) and Toggle Comment is now assigned to Ctrl+E (like Geany). In addition, Toggle Comment can now also be triggered by Ctrl+_, which in most terminal emulators is mapped to Ctrl+/.

I might consider the other suggestions in the future.

unxed commented 1 year ago

About Alt+char hot keys not working in non-Latin layouts: found possible solution at least then working in far2l extensions mode. Needs to be implemented on both far2l and turbo sides. See https://github.com/elfmz/far2l/issues/1562

JorisHansMeijer commented 1 year ago

Some related suggestion: Many terminal applications use F10 as exit (example htop, midnight commander). I would like to propose using F10 as exit for turbo as well.