diff --git a/src/commandline_frame.ts b/src/commandline_frame.ts index 72c12b37..86e11450 100644 --- a/src/commandline_frame.ts +++ b/src/commandline_frame.ts @@ -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), diff --git a/src/completions/Buffer.ts b/src/completions/Tab.ts similarity index 89% rename from src/completions/Buffer.ts rename to src/completions/Tab.ts index 319673dd..6718816b 100644 --- a/src/completions/Buffer.ts +++ b/src/completions/Tab.ts @@ -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, diff --git a/src/completions/BufferAll.ts b/src/completions/TabAll.ts similarity index 91% rename from src/completions/BufferAll.ts rename to src/completions/TabAll.ts index 0494113d..ff3f693e 100644 --- a/src/completions/BufferAll.ts +++ b/src/completions/TabAll.ts @@ -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, diff --git a/src/excmds.ts b/src/excmds.ts index 8b07fd27..d8c15183 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -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` diff --git a/src/lib/config.ts b/src/lib/config.ts index f709688f..2d773a8f 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -99,7 +99,7 @@ class default_config { "": "mode normal", "": "mode normal", "": "mode normal", - "": "buffer #", + "": "tab #", } /** @@ -117,7 +117,7 @@ class default_config { "": "focusinput -N", "": "mode normal", "": "mode normal", - "": "buffer #", + "": "tab #", } /** @@ -133,8 +133,8 @@ class default_config { "": "editor", "": "mode normal", "": "mode normal", - "": "buffer #", - "": "buffer #", + "": "tab #", + "": "tab #", "": "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", - "": "buffer #", - "": "buffer #", + "": "tab #", + "": "tab #", H: "back", L: "forward", "": "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", diff --git a/src/static/css/commandline.css b/src/static/css/commandline.css index daabc07d..71bc7fbe 100644 --- a/src/static/css/commandline.css +++ b/src/static/css/commandline.css @@ -133,11 +133,6 @@ a.url:hover { } } -/* .BufferCompletionOption span { */ -/* white-space: pre; */ -/* margin: 0 .5em; */ -/* } */ - .hidden { display: none; }