Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
afe91207
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
afe91207
编写于
9月 04, 2019
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Stabilize extension terminals (vscode.Pseudoterminal)
Fixes #78514
上级
052ffefc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
173 addition
and
179 deletion
+173
-179
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+172
-0
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+0
-178
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+1
-1
未找到文件。
src/vs/vscode.d.ts
浏览文件 @
afe91207
...
...
@@ -6855,6 +6855,15 @@ declare module 'vscode' {
*/
export
function
createTerminal
(
options
:
TerminalOptions
):
Terminal
;
/**
* Creates a [Terminal](#Terminal) where an extension controls its input and output.
*
* @param options An [ExtensionTerminalOptions](#ExtensionTerminalOptions) object describing
* the characteristics of the new terminal.
* @return A new Terminal.
*/
export
function
createTerminal
(
options
:
ExtensionTerminalOptions
):
Terminal
;
/**
* Register a [TreeDataProvider](#TreeDataProvider) for the view contributed using the extension point `views`.
* This will allow you to contribute data to the [TreeView](#TreeView) and update if the data changes.
...
...
@@ -7208,6 +7217,169 @@ declare module 'vscode' {
hideFromUser
?:
boolean
;
}
/**
* Value-object describing what options a virtual process terminal should use.
*/
export
interface
ExtensionTerminalOptions
{
/**
* A human-readable string which will be used to represent the terminal in the UI.
*/
name
:
string
;
/**
* An implementation of [Pseudoterminal](#Pseudoterminal) that allows an extension to
* control a terminal.
*/
pty
:
Pseudoterminal
;
}
/**
* Defines the interface of a terminal pty, enabling extensions to control a terminal.
*/
interface
Pseudoterminal
{
/**
* An event that when fired will write data to the terminal. Unlike
* [Terminal.sendText](#Terminal.sendText) which sends text to the underlying _process_
* (the pty "slave"), this will write the text to the terminal itself (the pty "master").
*
* **Example:** Write red text to the terminal
* ```typescript
* const writeEmitter = new vscode.EventEmitter<string>();
* const pty: vscode.Pseudoterminal = {
* onDidWrite: writeEmitter.event,
* open: () => writeEmitter.fire('\x1b[31mHello world\x1b[0m'),
* close: () => {}
* };
* vscode.window.createTerminal({ name: 'My terminal', pty });
* ```
*
* **Example:** Move the cursor to the 10th row and 20th column and write an asterisk
* ```typescript
* writeEmitter.fire('\x1b[10;20H*');
* ```
*/
onDidWrite
:
Event
<
string
>
;
/**
* An event that when fired allows overriding the [dimensions](#Terminal.dimensions) of the
* terminal. Note that when set, the overridden dimensions will only take effect when they
* are lower than the actual dimensions of the terminal (ie. there will never be a scroll
* bar). Set to `undefined` for the terminal to go back to the regular dimensions (fit to
* the size of the panel).
*
* **Example:** Override the dimensions of a terminal to 20 columns and 10 rows
* ```typescript
* const dimensionsEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
* const pty: vscode.Pseudoterminal = {
* onDidWrite: writeEmitter.event,
* onDidOverrideDimensions: dimensionsEmitter.event,
* open: () => {
* dimensionsEmitter.fire({
* columns: 20,
* rows: 10
* });
* },
* close: () => {}
* };
* vscode.window.createTerminal({ name: 'My terminal', pty });
* ```
*/
onDidOverrideDimensions
?:
Event
<
TerminalDimensions
|
undefined
>
;
/**
* An event that when fired will signal that the pty is closed and dispose of the terminal.
*
* A number can be used to provide an exit code for the terminal. Exit codes must be
* positive and a non-zero exit codes signals failure which shows a notification for a
* regular terminal and allows dependent tasks to proceed when used with the
* `CustomExecution2` API.
*
* **Example:** Exit the terminal when "y" is pressed, otherwise show a notification.
* ```typescript
* const writeEmitter = new vscode.EventEmitter<string>();
* const closeEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
* const pty: vscode.Pseudoterminal = {
* onDidWrite: writeEmitter.event,
* onDidClose: closeEmitter.event,
* open: () => writeEmitter.fire('Press y to exit successfully'),
* close: () => {},
* handleInput: data => {
* if (data !== 'y') {
* vscode.window.showInformationMessage('Something went wrong');
* }
* closeEmitter.fire();
* }
* };
* vscode.window.createTerminal({ name: 'Exit example', pty });
*/
onDidClose
?:
Event
<
void
|
number
>
;
/**
* Implement to handle when the pty is open and ready to start firing events.
*
* @param initialDimensions The dimensions of the terminal, this will be undefined if the
* terminal panel has not been opened before this is called.
*/
open
(
initialDimensions
:
TerminalDimensions
|
undefined
):
void
;
/**
* Implement to handle when the terminal is closed by an act of the user.
*/
close
():
void
;
/**
* Implement to handle incoming keystrokes in the terminal or when an extension calls
* [Terminal.sendText](#Terminal.sendText). `data` contains the keystrokes/text serialized into
* their corresponding VT sequence representation.
*
* @param data The incoming data.
*
* **Example:** Echo input in the terminal. The sequence for enter (`\r`) is translated to
* CRLF to go to a new line and move the cursor to the start of the line.
* ```typescript
* const writeEmitter = new vscode.EventEmitter<string>();
* const pty: vscode.Pseudoterminal = {
* onDidWrite: writeEmitter.event,
* open: () => {},
* close: () => {},
* handleInput: data => writeEmitter.fire(data === '\r' ? '\r\n' : data)
* };
* vscode.window.createTerminal({ name: 'Local echo', pty });
* ```
*/
handleInput
?(
data
:
string
):
void
;
/**
* Implement to handle when the number of rows and columns that fit into the terminal panel
* changes, for example when font size changes or when the panel is resized. The initial
* state of a terminal's dimensions should be treated as `undefined` until this is triggered
* as the size of a terminal isn't know until it shows up in the user interface.
*
* When dimensions are overridden by
* [onDidOverrideDimensions](#Pseudoterminal.onDidOverrideDimensions), `setDimensions` will
* continue to be called with the regular panel dimensions, allowing the extension continue
* to react dimension changes.
*
* @param dimensions The new dimensions.
*/
setDimensions
?(
dimensions
:
TerminalDimensions
):
void
;
}
/**
* Represents the dimensions of a terminal.
*/
export
interface
TerminalDimensions
{
/**
* The number of columns in the terminal.
*/
readonly
columns
:
number
;
/**
* The number of rows in the terminal.
*/
readonly
rows
:
number
;
}
/**
* A location in the editor at which progress information can be shown. It depends on the
* location how progress is visually represented.
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
afe91207
...
...
@@ -760,184 +760,6 @@ declare module 'vscode' {
readonly
onDidWriteData
:
Event
<
string
>
;
}
/**
* Represents the dimensions of a terminal.
*/
export
interface
TerminalDimensions
{
/**
* The number of columns in the terminal.
*/
readonly
columns
:
number
;
/**
* The number of rows in the terminal.
*/
readonly
rows
:
number
;
}
//#endregion
//#region Extension terminals
export
namespace
window
{
/**
* Creates a [Terminal](#Terminal) where an extension controls the terminal.
*
* @param options An [ExtensionTerminalOptions](#ExtensionTerminalOptions) object describing
* the characteristics of the new terminal.
* @return A new Terminal.
*/
export
function
createTerminal
(
options
:
ExtensionTerminalOptions
):
Terminal
;
}
/**
* Value-object describing what options a virtual process terminal should use.
*/
export
interface
ExtensionTerminalOptions
{
/**
* A human-readable string which will be used to represent the terminal in the UI.
*/
name
:
string
;
/**
* An implementation of [Pseudoterminal](#Pseudoterminal) that allows an extension to
* control a terminal.
*/
pty
:
Pseudoterminal
;
}
/**
* Defines the interface of a terminal pty, enabling extensions to control a terminal.
*/
interface
Pseudoterminal
{
/**
* An event that when fired will write data to the terminal. Unlike
* [Terminal.sendText](#Terminal.sendText) which sends text to the underlying _process_
* (the pty "slave"), this will write the text to the terminal itself (the pty "master").
*
* **Example:** Write red text to the terminal
* ```typescript
* const writeEmitter = new vscode.EventEmitter<string>();
* const pty: vscode.Pseudoterminal = {
* onDidWrite: writeEmitter.event,
* open: () => writeEmitter.fire('\x1b[31mHello world\x1b[0m'),
* close: () => {}
* };
* vscode.window.createTerminal({ name: 'My terminal', pty });
* ```
*
* **Example:** Move the cursor to the 10th row and 20th column and write an asterisk
* ```typescript
* writeEmitter.fire('\x1b[10;20H*');
* ```
*/
onDidWrite
:
Event
<
string
>
;
/**
* An event that when fired allows overriding the [dimensions](#Terminal.dimensions) of the
* terminal. Note that when set, the overridden dimensions will only take effect when they
* are lower than the actual dimensions of the terminal (ie. there will never be a scroll
* bar). Set to `undefined` for the terminal to go back to the regular dimensions (fit to
* the size of the panel).
*
* **Example:** Override the dimensions of a terminal to 20 columns and 10 rows
* ```typescript
* const dimensionsEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
* const pty: vscode.Pseudoterminal = {
* onDidWrite: writeEmitter.event,
* onDidOverrideDimensions: dimensionsEmitter.event,
* open: () => {
* dimensionsEmitter.fire({
* columns: 20,
* rows: 10
* });
* },
* close: () => {}
* };
* vscode.window.createTerminal({ name: 'My terminal', pty });
* ```
*/
onDidOverrideDimensions
?:
Event
<
TerminalDimensions
|
undefined
>
;
/**
* An event that when fired will signal that the pty is closed and dispose of the terminal.
*
* A number can be used to provide an exit code for the terminal. Exit codes must be
* positive and a non-zero exit codes signals failure which shows a notification for a
* regular terminal and allows dependent tasks to proceed when used with the
* `CustomExecution2` API.
*
* **Example:** Exit the terminal when "y" is pressed, otherwise show a notification.
* ```typescript
* const writeEmitter = new vscode.EventEmitter<string>();
* const closeEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
* const pty: vscode.Pseudoterminal = {
* onDidWrite: writeEmitter.event,
* onDidClose: closeEmitter.event,
* open: () => writeEmitter.fire('Press y to exit successfully'),
* close: () => {},
* handleInput: data => {
* if (data !== 'y') {
* vscode.window.showInformationMessage('Something went wrong');
* }
* closeEmitter.fire();
* }
* };
* vscode.window.createTerminal({ name: 'Exit example', pty });
*/
onDidClose
?:
Event
<
void
|
number
>
;
/**
* Implement to handle when the pty is open and ready to start firing events.
*
* @param initialDimensions The dimensions of the terminal, this will be undefined if the
* terminal panel has not been opened before this is called.
*/
open
(
initialDimensions
:
TerminalDimensions
|
undefined
):
void
;
/**
* Implement to handle when the terminal is closed by an act of the user.
*/
close
():
void
;
/**
* Implement to handle incoming keystrokes in the terminal or when an extension calls
* [Terminal.sendText](#Terminal.sendText). `data` contains the keystrokes/text serialized into
* their corresponding VT sequence representation.
*
* @param data The incoming data.
*
* **Example:** Echo input in the terminal. The sequence for enter (`\r`) is translated to
* CRLF to go to a new line and move the cursor to the start of the line.
* ```typescript
* const writeEmitter = new vscode.EventEmitter<string>();
* const pty: vscode.Pseudoterminal = {
* onDidWrite: writeEmitter.event,
* open: () => {},
* close: () => {},
* handleInput: data => writeEmitter.fire(data === '\r' ? '\r\n' : data)
* };
* vscode.window.createTerminal({ name: 'Local echo', pty });
* ```
*/
handleInput
?(
data
:
string
):
void
;
/**
* Implement to handle when the number of rows and columns that fit into the terminal panel
* changes, for example when font size changes or when the panel is resized. The initial
* state of a terminal's dimensions should be treated as `undefined` until this is triggered
* as the size of a terminal isn't know until it shows up in the user interface.
*
* When dimensions are overridden by
* [onDidOverrideDimensions](#Pseudoterminal.onDidOverrideDimensions), `setDimensions` will
* continue to be called with the regular panel dimensions, allowing the extension continue
* to react dimension changes.
*
* @param dimensions The new dimensions.
*/
setDimensions
?(
dimensions
:
TerminalDimensions
):
void
;
}
//#endregion
//#region Joh -> exclusive document filters
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
afe91207
...
...
@@ -512,7 +512,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
}
return
extHostTerminalService
.
createTerminalFromOptions
(
nameOrOptions
);
}
return
extHostTerminalService
.
createTerminal
(
<
string
>
nameOrOptions
,
shellPath
,
shellArgs
);
return
extHostTerminalService
.
createTerminal
(
nameOrOptions
,
shellPath
,
shellArgs
);
},
registerTreeDataProvider
(
viewId
:
string
,
treeDataProvider
:
vscode
.
TreeDataProvider
<
any
>
):
vscode
.
Disposable
{
return
extHostTreeViews
.
registerTreeDataProvider
(
viewId
,
treeDataProvider
,
extension
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录