Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/common/cursorEvents.ts
3292 views
1
/*---------------------------------------------------------------------------------------------
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 { Position } from './core/position.js';
7
import { Selection } from './core/selection.js';
8
9
/**
10
* Describes the reason the cursor has changed its position.
11
*/
12
export const enum CursorChangeReason {
13
/**
14
* Unknown or not set.
15
*/
16
NotSet = 0,
17
/**
18
* A `model.setValue()` was called.
19
*/
20
ContentFlush = 1,
21
/**
22
* The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers.
23
*/
24
RecoverFromMarkers = 2,
25
/**
26
* There was an explicit user gesture.
27
*/
28
Explicit = 3,
29
/**
30
* There was a Paste.
31
*/
32
Paste = 4,
33
/**
34
* There was an Undo.
35
*/
36
Undo = 5,
37
/**
38
* There was a Redo.
39
*/
40
Redo = 6,
41
}
42
/**
43
* An event describing that the cursor position has changed.
44
*/
45
export interface ICursorPositionChangedEvent {
46
/**
47
* Primary cursor's position.
48
*/
49
readonly position: Position;
50
/**
51
* Secondary cursors' position.
52
*/
53
readonly secondaryPositions: Position[];
54
/**
55
* Reason.
56
*/
57
readonly reason: CursorChangeReason;
58
/**
59
* Source of the call that caused the event.
60
*/
61
readonly source: string;
62
}
63
/**
64
* An event describing that the cursor selection has changed.
65
*/
66
export interface ICursorSelectionChangedEvent {
67
/**
68
* The primary selection.
69
*/
70
readonly selection: Selection;
71
/**
72
* The secondary selections.
73
*/
74
readonly secondarySelections: Selection[];
75
/**
76
* The model version id.
77
*/
78
readonly modelVersionId: number;
79
/**
80
* The old selections.
81
*/
82
readonly oldSelections: Selection[] | null;
83
/**
84
* The model version id the that `oldSelections` refer to.
85
*/
86
readonly oldModelVersionId: number;
87
/**
88
* Source of the call that caused the event.
89
*/
90
readonly source: string;
91
/**
92
* Reason.
93
*/
94
readonly reason: CursorChangeReason;
95
}
96
97