1
>
/*---------------------------------------------------------------------------------------------
textModelEvents.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { IPosition } from './core/position.js';
7
>
import { IRange, Range } from './core/range.js';
8
>
import { Selection } from './core/selection.js';
9
>
import { IModelDecoration, InjectedTextOptions } from './model.js';
10
>
import { IModelContentChange } from './model/mirrorTextModel.js';
11
>
import { AnnotationsUpdate } from './model/tokens/annotations.js';
12
>
import { TextModelEditSource } from './textModelEditSource.js';
13
>
14
>
/**
15
>
* An event describing that the current language associated with a model has changed.
16
>
*/
17
>
export interface IModelLanguageChangedEvent {
18
>
/**
19
>
* Previous language
20
>
*/
21
>
readonly oldLanguage: string;
22
>
/**
23
>
* New language
24
>
*/
25
>
readonly newLanguage: string;
26
>
27
>
/**
28
>
* Source of the call that caused the event.
29
>
*/
30
>
readonly source: string;
31
>
}
32
>
33
>
/**
34
>
* An event describing that the language configuration associated with a model has changed.
35
>
*/
36
>
export interface IModelLanguageConfigurationChangedEvent {
37
>
}
38
>
39
>
/**
40
>
* An event describing a change in the text of a model.
41
>
*/
42
>
export interface IModelContentChangedEvent {
43
>
/**
44
>
* The changes are ordered from the end of the document to the beginning, so they should be safe to apply in sequence.
45
>
*/
46
>
readonly changes: IModelContentChange[];
47
>
/**
48
>
* The (new) end-of-line character.
49
>
*/
50
>
readonly eol: string;
51
>
/**
52
>
* The new version id the model has transitioned to.
53
>
*/
54
>
readonly versionId: number;
55
>
/**
56
>
* Flag that indicates that this event was generated while undoing.
57
>
*/
58
>
readonly isUndoing: boolean;
59
>
/**
60
>
* Flag that indicates that this event was generated while redoing.
61
>
*/
62
>
readonly isRedoing: boolean;
63
>
/**
64
>
* Flag that indicates that all decorations were lost with this edit.
65
>
* The model has been reset to a new value.
66
>
*/
67
>
readonly isFlush: boolean;
68
>
69
>
/**
70
>
* Flag that indicates that this event describes an eol change.
71
>
*/
72
>
readonly isEolChange: boolean;
73
>
74
>
/**
75
>
* Detailed reason information for the change
76
>
* @internal
77
>
*/
78
>
readonly detailedReasons: TextModelEditSource[];
79
>
80
>
/**
81
>
* The sum of these lengths equals changes.length.
82
>
* The length of this array must equal the length of detailedReasons.
83
>
*/
84
>
readonly detailedReasonsChangeLengths: number[];
85
>
}
86
>
87
>
export interface ISerializedModelContentChangedEvent {
88
>
/**
89
>
* The changes are ordered from the end of the document to the beginning, so they should be safe to apply in sequence.
90
>
*/
91
>
readonly changes: IModelContentChange[];
92
>
/**
93
>
* The (new) end-of-line character.
94
>
*/
95
>
readonly eol: string;
96
>
/**
97
>
* The new version id the model has transitioned to.
98
>
*/
99
>
readonly versionId: number;
100
>
/**
101
>
* Flag that indicates that this event was generated while undoing.
102
>
*/
103
>
readonly isUndoing: boolean;
104
>
/**
105
>
* Flag that indicates that this event was generated while redoing.
106
>
*/
107
>
readonly isRedoing: boolean;
108
>
/**
109
>
* Flag that indicates that all decorations were lost with this edit.
110
>
* The model has been reset to a new value.
111
>
*/
112
>
readonly isFlush: boolean;
113
>
114
>
/**
115
>
* Flag that indicates that this event describes an eol change.
116
>
*/
117
>
readonly isEolChange: boolean;
118
>
119
>
/**
120
>
* Detailed reason information for the change
121
>
* @internal
122
>
*/
123
>
readonly detailedReason: Record<string, unknown> | undefined;
124
>
}
125
>
126
>
/**
127
>
* An event describing that model decorations have changed.
128
>
*/
129
>
export interface IModelDecorationsChangedEvent {
130
>
readonly affectsMinimap: boolean;
131
>
readonly affectsOverviewRuler: boolean;
132
>
readonly affectsGlyphMargin: boolean;
133
>
readonly affectsLineNumber: boolean;
134
>
}
135
>
136
>
/**
137
>
* An event describing that some ranges of lines have been tokenized (their tokens have changed).
138
>
* @internal
139
>
*/
140
>
export interface IModelTokensChangedEvent {
141
>
readonly semanticTokensApplied: boolean;
142
>
readonly ranges: {
143
>
/**
144
>
* The start of the range (inclusive)
145
>
*/
146
>
readonly fromLineNumber: number;
147
>
/**
148
>
* The end of the range (inclusive)
149
>
*/
150
>
readonly toLineNumber: number;
151
>
}[];
152
>
}
153
>
154
>
/**
155
>
* @internal
156
>
*/
157
>
export interface IFontTokenOption {
158
>
/**
159
>
* Font family of the token.
160
>
*/
161
>
readonly fontFamily?: string;
162
>
/**
163
>
* Font size of the token.
164
>
*/
165
>
readonly fontSizeMultiplier?: number;
166
>
/**
167
>
* Line height of the token.
168
>
*/
169
>
readonly lineHeightMultiplier?: number;
170
>
}
171
>
172
>
/**
173
>
* An event describing a token font change event
174
>
* @internal
175
>
*/
176
>
export interface IModelFontTokensChangedEvent {
177
>
changes: FontTokensUpdate;
178
>
}
179
>
180
>
/**
181
>
* @internal
182
>
*/
183
>
export type FontTokensUpdate = AnnotationsUpdate<IFontTokenOption | undefined>;
184
>
185
>
/**
186
>
* @internal
187
>
*/
188
>
export function serializeFontTokenOptions(): (options: IFontTokenOption) => IFontTokenOption {
189
return (annotation: IFontTokenOption) => {
190
return {