mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Merge pull request #5181 from vchernetskyi993/tstmove
Some checks failed
lint / lint (unit) (push) Has been cancelled
e2e / test (firefox, ubuntu) (push) Has been cancelled
e2e / test (firefox, windows) (push) Has been cancelled
e2e / test (firefoxesr, ubuntu) (push) Has been cancelled
lint / lint (lint) (push) Has been cancelled
lint / lint (mozilla) (push) Has been cancelled
Website / build (push) Has been cancelled
Website / deploy (push) Has been cancelled
Some checks failed
lint / lint (unit) (push) Has been cancelled
e2e / test (firefox, ubuntu) (push) Has been cancelled
e2e / test (firefox, windows) (push) Has been cancelled
e2e / test (firefoxesr, ubuntu) (push) Has been cancelled
lint / lint (lint) (push) Has been cancelled
lint / lint (mozilla) (push) Has been cancelled
Website / build (push) Has been cancelled
Website / deploy (push) Has been cancelled
Added ability to move TST trees
This commit is contained in:
commit
961726bfbd
|
|
@ -96,6 +96,9 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
|||
"tabrename",
|
||||
"tabdiscard",
|
||||
"pin",
|
||||
"tstmove",
|
||||
"tstmoveafter",
|
||||
"tstattach",
|
||||
],
|
||||
"BufferCompletionSource",
|
||||
"Tabs",
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ import { OpenMode } from "@src/lib/hint_util"
|
|||
import * as Proxy from "@src/lib/proxy"
|
||||
import * as arg from "@src/lib/arg_util"
|
||||
import * as R from "ramda"
|
||||
import * as treestyletab from "@src/interop/tst"
|
||||
|
||||
/**
|
||||
* This is used to drive some excmd handling in `composite`.
|
||||
|
|
@ -2859,8 +2860,8 @@ export async function tabopen_helper({ addressarr = [], waitForDom = false }): P
|
|||
// and browser.search.search() seems to fix that problem.
|
||||
// See https://github.com/tridactyl/tridactyl/pull/4791.
|
||||
return openInNewTab(null, args, waitForDom)
|
||||
.then(tab => browser.tabs.get(tab.id))
|
||||
.then(tab => browser.search.search({tabId: tab.id, ...maybeURL}))
|
||||
.then(tab => browser.tabs.get(tab.id))
|
||||
.then(tab => browser.search.search({ tabId: tab.id, ...maybeURL }))
|
||||
}
|
||||
|
||||
// Fall back to about:newtab
|
||||
|
|
@ -3055,7 +3056,7 @@ export async function tabcloseallto(side: string) {
|
|||
export async function tabdiscard(index: string) {
|
||||
let id: number
|
||||
if (index === "--all") {
|
||||
return browser.tabs.query({}).then(ts => browser.tabs.discard(ts.map(t=>t.id)))
|
||||
return browser.tabs.query({}).then(ts => browser.tabs.discard(ts.map(t => t.id)))
|
||||
} else if (index === undefined) {
|
||||
id = (await activeTab()).id
|
||||
} else {
|
||||
|
|
@ -3372,7 +3373,7 @@ export async function qall() {
|
|||
//#background
|
||||
export async function sidebaropen(...urllike: string[]) {
|
||||
const url = await queryAndURLwrangler(urllike)
|
||||
if (typeof url === "string") return browser.sidebarAction.setPanel({panel: url})
|
||||
if (typeof url === "string") return browser.sidebarAction.setPanel({ panel: url })
|
||||
throw new Error("Unsupported URL for sidebar. If it was a search term try `:set searchengine google` first")
|
||||
}
|
||||
|
||||
|
|
@ -3382,7 +3383,7 @@ export async function sidebaropen(...urllike: string[]) {
|
|||
* `:bind --mode=browser <C-.> jsua browser.sidebarAction.open(); tri.excmds.sidebaropen("https://mail.google.com/mail/mu")`
|
||||
*/
|
||||
//#background
|
||||
export async function jsua(){
|
||||
export async function jsua() {
|
||||
throw new Error(":jsua can only be called through `bind --mode=browser` binds, see `:help jsua`")
|
||||
}
|
||||
|
||||
|
|
@ -3392,7 +3393,7 @@ export async function jsua(){
|
|||
* `:bind --mode=browser <C-.> sidebartoggle`
|
||||
*/
|
||||
//#background
|
||||
export async function sidebartoggle(){
|
||||
export async function sidebartoggle() {
|
||||
throw new Error(":sidebartoggle can only be called through `bind --mode=browser` binds, see `:help sidebartoggle`")
|
||||
}
|
||||
|
||||
|
|
@ -3947,7 +3948,7 @@ export function fillcmdline(...strarr: string[]) {
|
|||
const str = strarr.join(" ")
|
||||
showcmdline(false)
|
||||
logger.debug("excmds fillcmdline sending fillcmdline to commandline_frame")
|
||||
return Messaging.messageOwnTab("commandline_frame", "fillcmdline", [str, true/*trailspace*/, true/*focus*/])
|
||||
return Messaging.messageOwnTab("commandline_frame", "fillcmdline", [str, true /*trailspace*/, true /*focus*/])
|
||||
}
|
||||
|
||||
/** Set the current value of the commandline to string *without* a trailing space */
|
||||
|
|
@ -3955,7 +3956,7 @@ export function fillcmdline(...strarr: string[]) {
|
|||
export function fillcmdline_notrail(...strarr: string[]) {
|
||||
const str = strarr.join(" ")
|
||||
showcmdline(false)
|
||||
return Messaging.messageOwnTab("commandline_frame", "fillcmdline", [str, false/*trailspace*/, true/*focus*/])
|
||||
return Messaging.messageOwnTab("commandline_frame", "fillcmdline", [str, false /*trailspace*/, true /*focus*/])
|
||||
}
|
||||
|
||||
/** Show and fill the command line without focusing it */
|
||||
|
|
@ -6208,3 +6209,34 @@ export async function elementunhide() {
|
|||
elem.className = elem.className.replace("TridactylKilledElem", "")
|
||||
}
|
||||
// vim: tabstop=4 shiftwidth=4 expandtab
|
||||
|
||||
/**
|
||||
* Move the current [Tree Style Tab](https://github.com/piroor/treestyletab) tree to be just in front of the tab specified. If TST is not installed, no error is raised and no action is taken.
|
||||
*/
|
||||
//#background
|
||||
export async function tstmove(index: string) {
|
||||
const tabId = await idFromIndex(index)
|
||||
treestyletab.moveTreeBefore(tabId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the current TST tree to be right after the tab specified.
|
||||
*
|
||||
* See also: [[tstmove]]
|
||||
*/
|
||||
//#background
|
||||
export async function tstmoveafter(index: string) {
|
||||
const tabId = await idFromIndex(index)
|
||||
treestyletab.moveTreeAfter(tabId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach current tree as a child to the selected parent.
|
||||
*
|
||||
* See also: [[tstmove]]
|
||||
*/
|
||||
//#background
|
||||
export async function tstattach(index: string) {
|
||||
const tabId = await idFromIndex(index)
|
||||
treestyletab.attachTree(tabId)
|
||||
}
|
||||
|
|
|
|||
29
src/interop/tst.ts
Normal file
29
src/interop/tst.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import * as ExtensionInfo from "@src/lib/extension_info"
|
||||
import { activeTab } from "@src/lib/webext"
|
||||
|
||||
export async function moveTreeBefore(tabId: number) {
|
||||
await ExtensionInfo.messageExtension("tree_style_tab", {
|
||||
type: "move-before",
|
||||
tab: "current",
|
||||
referenceTabId: tabId,
|
||||
followChildren: true,
|
||||
})
|
||||
}
|
||||
|
||||
export async function moveTreeAfter(tabId: number) {
|
||||
await ExtensionInfo.messageExtension("tree_style_tab", {
|
||||
type: "move-after",
|
||||
tab: "current",
|
||||
referenceTabId: tabId,
|
||||
followChildren: true,
|
||||
})
|
||||
}
|
||||
|
||||
export async function attachTree(parentTabId: number) {
|
||||
const currentTab = await activeTab()
|
||||
await ExtensionInfo.messageExtension("tree_style_tab", {
|
||||
type: "attach",
|
||||
child: currentTab.id,
|
||||
parent: parentTabId,
|
||||
})
|
||||
}
|
||||
|
|
@ -5,14 +5,21 @@
|
|||
|
||||
*/
|
||||
|
||||
import Logger from "./logging"
|
||||
|
||||
/** Friendly-names of extensions that are used in different places so
|
||||
that we can refer to them with more readable and less magic ids.
|
||||
*/
|
||||
export const KNOWN_EXTENSIONS: { [name: string]: string } = {
|
||||
temp_containers: "{c607c8df-14a7-4f28-894f-29e8722976af}",
|
||||
multi_account_containers: "@testpilot-containers",
|
||||
tree_style_tab: "treestyletab@piro.sakura.ne.jp",
|
||||
}
|
||||
|
||||
type KnownExtensionId = keyof typeof KNOWN_EXTENSIONS
|
||||
|
||||
const logger = new Logger("extensions")
|
||||
|
||||
/** List of currently installed extensions.
|
||||
*/
|
||||
const installedExtensions: {
|
||||
|
|
@ -84,3 +91,11 @@ export async function listExtensions() {
|
|||
.map(key => installedExtensions[key])
|
||||
.filter(obj => obj.optionsUrl.length > 0)
|
||||
}
|
||||
|
||||
export async function messageExtension(id: KnownExtensionId, message: any) {
|
||||
try {
|
||||
return await browser.runtime.sendMessage(KNOWN_EXTENSIONS[id], message)
|
||||
} catch (e) {
|
||||
logger.error("Failed to communicate with extension ", id, e)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue