Rename buffers to tabs

Note: The CSS class names are kept as they were, see #1183 for more
information.
This commit is contained in:
glacambre 2018-11-19 07:14:08 +01:00
parent 704e1e572d
commit c412c8dad0
No known key found for this signature in database
GPG key ID: B9625DB1767553AC
6 changed files with 38 additions and 41 deletions

View file

@ -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),

View file

@ -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,

View file

@ -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,

View file

@ -2623,10 +2623,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 +2637,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 +2745,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`

View file

@ -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",
@ -426,7 +426,8 @@ class default_config {
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",

View file

@ -133,11 +133,6 @@ a.url:hover {
} }
} }
/* .BufferCompletionOption span { */
/* white-space: pre; */
/* margin: 0 .5em; */
/* } */
.hidden { .hidden {
display: none; display: none;
} }