mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Add a clear command to extension terminal sample
Related microsoft/vscode#81908
This commit is contained in:
@ -12,7 +12,8 @@
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onCommand:extensionTerminalSample.create"
|
||||
"onCommand:extensionTerminalSample.create",
|
||||
"onCommand:extensionTerminalSample.clear"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"contributes": {
|
||||
@ -20,6 +21,10 @@
|
||||
{
|
||||
"command": "extensionTerminalSample.create",
|
||||
"title": "Extension Terminal Sample: Create"
|
||||
},
|
||||
{
|
||||
"command": "extensionTerminalSample.clear",
|
||||
"title": "Extension Terminal Sample: Clear"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
const writeEmitter = new vscode.EventEmitter<string>();
|
||||
context.subscriptions.push(vscode.commands.registerCommand('extensionTerminalSample.create', () => {
|
||||
const writeEmitter = new vscode.EventEmitter<string>();
|
||||
let line = '';
|
||||
const pty = {
|
||||
onDidWrite: writeEmitter.event,
|
||||
@ -34,6 +34,10 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
const terminal = (<any>vscode.window).createTerminal({ name: `My Extension REPL`, pty });
|
||||
terminal.show();
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('extensionTerminalSample.clear', () => {
|
||||
writeEmitter.fire('\x1b[2J\x1b[;H');
|
||||
}));
|
||||
}
|
||||
|
||||
function colorText(text: string): string {
|
||||
|
||||
Reference in New Issue
Block a user