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/html-tagged-template"
|
||||
import * as Completions from "@src/completions"
|
||||
import { BufferAllCompletionSource } from "@src/completions/BufferAll"
|
||||
import { BufferCompletionSource } from "@src/completions/Buffer"
|
||||
import { TabAllCompletionSource } from "@src/completions/TabAll"
|
||||
import { TabCompletionSource } from "@src/completions/Tab"
|
||||
import { BmarkCompletionSource } from "@src/completions/Bmark"
|
||||
import { ExcmdCompletionSource } from "@src/completions/Excmd"
|
||||
import { FileSystemCompletionSource } from "@src/completions/FileSystem"
|
||||
|
@ -93,8 +93,8 @@ export function enableCompletions() {
|
|||
if (!activeCompletions) {
|
||||
activeCompletions = [
|
||||
new BmarkCompletionSource(completionsDiv),
|
||||
new BufferAllCompletionSource(completionsDiv),
|
||||
new BufferCompletionSource(completionsDiv),
|
||||
new TabAllCompletionSource(completionsDiv),
|
||||
new TabCompletionSource(completionsDiv),
|
||||
new ExcmdCompletionSource(completionsDiv),
|
||||
new FileSystemCompletionSource(completionsDiv),
|
||||
new HelpCompletionSource(completionsDiv),
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as Containers from "@src/lib/containers"
|
|||
import * as Messaging from "@src/lib/messaging"
|
||||
import * as Completions from "@src/completions"
|
||||
|
||||
class BufferCompletionOption extends Completions.CompletionOptionHTML
|
||||
class TabCompletionOption extends Completions.CompletionOptionHTML
|
||||
implements Completions.CompletionOptionFuse {
|
||||
public fuseKeys = []
|
||||
|
||||
|
@ -15,7 +15,7 @@ class BufferCompletionOption extends Completions.CompletionOptionHTML
|
|||
container: browser.contextualIdentities.ContextualIdentity,
|
||||
) {
|
||||
super()
|
||||
// Two character buffer properties prefix
|
||||
// Two character tab properties prefix
|
||||
let pre = ""
|
||||
if (tab.active) pre += "%"
|
||||
else if (isAlternative) {
|
||||
|
@ -48,8 +48,8 @@ class BufferCompletionOption extends Completions.CompletionOptionHTML
|
|||
}
|
||||
}
|
||||
|
||||
export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
||||
public options: BufferCompletionOption[]
|
||||
export class TabCompletionSource extends Completions.CompletionSourceFuse {
|
||||
public options: TabCompletionOption[]
|
||||
private shouldSetStateFromScore = true
|
||||
|
||||
// TODO:
|
||||
|
@ -59,9 +59,9 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
|||
|
||||
constructor(private _parent) {
|
||||
super(
|
||||
["buffer", "tabclose", "tabdetach", "tabduplicate", "tabmove"],
|
||||
"BufferCompletionSource",
|
||||
"Buffers",
|
||||
["tab", "tabclose", "tabdetach", "tabduplicate", "tabmove"],
|
||||
"TabCompletionSource",
|
||||
"Tabs",
|
||||
)
|
||||
|
||||
this.updateOptions()
|
||||
|
@ -70,11 +70,12 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
|||
|
||||
@Perf.measuredAsync
|
||||
private async updateOptions(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
|
||||
this.shouldSetStateFromScore = !(prefix == "tabmove " && query.match("^[+-][0-9]+$"))
|
||||
this.shouldSetStateFromScore = !(
|
||||
prefix == "tabmove " && query.match("^[+-][0-9]+$")
|
||||
)
|
||||
|
||||
/* console.log('updateOptions', this.optionContainer) */
|
||||
const tabs: browser.tabs.Tab[] = await Messaging.message(
|
||||
|
@ -94,7 +95,7 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
|||
|
||||
for (const tab of tabs) {
|
||||
options.push(
|
||||
new BufferCompletionOption(
|
||||
new TabCompletionOption(
|
||||
(tab.index + 1).toString(),
|
||||
tab,
|
||||
tab === alt,
|
||||
|
@ -109,7 +110,7 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
|||
}
|
||||
|
||||
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.
|
||||
this.updateOptions(exstr)
|
||||
}
|
||||
|
@ -118,7 +119,7 @@ export class BufferCompletionSource extends Completions.CompletionSourceFuse {
|
|||
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(
|
||||
query: string,
|
||||
options = this.options,
|
|
@ -4,7 +4,7 @@ import * as Containers from "@src/lib/containers"
|
|||
import * as Messaging from "@src/lib/messaging"
|
||||
import * as Completions from "@src/completions"
|
||||
|
||||
class BufferAllCompletionOption extends Completions.CompletionOptionHTML
|
||||
class TabAllCompletionOption extends Completions.CompletionOptionHTML
|
||||
implements Completions.CompletionOptionFuse {
|
||||
public fuseKeys = []
|
||||
constructor(
|
||||
|
@ -39,11 +39,11 @@ class BufferAllCompletionOption extends Completions.CompletionOptionHTML
|
|||
}
|
||||
}
|
||||
|
||||
export class BufferAllCompletionSource extends Completions.CompletionSourceFuse {
|
||||
public options: BufferAllCompletionOption[]
|
||||
export class TabAllCompletionSource extends Completions.CompletionSourceFuse {
|
||||
public options: TabAllCompletionOption[]
|
||||
|
||||
constructor(private _parent) {
|
||||
super(["bufferall"], "BufferAllCompletionSource", "All Buffers")
|
||||
super(["taball"], "TabAllCompletionSource", "All Tabs")
|
||||
|
||||
this.updateOptions()
|
||||
this._parent.appendChild(this.node)
|
||||
|
@ -89,7 +89,7 @@ export class BufferAllCompletionSource extends Completions.CompletionSourceFuse
|
|||
winindex += 1
|
||||
}
|
||||
options.push(
|
||||
new BufferAllCompletionOption(
|
||||
new TabAllCompletionOption(
|
||||
tab.id.toString(),
|
||||
tab,
|
||||
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]`
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
export async function buffer(index: number | "#") {
|
||||
export async function tab(index: number | "#") {
|
||||
tabIndexSetActive(index)
|
||||
}
|
||||
|
||||
|
@ -2637,13 +2625,13 @@ export async function buffer(index: number | "#") {
|
|||
|
||||
*/
|
||||
//#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)
|
||||
if (id === null || id === undefined || !id.match(/\d+\.\d+/)) {
|
||||
const tab = await activeTab()
|
||||
let prevId = id
|
||||
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(".")
|
||||
await browser.windows.update(windows[parseInt(winindex) - 1], { focused: true })
|
||||
|
@ -2745,7 +2733,7 @@ function parse_bind_args(...args: string[]): bind_args {
|
|||
Examples:
|
||||
|
||||
- `bind G fillcmdline tabopen google`
|
||||
- `bind D composite tabclose | buffer #`
|
||||
- `bind D composite tabclose | tab #`
|
||||
- `bind j scrollline 20`
|
||||
- `bind F hint -b`
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class default_config {
|
|||
"<CA-Escape>": "mode normal",
|
||||
"<CA-`>": "mode normal",
|
||||
"<S-Escape>": "mode normal",
|
||||
"<C-^>": "buffer #",
|
||||
"<C-^>": "tab #",
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,7 @@ class default_config {
|
|||
"<S-Tab>": "focusinput -N",
|
||||
"<CA-Escape>": "mode normal",
|
||||
"<CA-`>": "mode normal",
|
||||
"<C-^>": "buffer #",
|
||||
"<C-^>": "tab #",
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,8 +133,8 @@ class default_config {
|
|||
"<C-i>": "editor",
|
||||
"<CA-Escape>": "mode normal",
|
||||
"<CA-`>": "mode normal",
|
||||
"<C-6>": "buffer #",
|
||||
"<C-^>": "buffer #",
|
||||
"<C-6>": "tab #",
|
||||
"<C-^>": "tab #",
|
||||
"<S-Escape>": "mode ignore",
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,8 @@ class default_config {
|
|||
$: "scrollto 100 x",
|
||||
// "0": "scrollto 0 x", // will get interpreted as a count
|
||||
"^": "scrollto 0 x",
|
||||
"<C-6>": "buffer #",
|
||||
"<C-^>": "buffer #",
|
||||
"<C-6>": "tab #",
|
||||
"<C-^>": "tab #",
|
||||
H: "back",
|
||||
L: "forward",
|
||||
"<C-o>": "jumpprev",
|
||||
|
@ -222,8 +222,8 @@ class default_config {
|
|||
// "n": "findnext 1",
|
||||
// "N": "findnext -1",
|
||||
M: "gobble 1 quickmark",
|
||||
B: "fillcmdline bufferall",
|
||||
b: "fillcmdline buffer",
|
||||
B: "fillcmdline taball",
|
||||
b: "fillcmdline tab",
|
||||
ZZ: "qall",
|
||||
f: "hint",
|
||||
F: "hint -b",
|
||||
|
@ -407,7 +407,7 @@ class default_config {
|
|||
aucon: "autocontain",
|
||||
audel: "autocmddelete",
|
||||
audelete: "autocmddelete",
|
||||
b: "buffer",
|
||||
b: "tab",
|
||||
o: "open",
|
||||
w: "winopen",
|
||||
t: "tabopen",
|
||||
|
@ -422,11 +422,14 @@ class default_config {
|
|||
bN: "tabprev",
|
||||
tprev: "tabprev",
|
||||
bprev: "tabprev",
|
||||
tabfirst: "tab 1",
|
||||
tablast: "tab 0",
|
||||
bfirst: "tabfirst",
|
||||
blast: "tablast",
|
||||
tfirst: "tabfirst",
|
||||
tlast: "tablast",
|
||||
tab: "buffer",
|
||||
buffer: "tab",
|
||||
bufferall: "taball",
|
||||
bd: "tabclose",
|
||||
bdelete: "tabclose",
|
||||
quit: "tabclose",
|
||||
|
|
|
@ -133,11 +133,6 @@ a.url:hover {
|
|||
}
|
||||
}
|
||||
|
||||
/* .BufferCompletionOption span { */
|
||||
/* white-space: pre; */
|
||||
/* margin: 0 .5em; */
|
||||
/* } */
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue