rbreaves / kinto

Mac-style shortcut keys for Linux & Windows.
http://kinto.sh
GNU General Public License v2.0
4.25k stars 213 forks source link

`Cmd + Backspace` doesn't delete entire line #754

Open ghost opened 1 year ago

ghost commented 1 year ago

Describe the bug Cmd + Backspace doesn't delete entire line.

Expected behavior Cmd + Backspace should delete entire line, as per https://github.com/rbreaves/kinto/commit/588fe1a0dc48e98c977cc1dfd2727380565e3f21.

Distro: Latest PopOS DE: Gnome Branch: master Commit: latest (e106710)

RedBearAK commented 1 year ago

@doplumi

xprop WM_CLASS _NET_WM_NAME

This shortcut is in the "General" section so it should theoretically work everywhere. But in the current Kinto config the terminals block is below the "General" keymap, and terminals need their own wordwise shortcuts. So if this is about it not working in a terminal app you may need to move the whole "terminals" keymap up so that it comes before the "General" keymap, and insert these lines in the terminals (termStr) keymap to override some of the wordwise shortcuts in the "General" keymap. This issue should be fixed in a future release of Kinto.

define_keymap(re.compile(termStr, re.IGNORECASE),{
    ### wordwise overrides of general GUI block
    K("Alt-Backspace"):         K("Alt-Shift-Backspace"),       # Wordwise delete word left of cursor in terminals
    K("Alt-Delete"):           [K("Esc"),K("d")],               # Wordwise delete word right of cursor in terminals
    K("RC-Backspace"):          K("C-u"),                       # Wordwise delete line left of cursor in terminals
    K("RC-Delete"):             K("C-k"),                       # Wordwise delete line right of cursor in terminals
kennethkeim commented 1 year ago

I'm on the latest PopOS and having this issue (only in vs code). Here's the output for the vscode window:

WM_CLASS(STRING) = "code", "Code"
_NET_WM_NAME(UTF8_STRING) = "Untitled (Workspace) - Visual Studio Code"
RedBearAK commented 1 year ago

@kennethkeim

I'm on the latest PopOS and having this issue (only in vs code).

Having the issue in VSCode in general, or in the embedded terminal pane inside VSCode? It's often difficult to get embedded terminals to work correctly because all the keymapper sees is the class/name of the main window in those situations. So the wordwise mappings for "GUI" apps will be active in VSCode, and if you're trying to use the wordwise shortcuts in the embedded terminal they won't be correct.

As far as I know there is no solution to this other than using a separate (external) terminal, if possible.

kennethkeim commented 1 year ago

That would make sense, but it was just in the text editor. I don't use the embedded terminals in vs code.

RedBearAK commented 1 year ago

@kennethkeim

That would make sense, but it was just in the text editor. I don't use the embedded terminals in vs code.

That is odd.

OK, looks like there is a line in "General" that remaps RC+Backspace to Ctrl+Shift+Backspace for most non-terminal applications, and this is interfering with VSCode, which seems to like Ctrl+Backspace for this "delete line left of cursor" shortcut.

    C("RC-Backspace"):          C("C-Shift-Backspace"),         # Delete Entire Line Left of Cursor

There are some general wordwise shortcuts in the "Codes" specific override keymap, but nothing to fix this particular shortcut. If you find your "Codes" keymap and insert this line (and restart Kinto), it will override the remap above from the "General" block. Unless... if your version of kinto.py has the "Codes" keymap below the "General" block, you'll need to move the entire "Codes" block above the "General" block instead of below it. Or this won't work.

    C("RC-Backspace"):          C("C-Backspace"),                   # Delete Entire Line Left of Cursor

Yeah, looks like the default kinto.py file is still out of the order it should be in. The simplest thing to do is to grab the entire "General GUI" keymap and move it to the very end of the config file. That will make the line above take precedence over the general shortcut while you are in VSCode(s).

The VSCode(s) block starts with this line:

define_keymap(re.compile(codeStr, re.IGNORECASE),{

Tested the fix in VSCode, VSCodium and "Code - OSS". Working for me now.

Let me know if you have trouble making this work.

ian-h-chamberlain commented 1 year ago

I was having this issue in the Firefox URL bar, not sure if it applies to other browsers, but I was able to workaround it with

    K("RC-Backspace"): K("C-u"),    # Delete Entire Line Left of Cursor
    # edit: actually C-k seems like it doesn't work how I thought it did...
    K("RC-Delete"): K("C-k"),    # Delete Entire Line Left of Cursor

Unfortunately, this breaks shortcuts in textareas, since C-u and C-k have other meanings in a non-URL bar context (I think the default C-Shift-Backspace and C-Shift-Delete probably work correctly here). I'd imagine that some Firefox config might be needed to change the shortcut behavior (if there isn't one that works in both places), since as I understand it xkeysnail doesn't have access to that context information.

Edit: Aha! This combo seems to work in both the URL bar and the textarea editors, although it feels slightly hacky to select, then delete text:

    K("RC-Backspace"): [K("Shift-Home"), K("Backspace")], # Delete Entire Line Left of Cursor
    K("RC-Delete"): [K("Shift-End"), K("Delete")],        # Delete Entire Line Right of Cursor
RedBearAK commented 1 year ago

@ian-h-chamberlain

This combo seems to work in both the URL bar and the textarea editors

Nice solution.

feels slightly hacky to select, then delete text

If it works, it works. Would need to be tested in multiple browsers before trying to use it as a general solution.

RedBearAK commented 1 year ago

@ian-h-chamberlain

After some testing, your solution for Firefox wordwise delete to end-of-line or beginning-of-line shortcuts seems like a good candidate for inclusion in the default Kinto config. The Chrome browsers don't seem to have any issue with the existing shortcuts working both in text areas on a page and in the URL bar.

I have a system that is notorious for being weirdly slow to perform macros, but I don't even see it highlighting the text before deletion, unless it's quite a lot of text in the URL bar. Works really well.

I think I'll put together a PR to have it added to the Kinto config.

Edit: https://github.com/rbreaves/kinto/pull/780

kennethkeim commented 1 year ago

@RedBearAK Thanks for the info, I still can't get that to work. I tried your suggestions and restarted but the issue is still there.

kennethkeim commented 1 year ago

@ian-h-chamberlain I added your lines to the general gui section and the vscode section, and it seems to work well in both. Thanks!