forked from irinazheltisheva/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewEvents.ts
More file actions
304 lines (237 loc) · 7.35 KB
/
Copy pathviewEvents.ts
File metadata and controls
304 lines (237 loc) · 7.35 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ScrollEvent } from 'vs/base/common/scrollable';
import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { ScrollType } from 'vs/editor/common/editorCommon';
import { IModelDecorationsChangedEvent } from 'vs/editor/common/model/textModelEvents';
export const enum ViewEventType {
ViewConfigurationChanged,
ViewCursorStateChanged,
ViewDecorationsChanged,
ViewFlushed,
ViewFocusChanged,
ViewLanguageConfigurationChanged,
ViewLineMappingChanged,
ViewLinesChanged,
ViewLinesDeleted,
ViewLinesInserted,
ViewRevealRangeRequest,
ViewScrollChanged,
ViewThemeChanged,
ViewTokensChanged,
ViewTokensColorsChanged,
ViewZonesChanged,
}
export class ViewConfigurationChangedEvent {
public readonly type = ViewEventType.ViewConfigurationChanged;
public readonly _source: ConfigurationChangedEvent;
constructor(source: ConfigurationChangedEvent) {
this._source = source;
}
public hasChanged(id: EditorOption): boolean {
return this._source.hasChanged(id);
}
}
export class ViewCursorStateChangedEvent {
public readonly type = ViewEventType.ViewCursorStateChanged;
public readonly selections: Selection[];
public readonly modelSelections: Selection[];
constructor(selections: Selection[], modelSelections: Selection[]) {
this.selections = selections;
this.modelSelections = modelSelections;
}
}
export class ViewDecorationsChangedEvent {
public readonly type = ViewEventType.ViewDecorationsChanged;
readonly affectsMinimap: boolean;
readonly affectsOverviewRuler: boolean;
constructor(source: IModelDecorationsChangedEvent | null) {
if (source) {
this.affectsMinimap = source.affectsMinimap;
this.affectsOverviewRuler = source.affectsOverviewRuler;
} else {
this.affectsMinimap = true;
this.affectsOverviewRuler = true;
}
}
}
export class ViewFlushedEvent {
public readonly type = ViewEventType.ViewFlushed;
constructor() {
// Nothing to do
}
}
export class ViewFocusChangedEvent {
public readonly type = ViewEventType.ViewFocusChanged;
public readonly isFocused: boolean;
constructor(isFocused: boolean) {
this.isFocused = isFocused;
}
}
export class ViewLanguageConfigurationEvent {
public readonly type = ViewEventType.ViewLanguageConfigurationChanged;
}
export class ViewLineMappingChangedEvent {
public readonly type = ViewEventType.ViewLineMappingChanged;
constructor() {
// Nothing to do
}
}
export class ViewLinesChangedEvent {
public readonly type = ViewEventType.ViewLinesChanged;
/**
* The first line that has changed.
*/
public readonly fromLineNumber: number;
/**
* The last line that has changed.
*/
public readonly toLineNumber: number;
constructor(fromLineNumber: number, toLineNumber: number) {
this.fromLineNumber = fromLineNumber;
this.toLineNumber = toLineNumber;
}
}
export class ViewLinesDeletedEvent {
public readonly type = ViewEventType.ViewLinesDeleted;
/**
* At what line the deletion began (inclusive).
*/
public readonly fromLineNumber: number;
/**
* At what line the deletion stopped (inclusive).
*/
public readonly toLineNumber: number;
constructor(fromLineNumber: number, toLineNumber: number) {
this.fromLineNumber = fromLineNumber;
this.toLineNumber = toLineNumber;
}
}
export class ViewLinesInsertedEvent {
public readonly type = ViewEventType.ViewLinesInserted;
/**
* Before what line did the insertion begin
*/
public readonly fromLineNumber: number;
/**
* `toLineNumber` - `fromLineNumber` + 1 denotes the number of lines that were inserted
*/
public readonly toLineNumber: number;
constructor(fromLineNumber: number, toLineNumber: number) {
this.fromLineNumber = fromLineNumber;
this.toLineNumber = toLineNumber;
}
}
export const enum VerticalRevealType {
Simple = 0,
Center = 1,
CenterIfOutsideViewport = 2,
Top = 3,
Bottom = 4,
NearTop = 5,
NearTopIfOutsideViewport = 6,
}
export class ViewRevealRangeRequestEvent {
public readonly type = ViewEventType.ViewRevealRangeRequest;
/**
* Range to be reavealed.
*/
public readonly range: Range | null;
/**
* Selections to be revealed.
*/
public readonly selections: Selection[] | null;
public readonly verticalType: VerticalRevealType;
/**
* If true: there should be a horizontal & vertical revealing
* If false: there should be just a vertical revealing
*/
public readonly revealHorizontal: boolean;
public readonly scrollType: ScrollType;
/**
* Source of the call that caused the event.
*/
readonly source: string | null | undefined;
constructor(source: string | null | undefined, range: Range | null, selections: Selection[] | null, verticalType: VerticalRevealType, revealHorizontal: boolean, scrollType: ScrollType) {
this.source = source;
this.range = range;
this.selections = selections;
this.verticalType = verticalType;
this.revealHorizontal = revealHorizontal;
this.scrollType = scrollType;
}
}
export class ViewScrollChangedEvent {
public readonly type = ViewEventType.ViewScrollChanged;
public readonly scrollWidth: number;
public readonly scrollLeft: number;
public readonly scrollHeight: number;
public readonly scrollTop: number;
public readonly scrollWidthChanged: boolean;
public readonly scrollLeftChanged: boolean;
public readonly scrollHeightChanged: boolean;
public readonly scrollTopChanged: boolean;
constructor(source: ScrollEvent) {
this.scrollWidth = source.scrollWidth;
this.scrollLeft = source.scrollLeft;
this.scrollHeight = source.scrollHeight;
this.scrollTop = source.scrollTop;
this.scrollWidthChanged = source.scrollWidthChanged;
this.scrollLeftChanged = source.scrollLeftChanged;
this.scrollHeightChanged = source.scrollHeightChanged;
this.scrollTopChanged = source.scrollTopChanged;
}
}
export class ViewThemeChangedEvent {
public readonly type = ViewEventType.ViewThemeChanged;
}
export class ViewTokensChangedEvent {
public readonly type = ViewEventType.ViewTokensChanged;
public readonly ranges: {
/**
* Start line number of range
*/
readonly fromLineNumber: number;
/**
* End line number of range
*/
readonly toLineNumber: number;
}[];
constructor(ranges: { fromLineNumber: number; toLineNumber: number; }[]) {
this.ranges = ranges;
}
}
export class ViewTokensColorsChangedEvent {
public readonly type = ViewEventType.ViewTokensColorsChanged;
constructor() {
// Nothing to do
}
}
export class ViewZonesChangedEvent {
public readonly type = ViewEventType.ViewZonesChanged;
constructor() {
// Nothing to do
}
}
export type ViewEvent = (
ViewConfigurationChangedEvent
| ViewCursorStateChangedEvent
| ViewDecorationsChangedEvent
| ViewFlushedEvent
| ViewFocusChangedEvent
| ViewLanguageConfigurationEvent
| ViewLineMappingChangedEvent
| ViewLinesChangedEvent
| ViewLinesDeletedEvent
| ViewLinesInsertedEvent
| ViewRevealRangeRequestEvent
| ViewScrollChangedEvent
| ViewThemeChangedEvent
| ViewTokensChangedEvent
| ViewTokensColorsChangedEvent
| ViewZonesChangedEvent
);