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

View file

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

View file

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

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

View file

@ -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",
@ -426,7 +426,8 @@ class default_config {
blast: "tablast",
tfirst: "tabfirst",
tlast: "tablast",
tab: "buffer",
buffer: "tab",
bufferall: "taball",
bd: "tabclose",
bdelete: "tabclose",
quit: "tabclose",

View file

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