forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.ts
More file actions
255 lines (215 loc) · 7.14 KB
/
editor.ts
File metadata and controls
255 lines (215 loc) · 7.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { Event } from 'vs/base/common/event';
export interface IEditorModel {
/**
* Emitted when the model is disposed.
*/
readonly onDispose: Event<void>;
/**
* Loads the model.
*/
load(): Promise<IEditorModel>;
/**
* Dispose associated resources
*/
dispose(): void;
}
export interface IBaseResourceEditorInput {
/**
* Optional options to use when opening the text input.
*/
options?: ITextEditorOptions;
/**
* Label to show for the diff editor
*/
readonly label?: string;
/**
* Description to show for the diff editor
*/
readonly description?: string;
/**
* Hint to indicate that this input should be treated as a file
* that opens in an editor capable of showing file content.
*
* Without this hint, the editor service will make a guess by
* looking at the scheme of the resource(s).
*/
readonly forceFile?: boolean;
/**
* Hint to indicate that this input should be treated as a
* untitled file.
*
* Without this hint, the editor service will make a guess by
* looking at the scheme of the resource(s).
*/
readonly forceUntitled?: boolean;
}
export interface IResourceEditorInput extends IBaseResourceEditorInput {
/**
* The resource URI of the resource to open.
*/
readonly resource: URI;
/**
* The encoding of the text input if known.
*/
readonly encoding?: string;
/**
* The identifier of the language mode of the text input
* if known to use when displaying the contents.
*/
readonly mode?: string;
}
export enum EditorActivation {
/**
* Activate the editor after it opened. This will automatically restore
* the editor if it is minimized.
*/
ACTIVATE,
/**
* Only restore the editor if it is minimized but do not activate it.
*
* Note: will only work in combination with the `preserveFocus: true` option.
* Otherwise, if focus moves into the editor, it will activate and restore
* automatically.
*/
RESTORE,
/**
* Preserve the current active editor.
*
* Note: will only work in combination with the `preserveFocus: true` option.
* Otherwise, if focus moves into the editor, it will activate and restore
* automatically.
*/
PRESERVE
}
export enum EditorOpenContext {
/**
* Default: the editor is opening via a programmatic call
* to the editor service API.
*/
API,
/**
* Indicates that a user action triggered the opening, e.g.
* via mouse or keyboard use.
*/
USER
}
export interface IEditorOptions {
/**
* Tells the editor to not receive keyboard focus when the editor is being opened.
*
* Will also not activate the group the editor opens in unless the group is already
* the active one. This behaviour can be overridden via the `activation` option.
*/
readonly preserveFocus?: boolean;
/**
* This option is only relevant if an editor is opened into a group that is not active
* already and allows to control if the inactive group should become active, restored
* or preserved.
*
* By default, the editor group will become active unless `preserveFocus` or `inactive`
* is specified.
*/
readonly activation?: EditorActivation;
/**
* Tells the editor to reload the editor input in the editor even if it is identical to the one
* already showing. By default, the editor will not reload the input if it is identical to the
* one showing.
*/
readonly forceReload?: boolean;
/**
* Will reveal the editor if it is already opened and visible in any of the opened editor groups.
*
* Note that this option is just a hint that might be ignored if the user wants to open an editor explicitly
* to the side of another one or into a specific editor group.
*/
readonly revealIfVisible?: boolean;
/**
* Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups.
*
* Note that this option is just a hint that might be ignored if the user wants to open an editor explicitly
* to the side of another one or into a specific editor group.
*/
readonly revealIfOpened?: boolean;
/**
* An editor that is pinned remains in the editor stack even when another editor is being opened.
* An editor that is not pinned will always get replaced by another editor that is not pinned.
*/
readonly pinned?: boolean;
/**
* The index in the document stack where to insert the editor into when opening.
*/
readonly index?: number;
/**
* An active editor that is opened will show its contents directly. Set to true to open an editor
* in the background without loading its contents.
*
* Will also not activate the group the editor opens in unless the group is already
* the active one. This behaviour can be overridden via the `activation` option.
*/
readonly inactive?: boolean;
/**
* Will not show an error in case opening the editor fails and thus allows to show a custom error
* message as needed. By default, an error will be presented as notification if opening was not possible.
*/
readonly ignoreError?: boolean;
/**
* Does not use editor overrides while opening the editor
*/
readonly ignoreOverrides?: boolean;
/**
* A optional hint to signal in which context the editor opens.
*
* If configured to be `EditorOpenContext.USER`, this hint can be
* used in various places to control the experience. For example,
* if the editor to open fails with an error, a notification could
* inform about this in a modal dialog. If the editor opened through
* some background task, the notification would show in the background,
* not as a modal dialog.
*/
readonly context?: EditorOpenContext;
}
export interface ITextEditorSelection {
readonly startLineNumber: number;
readonly startColumn: number;
readonly endLineNumber?: number;
readonly endColumn?: number;
}
export const enum TextEditorSelectionRevealType {
/**
* Option to scroll vertically or horizontally as necessary and reveal a range centered vertically.
*/
Center = 0,
/**
* Option to scroll vertically or horizontally as necessary and reveal a range centered vertically only if it lies outside the viewport.
*/
CenterIfOutsideViewport = 1,
/**
* Option to scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport, but not quite at the top.
*/
NearTop = 2,
/**
* Option to scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport, but not quite at the top.
* Only if it lies outside the viewport
*/
NearTopIfOutsideViewport = 3,
}
export interface ITextEditorOptions extends IEditorOptions {
/**
* Text editor selection.
*/
readonly selection?: ITextEditorSelection;
/**
* Text editor view state.
*/
readonly viewState?: object;
/**
* Option to control the text editor selection reveal type.
* Defaults to TextEditorSelectionRevealType.Center
*/
readonly selectionRevealType?: TextEditorSelectionRevealType;
}