Skip to content

Commit

Permalink
Bind commands for terminal.sendSequence and terminal.kill
Browse files Browse the repository at this point in the history
Signed-off-by: Vladyslav Zhukovskyi <vzhukovs@redhat.com>
  • Loading branch information
vzhukovs committed May 28, 2020
1 parent 99a7aa3 commit 48eeea9
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { URI } from 'vscode-uri';
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
import { TerminalFrontendContribution } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
import { QuickOpenWorkspace } from '@theia/workspace/lib/browser/quick-open-workspace';
import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';

export namespace VscodeCommands {
export const OPEN: Command = {
Expand Down Expand Up @@ -93,6 +94,8 @@ export class PluginVscodeCommandsContribution implements CommandContribution {
protected readonly terminalContribution: TerminalFrontendContribution;
@inject(QuickOpenWorkspace)
protected readonly quickOpenWorkspace: QuickOpenWorkspace;
@inject(TerminalService)
protected readonly terminalService: TerminalService;

registerCommands(commands: CommandRegistry): void {
commands.registerCommand(VscodeCommands.OPEN, {
Expand Down Expand Up @@ -584,5 +587,35 @@ export class PluginVscodeCommandsContribution implements CommandContribution {
}, {
execute: () => commands.executeCommand(WorkspaceCommands.NEW_FOLDER.id)
});
commands.registerCommand({
id: 'workbench.action.terminal.sendSequence'
}, {
execute: (args?: { text?: string }) => {
if (args === undefined || args.text === undefined) {
return;
}

const currentTerminal = this.terminalService.currentTerminal;

if (currentTerminal === undefined) {
return;
}

currentTerminal.sendText(args.text);
}
});
commands.registerCommand({
id: 'workbench.action.terminal.kill'
}, {
execute: () => {
const currentTerminal = this.terminalService.currentTerminal;

if (currentTerminal === undefined) {
return;
}

currentTerminal.dispose();
}
});
}
}

0 comments on commit 48eeea9

Please sign in to comment.