mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 10:01:39 -05:00
Merge pull request #1183 from glacambre/s_buffer_tab_
Rename buffers to tabs
This commit is contained in:
commit
f53375f474
6 changed files with 40 additions and 53 deletions
|
@ -21,8 +21,8 @@ import * as perf from "@src/perf"
|
||||||
import "@src/lib/number.clamp"
|
import "@src/lib/number.clamp"
|
||||||
import "@src/lib/html-tagged-template"
|
import "@src/lib/html-tagged-template"
|
||||||
import * as Completions from "@src/completions"
|
import * as Completions from "@src/completions"
|
||||||
import { BufferAllCompletionSource } from "@src/completions/BufferAll"
|
import { TabAllCompletionSource } from "@src/completions/TabAll"
|
||||||
import { BufferCompletionSource } from "@src/completions/Buffer"
|
import { TabCompletionSource } from "@src/completions/Tab"
|
||||||
import { BmarkCompletionSource } from "@src/completions/Bmark"
|
import { BmarkCompletionSource } from "@src/completions/Bmark"
|
||||||
import { ExcmdCompletionSource } from "@src/completions/Excmd"
|
import { ExcmdCompletionSource } from "@src/completions/Excmd"
|
||||||
import { FileSystemCompletionSource } from "@src/completions/FileSystem"
|
import { FileSystemCompletionSource } from "@src/completions/FileSystem"
|
||||||
|
@ -93,8 +93,8 @@ export function enableCompletions() {
|
||||||
if (!activeCompletions) {
|
if (!activeCompletions) {
|
||||||
activeCompletions = [
|
activeCompletions = [
|
||||||
new BmarkCompletionSource(completionsDiv),
|
new BmarkCompletionSource(completionsDiv),
|
||||||
new BufferAllCompletionSource(completionsDiv),
|
new TabAllCompletionSource(completionsDiv),
|
||||||
new BufferCompletionSource(completionsDiv),
|
new TabCompletionSource(completionsDiv),
|
||||||
new ExcmdCompletionSource(completionsDiv),
|
new ExcmdCompletionSource(completionsDiv),
|
||||||
new FileSystemCompletionSource(completionsDiv),
|
new FileSystemCompletionSource(completionsDiv),
|
||||||
new HelpCompletionSource(completionsDiv),
|
new HelpCompletionSource(completionsDiv),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as Containers from "@src/lib/containers"
|
||||||
import * as Messaging from "@src/lib/messaging"
|
import * as Messaging from "@src/lib/messaging"
|
||||||
import * as Completions from "@src/completions"
|
import * as Completions from "@src/completions"
|
||||||
|
|
||||||
class BufferCompletionOption extends Completions.CompletionOptionHTML
|
class TabCompletionOption extends Completions.CompletionOptionHTML
|
||||||
implements Completions.CompletionOptionFuse {
|
implements Completions.CompletionOptionFuse {
|
||||||
public fuseKeys = []
|
public fuseKeys = []
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class BufferCompletionOption extends Completions.CompletionOptionHTML
|
||||||
container: browser.contextualIdentities.ContextualIdentity,
|
container: browser.contextualIdentities.ContextualIdentity,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
// Two character buffer properties prefix
|
// Two character tab properties prefix
|
||||||
let pre = ""
|
let pre = ""
|
||||||
if (tab.active) pre += "%"
|
if (tab.active) pre += "%"
|
||||||
else if (isAlternative) {
|
else if (isAlternative) {
|
||||||
|
@ -48,8 +48,8 @@ class BufferCompletionOption extends Completions.CompletionOptionHTML
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
export class TabCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
public options: BufferCompletionOption[]
|
public options: TabCompletionOption[]
|
||||||
private shouldSetStateFromScore = true
|
private shouldSetStateFromScore = true
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
|
@ -59,9 +59,9 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
|
|
||||||
constructor(private _parent) {
|
constructor(private _parent) {
|
||||||
super(
|
super(
|
||||||
["buffer", "tabclose", "tabdetach", "tabduplicate", "tabmove"],
|
["tab", "tabclose", "tabdetach", "tabduplicate", "tabmove"],
|
||||||
"BufferCompletionSource",
|
"TabCompletionSource",
|
||||||
"Buffers",
|
"Tabs",
|
||||||
)
|
)
|
||||||
|
|
||||||
this.updateOptions()
|
this.updateOptions()
|
||||||
|
@ -70,11 +70,12 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
|
|
||||||
@Perf.measuredAsync
|
@Perf.measuredAsync
|
||||||
private async updateOptions(exstr = "") {
|
private async updateOptions(exstr = "") {
|
||||||
|
|
||||||
const [prefix, query] = this.splitOnPrefix(exstr)
|
const [prefix, query] = this.splitOnPrefix(exstr)
|
||||||
|
|
||||||
// When the user is asking for tabmove completions, don't autoselect if the query looks like a relative move https://github.com/tridactyl/tridactyl/issues/825
|
// When the user is asking for tabmove completions, don't autoselect if the query looks like a relative move https://github.com/tridactyl/tridactyl/issues/825
|
||||||
this.shouldSetStateFromScore = !(prefix == "tabmove " && query.match("^[+-][0-9]+$"))
|
this.shouldSetStateFromScore = !(
|
||||||
|
prefix == "tabmove " && query.match("^[+-][0-9]+$")
|
||||||
|
)
|
||||||
|
|
||||||
/* console.log('updateOptions', this.optionContainer) */
|
/* console.log('updateOptions', this.optionContainer) */
|
||||||
const tabs: browser.tabs.Tab[] = await Messaging.message(
|
const tabs: browser.tabs.Tab[] = await Messaging.message(
|
||||||
|
@ -94,7 +95,7 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
|
|
||||||
for (const tab of tabs) {
|
for (const tab of tabs) {
|
||||||
options.push(
|
options.push(
|
||||||
new BufferCompletionOption(
|
new TabCompletionOption(
|
||||||
(tab.index + 1).toString(),
|
(tab.index + 1).toString(),
|
||||||
tab,
|
tab,
|
||||||
tab === alt,
|
tab === alt,
|
||||||
|
@ -109,7 +110,7 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
}
|
}
|
||||||
|
|
||||||
async onInput(exstr) {
|
async onInput(exstr) {
|
||||||
// Schedule an update, if you like. Not very useful for buffers, but
|
// Schedule an update, if you like. Not very useful for tabs, but
|
||||||
// will be for other things.
|
// will be for other things.
|
||||||
this.updateOptions(exstr)
|
this.updateOptions(exstr)
|
||||||
}
|
}
|
||||||
|
@ -118,7 +119,7 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
super.setStateFromScore(scoredOpts, this.shouldSetStateFromScore)
|
super.setStateFromScore(scoredOpts, this.shouldSetStateFromScore)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Score with fuse unless query is a single # or looks like a buffer index */
|
/** Score with fuse unless query is a single # or looks like a tab index */
|
||||||
scoredOptions(
|
scoredOptions(
|
||||||
query: string,
|
query: string,
|
||||||
options = this.options,
|
options = this.options,
|
|
@ -4,7 +4,7 @@ import * as Containers from "@src/lib/containers"
|
||||||
import * as Messaging from "@src/lib/messaging"
|
import * as Messaging from "@src/lib/messaging"
|
||||||
import * as Completions from "@src/completions"
|
import * as Completions from "@src/completions"
|
||||||
|
|
||||||
class BufferAllCompletionOption extends Completions.CompletionOptionHTML
|
class TabAllCompletionOption extends Completions.CompletionOptionHTML
|
||||||
implements Completions.CompletionOptionFuse {
|
implements Completions.CompletionOptionFuse {
|
||||||
public fuseKeys = []
|
public fuseKeys = []
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -39,11 +39,11 @@ class BufferAllCompletionOption extends Completions.CompletionOptionHTML
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BufferAllCompletionSource extends Completions.CompletionSourceFuse {
|
export class TabAllCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
public options: BufferAllCompletionOption[]
|
public options: TabAllCompletionOption[]
|
||||||
|
|
||||||
constructor(private _parent) {
|
constructor(private _parent) {
|
||||||
super(["bufferall"], "BufferAllCompletionSource", "All Buffers")
|
super(["taball"], "TabAllCompletionSource", "All Tabs")
|
||||||
|
|
||||||
this.updateOptions()
|
this.updateOptions()
|
||||||
this._parent.appendChild(this.node)
|
this._parent.appendChild(this.node)
|
||||||
|
@ -89,7 +89,7 @@ export class BufferAllCompletionSource extends Completions.CompletionSourceFuse
|
||||||
winindex += 1
|
winindex += 1
|
||||||
}
|
}
|
||||||
options.push(
|
options.push(
|
||||||
new BufferAllCompletionOption(
|
new TabAllCompletionOption(
|
||||||
tab.id.toString(),
|
tab.id.toString(),
|
||||||
tab,
|
tab,
|
||||||
winindex,
|
winindex,
|
|
@ -1711,18 +1711,6 @@ export async function tabprev(increment = 1) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Switch to the first tab. */
|
|
||||||
//#background
|
|
||||||
export async function tabfirst() {
|
|
||||||
tabIndexSetActive(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Switch to the last tab. */
|
|
||||||
//#background
|
|
||||||
export async function tablast() {
|
|
||||||
tabIndexSetActive(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Like [[open]], but in a new tab. If no address is given, it will open the newtab page, which can be set with `set newtab [url]`
|
/** Like [[open]], but in a new tab. If no address is given, it will open the newtab page, which can be set with `set newtab [url]`
|
||||||
|
|
||||||
Use the `-c` flag followed by a container name to open a tab in said container. Tridactyl will try to fuzzy match a name if an exact match is not found.
|
Use the `-c` flag followed by a container name to open a tab in said container. Tridactyl will try to fuzzy match a name if an exact match is not found.
|
||||||
|
@ -2623,10 +2611,10 @@ export async function clipboard(excmd: "open" | "yank" | "yankshort" | "yankcano
|
||||||
|
|
||||||
"#" means the tab that was last accessed in this window
|
"#" means the tab that was last accessed in this window
|
||||||
|
|
||||||
This is different from [[bufferall]] because `index` is the position of the tab in the window.
|
This is different from [[taball]] because `index` is the position of the tab in the current window.
|
||||||
*/
|
*/
|
||||||
//#background
|
//#background
|
||||||
export async function buffer(index: number | "#") {
|
export async function tab(index: number | "#") {
|
||||||
tabIndexSetActive(index)
|
tabIndexSetActive(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2637,13 +2625,13 @@ export async function buffer(index: number | "#") {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
//#background
|
//#background
|
||||||
export async function bufferall(id: string) {
|
export async function taball(id: string) {
|
||||||
let windows = (await browser.windows.getAll()).map(w => w.id).sort((a, b) => a - b)
|
let windows = (await browser.windows.getAll()).map(w => w.id).sort((a, b) => a - b)
|
||||||
if (id === null || id === undefined || !id.match(/\d+\.\d+/)) {
|
if (id === null || id === undefined || !id.match(/\d+\.\d+/)) {
|
||||||
const tab = await activeTab()
|
const tab = await activeTab()
|
||||||
let prevId = id
|
let prevId = id
|
||||||
id = windows.indexOf(tab.windowId) + "." + (tab.index + 1)
|
id = windows.indexOf(tab.windowId) + "." + (tab.index + 1)
|
||||||
logger.info(`bufferall: Bad tab id: ${prevId}, defaulting to ${id}`)
|
logger.info(`taball: Bad tab id: ${prevId}, defaulting to ${id}`)
|
||||||
}
|
}
|
||||||
let [winindex, tabindex] = id.split(".")
|
let [winindex, tabindex] = id.split(".")
|
||||||
await browser.windows.update(windows[parseInt(winindex) - 1], { focused: true })
|
await browser.windows.update(windows[parseInt(winindex) - 1], { focused: true })
|
||||||
|
@ -2745,7 +2733,7 @@ function parse_bind_args(...args: string[]): bind_args {
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
- `bind G fillcmdline tabopen google`
|
- `bind G fillcmdline tabopen google`
|
||||||
- `bind D composite tabclose | buffer #`
|
- `bind D composite tabclose | tab #`
|
||||||
- `bind j scrollline 20`
|
- `bind j scrollline 20`
|
||||||
- `bind F hint -b`
|
- `bind F hint -b`
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ class default_config {
|
||||||
"<CA-Escape>": "mode normal",
|
"<CA-Escape>": "mode normal",
|
||||||
"<CA-`>": "mode normal",
|
"<CA-`>": "mode normal",
|
||||||
"<S-Escape>": "mode normal",
|
"<S-Escape>": "mode normal",
|
||||||
"<C-^>": "buffer #",
|
"<C-^>": "tab #",
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +117,7 @@ class default_config {
|
||||||
"<S-Tab>": "focusinput -N",
|
"<S-Tab>": "focusinput -N",
|
||||||
"<CA-Escape>": "mode normal",
|
"<CA-Escape>": "mode normal",
|
||||||
"<CA-`>": "mode normal",
|
"<CA-`>": "mode normal",
|
||||||
"<C-^>": "buffer #",
|
"<C-^>": "tab #",
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,8 +133,8 @@ class default_config {
|
||||||
"<C-i>": "editor",
|
"<C-i>": "editor",
|
||||||
"<CA-Escape>": "mode normal",
|
"<CA-Escape>": "mode normal",
|
||||||
"<CA-`>": "mode normal",
|
"<CA-`>": "mode normal",
|
||||||
"<C-6>": "buffer #",
|
"<C-6>": "tab #",
|
||||||
"<C-^>": "buffer #",
|
"<C-^>": "tab #",
|
||||||
"<S-Escape>": "mode ignore",
|
"<S-Escape>": "mode ignore",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,8 +183,8 @@ class default_config {
|
||||||
$: "scrollto 100 x",
|
$: "scrollto 100 x",
|
||||||
// "0": "scrollto 0 x", // will get interpreted as a count
|
// "0": "scrollto 0 x", // will get interpreted as a count
|
||||||
"^": "scrollto 0 x",
|
"^": "scrollto 0 x",
|
||||||
"<C-6>": "buffer #",
|
"<C-6>": "tab #",
|
||||||
"<C-^>": "buffer #",
|
"<C-^>": "tab #",
|
||||||
H: "back",
|
H: "back",
|
||||||
L: "forward",
|
L: "forward",
|
||||||
"<C-o>": "jumpprev",
|
"<C-o>": "jumpprev",
|
||||||
|
@ -222,8 +222,8 @@ class default_config {
|
||||||
// "n": "findnext 1",
|
// "n": "findnext 1",
|
||||||
// "N": "findnext -1",
|
// "N": "findnext -1",
|
||||||
M: "gobble 1 quickmark",
|
M: "gobble 1 quickmark",
|
||||||
B: "fillcmdline bufferall",
|
B: "fillcmdline taball",
|
||||||
b: "fillcmdline buffer",
|
b: "fillcmdline tab",
|
||||||
ZZ: "qall",
|
ZZ: "qall",
|
||||||
f: "hint",
|
f: "hint",
|
||||||
F: "hint -b",
|
F: "hint -b",
|
||||||
|
@ -407,7 +407,7 @@ class default_config {
|
||||||
aucon: "autocontain",
|
aucon: "autocontain",
|
||||||
audel: "autocmddelete",
|
audel: "autocmddelete",
|
||||||
audelete: "autocmddelete",
|
audelete: "autocmddelete",
|
||||||
b: "buffer",
|
b: "tab",
|
||||||
o: "open",
|
o: "open",
|
||||||
w: "winopen",
|
w: "winopen",
|
||||||
t: "tabopen",
|
t: "tabopen",
|
||||||
|
@ -422,11 +422,14 @@ class default_config {
|
||||||
bN: "tabprev",
|
bN: "tabprev",
|
||||||
tprev: "tabprev",
|
tprev: "tabprev",
|
||||||
bprev: "tabprev",
|
bprev: "tabprev",
|
||||||
|
tabfirst: "tab 1",
|
||||||
|
tablast: "tab 0",
|
||||||
bfirst: "tabfirst",
|
bfirst: "tabfirst",
|
||||||
blast: "tablast",
|
blast: "tablast",
|
||||||
tfirst: "tabfirst",
|
tfirst: "tabfirst",
|
||||||
tlast: "tablast",
|
tlast: "tablast",
|
||||||
tab: "buffer",
|
buffer: "tab",
|
||||||
|
bufferall: "taball",
|
||||||
bd: "tabclose",
|
bd: "tabclose",
|
||||||
bdelete: "tabclose",
|
bdelete: "tabclose",
|
||||||
quit: "tabclose",
|
quit: "tabclose",
|
||||||
|
|
|
@ -133,11 +133,6 @@ a.url:hover {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* .BufferCompletionOption span { */
|
|
||||||
/* white-space: pre; */
|
|
||||||
/* margin: 0 .5em; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue