當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vscode.Terminal類代碼示例

本文整理匯總了TypeScript中vscode.Terminal的典型用法代碼示例。如果您正苦於以下問題:TypeScript Terminal類的具體用法?TypeScript Terminal怎麽用?TypeScript Terminal使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Terminal類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: startTask

 public async startTask(
     executable: string,
     preCommandArgs: string[],
     command: string,
     args: string[],
     cwd: string
 ): Promise<void> {
     args = preCommandArgs.concat(command, ...args);
     const terminal = window.createTerminal('Cargo Task');
     this._runningTerminal = terminal;
     const shell = await this._shellProvider.getValue();
     if (shell === undefined) {
         return;
     }
     const setEnvironmentVariables = () => {
         const cargoEnv = this._configuration.getCargoEnv();
         // Set environment variables
         for (const name in cargoEnv) {
             if (name in cargoEnv) {
                 const value = cargoEnv[name];
                 terminal.sendText(getCommandToSetEnvVar(shell, name, value));
             }
         }
     };
     setEnvironmentVariables();
     // Change the current directory to a specified directory
     this._runningTerminal.sendText(getCommandToChangeWorkingDirectory(shell, cwd));
     // Start a requested command
     this._runningTerminal.sendText(getCommandForArgs(shell, [executable, ...args]));
     this._runningTerminal.show(true);
 }
開發者ID:KalitaAlexey,項目名稱:RustyCode,代碼行數:31,代碼來源:terminal_task_manager.ts

示例2:

 const runCommandInIntegratedTerminal = (args: string[], cwd: string) => {
   if (terminal === null) {
     terminal = window.createTerminal('sbt');
     // start sbt
     terminal.sendText('sbt', true);
   }
   terminal.show();
   terminal.sendText(args.join(' '));
 };
開發者ID:dragos,項目名稱:dragos-vscode-scala,代碼行數:9,代碼來源:sbt.ts

示例3: runCommandInIntegratedTerminal

function runCommandInIntegratedTerminal(args: string[], cwd: string): void {
	const cmd_args = Array.from(args);
	if (!terminal) {
		terminal = window.createTerminal('npm');
	}
	terminal.show();
	if (cwd) {
		terminal.sendText(['cd', cwd].join(' '));
	}
	cmd_args.splice(0, 0, getNpmBin());
	terminal.sendText(cmd_args.join(' '));
}
開發者ID:scytalezero,項目名稱:vscode-npm-scripts,代碼行數:12,代碼來源:main.ts

示例4: timeout

			const reg1 = window.onDidChangeTerminalDimensions(async (event: TerminalDimensionsChangeEvent) => {
				assert.equal(event.terminal, terminal1);
				assert.equal(typeof event.dimensions.columns, 'number');
				assert.equal(typeof event.dimensions.rows, 'number');
				assert.ok(event.dimensions.columns > 0);
				assert.ok(event.dimensions.rows > 0);
				reg1.dispose();
				let terminal2: Terminal;
				const reg2 = window.onDidOpenTerminal((newTerminal) => {
					// This is guarantees to fire before dimensions change event
					if (newTerminal !== terminal1) {
						terminal2 = newTerminal;
						reg2.dispose();
					}
				});
				let firstCalled = false;
				let secondCalled = false;
				const reg3 = window.onDidChangeTerminalDimensions((event: TerminalDimensionsChangeEvent) => {
					if (event.terminal === terminal1) {
						// The original terminal should fire dimension change after a split
						firstCalled = true;
					} else if (event.terminal !== terminal1) {
						// The new split terminal should fire dimension change
						secondCalled = true;
					}
					if (firstCalled && secondCalled) {
						terminal1.dispose();
						terminal2.dispose();
						reg3.dispose();
						done();
					}
				});
				await timeout(500);
				commands.executeCommand('workbench.action.terminal.split');
			});
開發者ID:joelday,項目名稱:vscode,代碼行數:35,代碼來源:window.test.ts

示例5:

			const reg2 = renderer.onDidChangeMaximumDimensions(dimensions => {
				assert.ok(dimensions.columns > 0);
				assert.ok(dimensions.rows > 0);
				reg2.dispose();
				const reg3 = window.onDidCloseTerminal(() => {
					reg3.dispose();
					done();
				});
				terminal.dispose();
			});
開發者ID:joelday,項目名稱:vscode,代碼行數:10,代碼來源:window.test.ts

示例6: if

				const reg3 = window.onDidChangeTerminalDimensions((event: TerminalDimensionsChangeEvent) => {
					if (event.terminal === terminal1) {
						// The original terminal should fire dimension change after a split
						firstCalled = true;
					} else if (event.terminal !== terminal1) {
						// The new split terminal should fire dimension change
						secondCalled = true;
					}
					if (firstCalled && secondCalled) {
						terminal1.dispose();
						terminal2.dispose();
						reg3.dispose();
						done();
					}
				});
開發者ID:joelday,項目名稱:vscode,代碼行數:15,代碼來源:window.test.ts

示例7: test

		test('terminal renderers should get maximum dimensions set when shown', (done) => {
			let terminal: Terminal;
			const reg1 = window.onDidOpenTerminal(term => {
				reg1.dispose();
				term.show();
				terminal = term;
			});
			const renderer = window.createTerminalRenderer('foo');
			const reg2 = renderer.onDidChangeMaximumDimensions(dimensions => {
				assert.ok(dimensions.columns > 0);
				assert.ok(dimensions.rows > 0);
				reg2.dispose();
				const reg3 = window.onDidCloseTerminal(() => {
					reg3.dispose();
					done();
				});
				terminal.dispose();
			});
		});
開發者ID:joelday,項目名稱:vscode,代碼行數:19,代碼來源:window.test.ts

示例8: ensureTerminal

    private ensureTerminal(cwd: string): Terminal {
        if (this._terminal === undefined) {
            this._terminal = window.createTerminal(extensionTerminalName);
            this._disposable = window.onDidCloseTerminal((e: Terminal) => {
                if (e.name === extensionTerminalName) {
                    this._terminal = undefined;
                    this._disposable!.dispose();
                    this._disposable = undefined;
                }
            }, this);

            Container.context.subscriptions.push(this._disposable);
            this._terminalCwd = undefined;
        }

        if (this._terminalCwd !== cwd) {
            this._terminal.sendText(`cd "${cwd}"`, true);
            this._terminalCwd = cwd;
        }

        return this._terminal;
    }
開發者ID:eamodio,項目名稱:vscode-git-codelens,代碼行數:22,代碼來源:viewCommands.ts

示例9: stopRunningTask

 public stopRunningTask(): void {
     if (this._runningTerminal) {
         this._runningTerminal.dispose();
         this._runningTerminal = undefined;
     }
 }
開發者ID:KalitaAlexey,項目名稱:RustyCode,代碼行數:6,代碼來源:terminal_task_manager.ts

示例10: deactivate

export function deactivate() {
	if (terminal) {
		terminal.dispose();
	}
}
開發者ID:scytalezero,項目名稱:vscode-npm-scripts,代碼行數:5,代碼來源:main.ts


注:本文中的vscode.Terminal類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。