Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Implement issue #157. #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/modes/command/client/commands/hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const openLinkInBackgroundTab = background('findHints', {
filter: '*',
activate: 'openLinkInBackgroundTab'
})
export const openMultipleLinksInBackgroundTabs = background('findHints', {
filter: '*',
activate: 'openMultipleLinksInBackgroundTabs'
})
export const openLinkInForegroundTab = background('findHints', {
filter: '*',
activate: 'openLinkInForegroundTab'
Expand Down
19 changes: 17 additions & 2 deletions src/modes/hints/client/activate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { msg } from 'mosi/client'
import { mouseEvent } from 'lib/dom'
import { isMac } from 'lib/keys'
import { hideHints } from './HintRenderer'
import { hideVideoControls } from './video'

let activator
export function configureActivate (_activator = 'openLink') {
Expand All @@ -10,8 +12,8 @@ export function configureActivate (_activator = 'openLink') {
/**
* Calls the appropriate activation function on the target hintable element.
* Returns the next mode
* @param {KeyboardEvent} event - an object that representing a keyboard event
* @param {HTMLElement} target
* @param {KeyboardEvent} event - an object representing a keyboard event
* @param {HTMLElement} target
* @returns {string}
*/
export function activate (event, target) {
Expand Down Expand Up @@ -46,6 +48,19 @@ const activators = {
target.focus()
return 'Reset'
},
openMultipleLinksInBackgroundTabs: (event, target) => {
mouseEvent(target, 'click', { ctrlKey: !isMac, metaKey: isMac })
if (SAKA_PLATFORM === 'firefox') {
backgroundOpenLink('openLinkInBackgroundTab', target)
}
hideHints()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to hide the current hint before re-showing them all because the element under the current hint will be considered "invisible" and a hint won't be rendered for it.

hideVideoControls()
msg(1, 'findHints', {
filter: '*',
activate: 'openMultipleLinksInBackgroundTabs'
})
return 'Same'
},
openLinkInForegroundTab: (event, target) => {
mouseEvent(target, 'click', {
ctrlKey: !isMac,
Expand Down
6 changes: 6 additions & 0 deletions src/options/Keybindings/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
"key": "openLinkInBackgroundTab",
"default": []
},
{
"type": "keybinding",
"label": "Open Multiple Links in Background Tabs",
"key": "openMultipleLinksInBackgroundTabs",
"default": []
},
{
"type": "keybinding",
"label": "Open Link in Foreground Tab",
Expand Down
11 changes: 11 additions & 0 deletions src/options/Keybindings/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"openLinkInBackgroundTab": [
[{ "code": "KeyF", "key": "f" }, { "code": "KeyB", "key": "b" }]
],
"openMultipleLinksInBackgroundTabs": [
[{ "code": "KeyF", "key": "f" }, { "code": "KeyM", "key": "m" }]
],
"openLinkInForegroundTab": [
[
{ "code": "KeyF", "key": "f" },
Expand Down Expand Up @@ -216,6 +219,12 @@
"toggleSaka": [[{ "code": "KeyL", "key": "l" }]],
"openLink": [[{ "code": "KeyF", "key": "f" }]],
"openLinkInBackgroundTab": [[{ "code": "KeyA", "key": "a" }]],
"openMultipleLinksInBackgroundTabs": [
[
{ "code": "KeyF", "key": "F", "shiftKey": true },
{ "code": "KeyM", "key": "m" }
]
],
"openLinkInForegroundTab": [
[{ "code": "KeyA", "key": "A", "shiftKey": true }]
],
Expand Down Expand Up @@ -402,6 +411,7 @@
"openLinkInBackgroundTab": [
[{ "code": "KeyF", "key": "F", "shiftKey": true }]
],
"openMultipleLinksInBackgroundTabs": [],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of a shortcut in the form of ALT+something but, at least in linux, they open the browser's menus like File, Edit, and stuff like that. Let me know if you want some specific defaults.

"openLinkInForegroundTab": [
[
{ "code": "KeyF", "key": "ƒ", "altKey": true },
Expand Down Expand Up @@ -541,6 +551,7 @@
"openLinkInBackgroundTab": [
[{ "code": "KeyF", "key": "F", "shiftKey": true }]
],
"openMultipleLinksInBackgroundTabs": [],
"openLinkInForegroundTab": [],
"openLinkInNewWindow": [],
"openLinkInIncognitoWindow": [],
Expand Down