Add Tab Support

This commit is contained in:
rebornix 2016-06-28 10:25:28 +08:00
parent 8312673f8e
commit ca23b6641b
4 changed files with 102 additions and 1 deletions

View File

@ -380,3 +380,13 @@ Status | Command | Description
---|--------|------------------------------
| :r [file] | insert the contents of [file] below the cursor
| :r! {command} | insert the standard output of {command} below the cursor
## Tabs
Status | Command | Description
---|--------|------------------------------
:warning: | :tabn[ext] :1234: | Go to tab page {count}. The first tab page has number one.
:warning: | :tabp[revious] :1234: | Go to the previous tab page. Wraps around from the first one to the last one.
:x: | :tabfir[st] | Go to the first tab page.
:x: | :tabl[ast] | Go to the last tab page.

View File

@ -0,0 +1,56 @@
"use strict";
import * as vscode from "vscode";
import * as node from "../node";
import * as error from '../../error';
export enum Tab {
Next,
Previous,
First,
Last
}
export interface ITabCommandArguments extends node.ICommandArgs {
tab: Tab;
range?: node.LineRange;
}
//
// Implements tab
// http://vimdoc.sourceforge.net/htmldoc/editing.html#:quit
//
export class TabCommand extends node.CommandBase {
protected _arguments : ITabCommandArguments;
constructor(args : ITabCommandArguments) {
super();
this._name = 'tab';
this._shortName = 'tab';
this._arguments = args;
}
get arguments() : ITabCommandArguments {
return this._arguments;
}
execute() : void {
switch (this._arguments.tab) {
case Tab.Next:
vscode.commands.executeCommand("workbench.action.nextEditor");
break;
case Tab.Previous:
vscode.commands.executeCommand("workbench.action.previousEditor");
break;
case Tab.First:
vscode.commands.executeCommand("workbench.action.openEditorAtIndex1");
break;
case Tab.Last:
vscode.commands.executeCommand("workbench.action.openLastEditorInGroup");
break;
default:
break;
}
}
}

View File

@ -2,6 +2,7 @@
import {parseQuitCommandArgs} from './subparsers/quit';
import {parseWriteCommandArgs} from './subparsers/write';
import * as tabCmd from './subparsers/tab';
// maps command names to parsers for said commands.
export const commandParsers = {
@ -9,5 +10,10 @@ export const commandParsers = {
write: parseWriteCommandArgs,
quit: parseQuitCommandArgs,
q: parseQuitCommandArgs
q: parseQuitCommandArgs,
tabn: tabCmd.parseTabNCommandArgs,
tabp: tabCmd.parseTabPCommandArgs,
tabfir: tabCmd.parseTabFirstCommandArgs,
tabl: tabCmd.parseTabLastCommandArgs
};

View File

@ -0,0 +1,29 @@
"use strict";
import * as node from "../commands/tab";
import {Scanner} from '../scanner';
import {VimError, ErrorCode} from '../../error';
export function parseTabNCommandArgs(args : string) : node.TabCommand {
return new node.TabCommand({
tab: node.Tab.Next
});
}
export function parseTabPCommandArgs(args : string) : node.TabCommand {
return new node.TabCommand({
tab: node.Tab.Previous
});
}
export function parseTabFirstCommandArgs(args : string) : node.TabCommand {
return new node.TabCommand({
tab: node.Tab.First
});
}
export function parseTabLastCommandArgs(args : string) : node.TabCommand {
return new node.TabCommand({
tab: node.Tab.Last
});
}