hinting: allow hints to open in bg

This commit is contained in:
Colin Caine 2017-11-18 01:51:46 +00:00
parent 17e42588b0
commit 9e75cbed3f
3 changed files with 25 additions and 6 deletions

View file

@ -574,11 +574,12 @@ export async function reset(key: string){
// {{{ HINTMODE
//#background_helper
import {hintPageSimple} from './hinting_background'
import * as hinting from './hinting_background'
//#background
export function hint() {
hintPageSimple()
export function hint(option: string) {
if (option === '-b') hinting.hintPageOpenInBackground()
else hinting.hintPageSimple()
mode('hint')
}

View file

@ -252,9 +252,22 @@ select,
[tabindex]
`
// DEBUGGING
/* hintPage(hintables(), hint=>mouseEvent(hint.target, 'click')) */
/* addEventListener('keydown', pushKey) */
import browserBg from './lib/browser_proxy'
function hintPageOpenInBackground() {
hintPage(hintables(), hint=>{
hint.target.focus()
if (hint.target.href && ! hint.target.href.startsWith('#')) {
browserBg.tabs.create({
active: false,
url: hint.target.href
})
} else {
// This is to mirror vimperator behaviour.
mouseEvent(hint.target, "click")
}
})
}
function hintPageSimple() {
console.log("Hinting!")
@ -277,4 +290,5 @@ addListener('hinting_content', attributeCaller({
selectFocusedHint,
reset,
hintPageSimple,
hintPageOpenInBackground,
}))

View file

@ -16,6 +16,10 @@ export async function hintPageSimple() {
return await messageActiveTab('hinting_content', 'hintPageSimple')
}
export async function hintPageOpenInBackground() {
return await messageActiveTab('hinting_content', 'hintPageOpenInBackground')
}
import {MsgSafeKeyboardEvent} from './msgsafe'
/** At some point, this might be turned into a real keyseq parser