wshanks / tbkeys

Custom keybindings for Thunderbird
Other
190 stars 13 forks source link

vim visual line mode-like selection navigation #162

Open LaptopDev opened 10 months ago

LaptopDev commented 10 months ago

There are two modes of selection that are relevant to this. One is a hover selection that can be done on a single email at a time, which enables you to move through your inbox over individual e-mails. The other mode of selection is toggling a highlight so that it is selected for some type of next action like deletion, marking, or tagging.

Can the shift key be configured so that when I use j and k to move through my inbox I create a selection over multiple e-mails?

morat523035 commented 10 months ago

Are you asking to configure something like the select multiple adjacent messages keyboard shortcut?

Select the first message of your intended selection, and then either Shift + Click on the last message of your selection, or hold Shift while using any of the following movement keys to expand your selection: ↓, ↑, Page Down, Page Up, End, or Home.

Thunderbird Keyboard shortcuts (search for adjacent) http://support.mozilla.org/kb/keyboard-shortcuts-thunderbird

How to simulate or synthesize a keypress or a mouse click http://forums.mozillazine.org/viewtopic.php?p=14949538#p14949538

Simulate Shift+ArrowUp key event.

(function () {
  var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false};
  var WIN_VK_UP = 0xe0480026;
  var NATIVE_MODIFIER_SHIFT_LEFT = 0x00000100;
  var modifiers = 0;
  modifiers |= NATIVE_MODIFIER_SHIFT_LEFT;
  window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_UP, modifiers, '', '');
})();

Simulate Shift+ArrowDown key event.

(function () {
  var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false};
  var WIN_VK_DOWN = 0xe0500028;
  var NATIVE_MODIFIER_SHIFT_LEFT = 0x00000100;
  var modifiers = 0;
  modifiers |= NATIVE_MODIFIER_SHIFT_LEFT;
  window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_DOWN, modifiers, '', '');
})();

There may be a cmd_ command that selects an adjacent message in the thread pane, but I don't think so.

window.goDoCommand('cmd_selectAll');

The cmd_selectAll command selects all messages in the thread pane.

LaptopDev commented 10 months ago

I would like to be able to move up and down and keep selections. When I select with my mouse multiple e-mails, or with shift (for adjacent emails), and press the up or down key the selection is removed.

I could emulate a mouse click to select the currently highlighted email, but it wouldn't matter because when I press up or down, it will become unselected.

Are you asking to configure something like the select multiple adjacent messages keyboard shortcut?

Select the first message of your intended selection, and then either Shift + Click on the last message of your selection, or hold Shift while using any of the following movement keys to expand your selection: ↓, ↑, Page Down, Page Up, End, or Home.

Thunderbird Keyboard shortcuts (search for adjacent) http://support.mozilla.org/kb/keyboard-shortcuts-thunderbird

How to simulate or synthesize a keypress or a mouse click http://forums.mozillazine.org/viewtopic.php?p=14949538#p14949538

Simulate Shift+ArrowUp key event.

(function () {
  var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false};
  var WIN_VK_UP = 0xe0480026;
  var NATIVE_MODIFIER_SHIFT_LEFT = 0x00000100;
  var modifiers = 0;
  modifiers |= NATIVE_MODIFIER_SHIFT_LEFT;
  window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_UP, modifiers, '', '');
})();

Simulate Shift+ArrowDown key event.

(function () {
  var KEYBOARD_LAYOUT_EN_US = {name: 'US', Mac: 0, Win: 0x00000409, hasAltGrOnWin: false};
  var WIN_VK_DOWN = 0xe0500028;
  var NATIVE_MODIFIER_SHIFT_LEFT = 0x00000100;
  var modifiers = 0;
  modifiers |= NATIVE_MODIFIER_SHIFT_LEFT;
  window.windowUtils.sendNativeKeyEvent(KEYBOARD_LAYOUT_EN_US, WIN_VK_DOWN, modifiers, '', '');
})();

There may be a cmd_ command that selects an adjacent message in the thread pane, but I don't think so.

window.goDoCommand('cmd_selectAll');

The cmd_selectAll command selects all messages in the thread pane.

morat523035 commented 10 months ago

Here is how to change the focus up or down, but not the selection.

window.gTabmail.currentAbout3Pane.threadTree.currentIndex -= 1;
window.gTabmail.currentAbout3Pane.threadTree.currentIndex += 1;

Reference http://searchfox.org/comm-esr115/search?q=Change+focus&path=tree-view.mjs

The event[accelKeyName] expression is true when the Ctrl key is down on Windows.

Select multiple adjacent messages:

hold Shift while using any of the following movement keys to expand your selection: ↓, ↑, Page Down, Page Up, End, or Home.

Select multiple non-adjacent messages:

hold Ctrl while using any of the movement keys listed below and then pressing Space on each message that you want to add to your selection. The movement keys are ↓, ↑, Page Down, Page Up, End, or Home.

You can't change how the Shift key or Ctrl key works using the tbkey addon.

You can create a Shift+J key binding to change the focus down and keep the selection.

If you want to toggle the selection on the focused message, then use the Ctrl+Space shortcut.

agenbite commented 9 months ago

How would one go about finding the command triggered by Ctrl-Space (toggle message selection), in order to rebind it?

morat523035 commented 9 months ago

@agenbite

How to find the toggle message selection command? Try looking in the source code.

The "Space bar keystroke selection toggling" code is 12 lines down from the "Change focus, but not selection" code.

(function () {
  var currentIndex = window.gTabmail.currentAbout3Pane.threadTree.currentIndex;
  window.gTabmail.currentAbout3Pane.threadTree._toggleSelected(currentIndex);
})();

Reference (link posted above) http://searchfox.org/comm-esr115/search?q=Change+focus&path=tree-view.mjs

Reference http://searchfox.org/comm-esr115/search?q=Space+bar+keystroke&path=tree-view.mjs

The event[accelKeyName] expression is true when the Ctrl key is down on Windows.