@xterm/xterm 5.6.0-beta.8 → 5.6.0-beta.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/css/xterm.css +71 -4
- package/lib/xterm.js +1 -1
- package/lib/xterm.js.map +1 -1
- package/lib/xterm.mjs +53 -0
- package/lib/xterm.mjs.map +7 -0
- package/package.json +43 -33
- package/src/browser/AccessibilityManager.ts +53 -25
- package/src/browser/{Terminal.ts → CoreBrowserTerminal.ts} +139 -148
- package/src/browser/Linkifier.ts +26 -14
- package/src/browser/LocalizableStrings.ts +15 -4
- package/src/browser/{Types.d.ts → Types.ts} +67 -15
- package/src/browser/Viewport.ts +143 -370
- package/src/browser/decorations/BufferDecorationRenderer.ts +14 -9
- package/src/browser/decorations/OverviewRulerRenderer.ts +40 -44
- package/src/browser/public/Terminal.ts +25 -19
- package/src/browser/renderer/dom/DomRenderer.ts +22 -19
- package/src/browser/renderer/dom/DomRendererRowFactory.ts +35 -15
- package/src/browser/renderer/shared/CharAtlasUtils.ts +4 -0
- package/src/browser/renderer/shared/CustomGlyphs.ts +6 -0
- package/src/browser/renderer/shared/DevicePixelObserver.ts +1 -2
- package/src/browser/renderer/shared/TextureAtlas.ts +3 -3
- package/src/browser/renderer/shared/{Types.d.ts → Types.ts} +4 -4
- package/src/browser/services/CharSizeService.ts +6 -6
- package/src/browser/services/CoreBrowserService.ts +15 -15
- package/src/browser/services/LinkProviderService.ts +2 -2
- package/src/browser/services/RenderService.ts +20 -20
- package/src/browser/services/SelectionService.ts +8 -8
- package/src/browser/services/Services.ts +13 -13
- package/src/browser/services/ThemeService.ts +19 -58
- package/src/browser/shared/Constants.ts +8 -0
- package/src/common/CircularList.ts +5 -5
- package/src/common/CoreTerminal.ts +35 -41
- package/src/common/InputHandler.ts +63 -51
- package/src/common/{Types.d.ts → Types.ts} +13 -17
- package/src/common/buffer/Buffer.ts +15 -7
- package/src/common/buffer/BufferReflow.ts +9 -6
- package/src/common/buffer/BufferSet.ts +5 -5
- package/src/common/buffer/Marker.ts +4 -4
- package/src/common/buffer/{Types.d.ts → Types.ts} +2 -2
- package/src/common/input/WriteBuffer.ts +3 -3
- package/src/common/parser/EscapeSequenceParser.ts +4 -4
- package/src/common/public/BufferNamespaceApi.ts +3 -3
- package/src/common/services/BufferService.ts +7 -7
- package/src/common/services/CoreMouseService.ts +5 -3
- package/src/common/services/CoreService.ts +8 -6
- package/src/common/services/DecorationService.ts +8 -9
- package/src/common/services/InstantiationService.ts +1 -1
- package/src/common/services/LogService.ts +2 -2
- package/src/common/services/OptionsService.ts +6 -5
- package/src/common/services/ServiceRegistry.ts +1 -1
- package/src/common/services/Services.ts +26 -17
- package/src/common/services/UnicodeService.ts +2 -2
- package/src/vs/base/browser/browser.ts +141 -0
- package/src/vs/base/browser/canIUse.ts +49 -0
- package/src/vs/base/browser/dom.ts +2369 -0
- package/src/vs/base/browser/fastDomNode.ts +316 -0
- package/src/vs/base/browser/globalPointerMoveMonitor.ts +112 -0
- package/src/vs/base/browser/iframe.ts +135 -0
- package/src/vs/base/browser/keyboardEvent.ts +213 -0
- package/src/vs/base/browser/mouseEvent.ts +229 -0
- package/src/vs/base/browser/touch.ts +372 -0
- package/src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts +303 -0
- package/src/vs/base/browser/ui/scrollbar/horizontalScrollbar.ts +114 -0
- package/src/vs/base/browser/ui/scrollbar/scrollableElement.ts +720 -0
- package/src/vs/base/browser/ui/scrollbar/scrollableElementOptions.ts +165 -0
- package/src/vs/base/browser/ui/scrollbar/scrollbarArrow.ts +114 -0
- package/src/vs/base/browser/ui/scrollbar/scrollbarState.ts +243 -0
- package/src/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.ts +118 -0
- package/src/vs/base/browser/ui/scrollbar/verticalScrollbar.ts +116 -0
- package/src/vs/base/browser/ui/widget.ts +57 -0
- package/src/vs/base/browser/window.ts +14 -0
- package/src/vs/base/common/arrays.ts +887 -0
- package/src/vs/base/common/arraysFind.ts +202 -0
- package/src/vs/base/common/assert.ts +71 -0
- package/src/vs/base/common/async.ts +1992 -0
- package/src/vs/base/common/cancellation.ts +148 -0
- package/src/vs/base/common/charCode.ts +450 -0
- package/src/vs/base/common/collections.ts +140 -0
- package/src/vs/base/common/decorators.ts +130 -0
- package/src/vs/base/common/equals.ts +146 -0
- package/src/vs/base/common/errors.ts +303 -0
- package/src/vs/base/common/event.ts +1778 -0
- package/src/vs/base/common/functional.ts +32 -0
- package/src/vs/base/common/hash.ts +316 -0
- package/src/vs/base/common/iterator.ts +159 -0
- package/src/vs/base/common/keyCodes.ts +526 -0
- package/src/vs/base/common/keybindings.ts +284 -0
- package/src/vs/base/common/lazy.ts +47 -0
- package/src/vs/base/common/lifecycle.ts +801 -0
- package/src/vs/base/common/linkedList.ts +142 -0
- package/src/vs/base/common/map.ts +202 -0
- package/src/vs/base/common/numbers.ts +98 -0
- package/src/vs/base/common/observable.ts +76 -0
- package/src/vs/base/common/observableInternal/api.ts +31 -0
- package/src/vs/base/common/observableInternal/autorun.ts +281 -0
- package/src/vs/base/common/observableInternal/base.ts +489 -0
- package/src/vs/base/common/observableInternal/debugName.ts +145 -0
- package/src/vs/base/common/observableInternal/derived.ts +428 -0
- package/src/vs/base/common/observableInternal/lazyObservableValue.ts +146 -0
- package/src/vs/base/common/observableInternal/logging.ts +328 -0
- package/src/vs/base/common/observableInternal/promise.ts +209 -0
- package/src/vs/base/common/observableInternal/utils.ts +610 -0
- package/src/vs/base/common/platform.ts +281 -0
- package/src/vs/base/common/scrollable.ts +522 -0
- package/src/vs/base/common/sequence.ts +34 -0
- package/src/vs/base/common/stopwatch.ts +43 -0
- package/src/vs/base/common/strings.ts +557 -0
- package/src/vs/base/common/symbols.ts +9 -0
- package/src/vs/base/common/uint.ts +59 -0
- package/src/vs/patches/nls.ts +90 -0
- package/src/vs/typings/base-common.d.ts +20 -0
- package/src/vs/typings/require.d.ts +42 -0
- package/src/vs/typings/thenable.d.ts +12 -0
- package/src/vs/typings/vscode-globals-nls.d.ts +36 -0
- package/src/vs/typings/vscode-globals-product.d.ts +33 -0
- package/typings/xterm.d.ts +66 -15
- package/src/browser/Lifecycle.ts +0 -33
- package/src/common/EventEmitter.ts +0 -78
- package/src/common/Lifecycle.ts +0 -108
- /package/src/browser/selection/{Types.d.ts → Types.ts} +0 -0
- /package/src/common/parser/{Types.d.ts → Types.ts} +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
class Node<E> {
|
|
7
|
+
|
|
8
|
+
static readonly Undefined = new Node<any>(undefined);
|
|
9
|
+
|
|
10
|
+
element: E;
|
|
11
|
+
next: Node<E>;
|
|
12
|
+
prev: Node<E>;
|
|
13
|
+
|
|
14
|
+
constructor(element: E) {
|
|
15
|
+
this.element = element;
|
|
16
|
+
this.next = Node.Undefined;
|
|
17
|
+
this.prev = Node.Undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class LinkedList<E> {
|
|
22
|
+
|
|
23
|
+
private _first: Node<E> = Node.Undefined;
|
|
24
|
+
private _last: Node<E> = Node.Undefined;
|
|
25
|
+
private _size: number = 0;
|
|
26
|
+
|
|
27
|
+
get size(): number {
|
|
28
|
+
return this._size;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
isEmpty(): boolean {
|
|
32
|
+
return this._first === Node.Undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
clear(): void {
|
|
36
|
+
let node = this._first;
|
|
37
|
+
while (node !== Node.Undefined) {
|
|
38
|
+
const next = node.next;
|
|
39
|
+
node.prev = Node.Undefined;
|
|
40
|
+
node.next = Node.Undefined;
|
|
41
|
+
node = next;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this._first = Node.Undefined;
|
|
45
|
+
this._last = Node.Undefined;
|
|
46
|
+
this._size = 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
unshift(element: E): () => void {
|
|
50
|
+
return this._insert(element, false);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
push(element: E): () => void {
|
|
54
|
+
return this._insert(element, true);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private _insert(element: E, atTheEnd: boolean): () => void {
|
|
58
|
+
const newNode = new Node(element);
|
|
59
|
+
if (this._first === Node.Undefined) {
|
|
60
|
+
this._first = newNode;
|
|
61
|
+
this._last = newNode;
|
|
62
|
+
|
|
63
|
+
} else if (atTheEnd) {
|
|
64
|
+
// push
|
|
65
|
+
const oldLast = this._last;
|
|
66
|
+
this._last = newNode;
|
|
67
|
+
newNode.prev = oldLast;
|
|
68
|
+
oldLast.next = newNode;
|
|
69
|
+
|
|
70
|
+
} else {
|
|
71
|
+
// unshift
|
|
72
|
+
const oldFirst = this._first;
|
|
73
|
+
this._first = newNode;
|
|
74
|
+
newNode.next = oldFirst;
|
|
75
|
+
oldFirst.prev = newNode;
|
|
76
|
+
}
|
|
77
|
+
this._size += 1;
|
|
78
|
+
|
|
79
|
+
let didRemove = false;
|
|
80
|
+
return () => {
|
|
81
|
+
if (!didRemove) {
|
|
82
|
+
didRemove = true;
|
|
83
|
+
this._remove(newNode);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
shift(): E | undefined {
|
|
89
|
+
if (this._first === Node.Undefined) {
|
|
90
|
+
return undefined;
|
|
91
|
+
} else {
|
|
92
|
+
const res = this._first.element;
|
|
93
|
+
this._remove(this._first);
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
pop(): E | undefined {
|
|
99
|
+
if (this._last === Node.Undefined) {
|
|
100
|
+
return undefined;
|
|
101
|
+
} else {
|
|
102
|
+
const res = this._last.element;
|
|
103
|
+
this._remove(this._last);
|
|
104
|
+
return res;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private _remove(node: Node<E>): void {
|
|
109
|
+
if (node.prev !== Node.Undefined && node.next !== Node.Undefined) {
|
|
110
|
+
// middle
|
|
111
|
+
const anchor = node.prev;
|
|
112
|
+
anchor.next = node.next;
|
|
113
|
+
node.next.prev = anchor;
|
|
114
|
+
|
|
115
|
+
} else if (node.prev === Node.Undefined && node.next === Node.Undefined) {
|
|
116
|
+
// only node
|
|
117
|
+
this._first = Node.Undefined;
|
|
118
|
+
this._last = Node.Undefined;
|
|
119
|
+
|
|
120
|
+
} else if (node.next === Node.Undefined) {
|
|
121
|
+
// last
|
|
122
|
+
this._last = this._last.prev!;
|
|
123
|
+
this._last.next = Node.Undefined;
|
|
124
|
+
|
|
125
|
+
} else if (node.prev === Node.Undefined) {
|
|
126
|
+
// first
|
|
127
|
+
this._first = this._first.next!;
|
|
128
|
+
this._first.prev = Node.Undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// done
|
|
132
|
+
this._size -= 1;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
*[Symbol.iterator](): Iterator<E> {
|
|
136
|
+
let node = this._first;
|
|
137
|
+
while (node !== Node.Undefined) {
|
|
138
|
+
yield node.element;
|
|
139
|
+
node = node.next;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
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
|
+
export function getOrSet<K, V>(map: Map<K, V>, key: K, value: V): V {
|
|
7
|
+
let result = map.get(key);
|
|
8
|
+
if (result === undefined) {
|
|
9
|
+
result = value;
|
|
10
|
+
map.set(key, result);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function mapToString<K, V>(map: Map<K, V>): string {
|
|
17
|
+
const entries: string[] = [];
|
|
18
|
+
map.forEach((value, key) => {
|
|
19
|
+
entries.push(`${key} => ${value}`);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return `Map(${map.size}) {${entries.join(', ')}}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function setToString<K>(set: Set<K>): string {
|
|
26
|
+
const entries: K[] = [];
|
|
27
|
+
set.forEach(value => {
|
|
28
|
+
entries.push(value);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return `Set(${set.size}) {${entries.join(', ')}}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const enum Touch {
|
|
35
|
+
None = 0,
|
|
36
|
+
AsOld = 1,
|
|
37
|
+
AsNew = 2
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class CounterSet<T> {
|
|
41
|
+
|
|
42
|
+
private map = new Map<T, number>();
|
|
43
|
+
|
|
44
|
+
add(value: T): CounterSet<T> {
|
|
45
|
+
this.map.set(value, (this.map.get(value) || 0) + 1);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
delete(value: T): boolean {
|
|
50
|
+
let counter = this.map.get(value) || 0;
|
|
51
|
+
|
|
52
|
+
if (counter === 0) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
counter--;
|
|
57
|
+
|
|
58
|
+
if (counter === 0) {
|
|
59
|
+
this.map.delete(value);
|
|
60
|
+
} else {
|
|
61
|
+
this.map.set(value, counter);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
has(value: T): boolean {
|
|
68
|
+
return this.map.has(value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A map that allows access both by keys and values.
|
|
74
|
+
* **NOTE**: values need to be unique.
|
|
75
|
+
*/
|
|
76
|
+
export class BidirectionalMap<K, V> {
|
|
77
|
+
|
|
78
|
+
private readonly _m1 = new Map<K, V>();
|
|
79
|
+
private readonly _m2 = new Map<V, K>();
|
|
80
|
+
|
|
81
|
+
constructor(entries?: readonly (readonly [K, V])[]) {
|
|
82
|
+
if (entries) {
|
|
83
|
+
for (const [key, value] of entries) {
|
|
84
|
+
this.set(key, value);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
clear(): void {
|
|
90
|
+
this._m1.clear();
|
|
91
|
+
this._m2.clear();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
set(key: K, value: V): void {
|
|
95
|
+
this._m1.set(key, value);
|
|
96
|
+
this._m2.set(value, key);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get(key: K): V | undefined {
|
|
100
|
+
return this._m1.get(key);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getKey(value: V): K | undefined {
|
|
104
|
+
return this._m2.get(value);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
delete(key: K): boolean {
|
|
108
|
+
const value = this._m1.get(key);
|
|
109
|
+
if (value === undefined) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
this._m1.delete(key);
|
|
113
|
+
this._m2.delete(value);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
forEach(callbackfn: (value: V, key: K, map: BidirectionalMap<K, V>) => void, thisArg?: any): void {
|
|
118
|
+
this._m1.forEach((value, key) => {
|
|
119
|
+
callbackfn.call(thisArg, value, key, this);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
keys(): IterableIterator<K> {
|
|
124
|
+
return this._m1.keys();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
values(): IterableIterator<V> {
|
|
128
|
+
return this._m1.values();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export class SetMap<K, V> {
|
|
133
|
+
|
|
134
|
+
private map = new Map<K, Set<V>>();
|
|
135
|
+
|
|
136
|
+
add(key: K, value: V): void {
|
|
137
|
+
let values = this.map.get(key);
|
|
138
|
+
|
|
139
|
+
if (!values) {
|
|
140
|
+
values = new Set<V>();
|
|
141
|
+
this.map.set(key, values);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
values.add(value);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
delete(key: K, value: V): void {
|
|
148
|
+
const values = this.map.get(key);
|
|
149
|
+
|
|
150
|
+
if (!values) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
values.delete(value);
|
|
155
|
+
|
|
156
|
+
if (values.size === 0) {
|
|
157
|
+
this.map.delete(key);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
forEach(key: K, fn: (value: V) => void): void {
|
|
162
|
+
const values = this.map.get(key);
|
|
163
|
+
|
|
164
|
+
if (!values) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
values.forEach(fn);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
get(key: K): ReadonlySet<V> {
|
|
172
|
+
const values = this.map.get(key);
|
|
173
|
+
if (!values) {
|
|
174
|
+
return new Set<V>();
|
|
175
|
+
}
|
|
176
|
+
return values;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function mapsStrictEqualIgnoreOrder(a: Map<unknown, unknown>, b: Map<unknown, unknown>): boolean {
|
|
181
|
+
if (a === b) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (a.size !== b.size) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
for (const [key, value] of a) {
|
|
190
|
+
if (!b.has(key) || b.get(key) !== value) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
for (const [key] of b) {
|
|
196
|
+
if (!a.has(key)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
export function clamp(value: number, min: number, max: number): number {
|
|
7
|
+
return Math.min(Math.max(value, min), max);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function rot(index: number, modulo: number): number {
|
|
11
|
+
return (modulo + (index % modulo)) % modulo;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Counter {
|
|
15
|
+
private _next = 0;
|
|
16
|
+
|
|
17
|
+
getNext(): number {
|
|
18
|
+
return this._next++;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class MovingAverage {
|
|
23
|
+
|
|
24
|
+
private _n = 1;
|
|
25
|
+
private _val = 0;
|
|
26
|
+
|
|
27
|
+
update(value: number): number {
|
|
28
|
+
this._val = this._val + (value - this._val) / this._n;
|
|
29
|
+
this._n += 1;
|
|
30
|
+
return this._val;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get value(): number {
|
|
34
|
+
return this._val;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class SlidingWindowAverage {
|
|
39
|
+
|
|
40
|
+
private _n: number = 0;
|
|
41
|
+
private _val = 0;
|
|
42
|
+
|
|
43
|
+
private readonly _values: number[] = [];
|
|
44
|
+
private _index: number = 0;
|
|
45
|
+
private _sum = 0;
|
|
46
|
+
|
|
47
|
+
constructor(size: number) {
|
|
48
|
+
this._values = new Array(size);
|
|
49
|
+
this._values.fill(0, 0, size);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
update(value: number): number {
|
|
53
|
+
const oldValue = this._values[this._index];
|
|
54
|
+
this._values[this._index] = value;
|
|
55
|
+
this._index = (this._index + 1) % this._values.length;
|
|
56
|
+
|
|
57
|
+
this._sum -= oldValue;
|
|
58
|
+
this._sum += value;
|
|
59
|
+
|
|
60
|
+
if (this._n < this._values.length) {
|
|
61
|
+
this._n += 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this._val = this._sum / this._n;
|
|
65
|
+
return this._val;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get value(): number {
|
|
69
|
+
return this._val;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Returns whether the point is within the triangle formed by the following 6 x/y point pairs */
|
|
74
|
+
export function isPointWithinTriangle(
|
|
75
|
+
x: number, y: number,
|
|
76
|
+
ax: number, ay: number,
|
|
77
|
+
bx: number, by: number,
|
|
78
|
+
cx: number, cy: number
|
|
79
|
+
) {
|
|
80
|
+
const v0x = cx - ax;
|
|
81
|
+
const v0y = cy - ay;
|
|
82
|
+
const v1x = bx - ax;
|
|
83
|
+
const v1y = by - ay;
|
|
84
|
+
const v2x = x - ax;
|
|
85
|
+
const v2y = y - ay;
|
|
86
|
+
|
|
87
|
+
const dot00 = v0x * v0x + v0y * v0y;
|
|
88
|
+
const dot01 = v0x * v1x + v0y * v1y;
|
|
89
|
+
const dot02 = v0x * v2x + v0y * v2y;
|
|
90
|
+
const dot11 = v1x * v1x + v1y * v1y;
|
|
91
|
+
const dot12 = v1x * v2x + v1y * v2y;
|
|
92
|
+
|
|
93
|
+
const invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
|
|
94
|
+
const u = (dot11 * dot02 - dot01 * dot12) * invDenom;
|
|
95
|
+
const v = (dot00 * dot12 - dot01 * dot02) * invDenom;
|
|
96
|
+
|
|
97
|
+
return u >= 0 && v >= 0 && u + v < 1;
|
|
98
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
// This is a facade for the observable implementation. Only import from here!
|
|
7
|
+
|
|
8
|
+
export type {
|
|
9
|
+
IObservable,
|
|
10
|
+
IObserver,
|
|
11
|
+
IReader,
|
|
12
|
+
ISettable,
|
|
13
|
+
ISettableObservable,
|
|
14
|
+
ITransaction,
|
|
15
|
+
IChangeContext,
|
|
16
|
+
IChangeTracker,
|
|
17
|
+
} from 'vs/base/common/observableInternal/base';
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
observableValue,
|
|
21
|
+
disposableObservableValue,
|
|
22
|
+
transaction,
|
|
23
|
+
subtransaction,
|
|
24
|
+
} from 'vs/base/common/observableInternal/base';
|
|
25
|
+
export {
|
|
26
|
+
derived,
|
|
27
|
+
derivedOpts,
|
|
28
|
+
derivedHandleChanges,
|
|
29
|
+
derivedWithStore,
|
|
30
|
+
} from 'vs/base/common/observableInternal/derived';
|
|
31
|
+
export {
|
|
32
|
+
autorun,
|
|
33
|
+
autorunDelta,
|
|
34
|
+
autorunHandleChanges,
|
|
35
|
+
autorunWithStore,
|
|
36
|
+
autorunOpts,
|
|
37
|
+
autorunWithStoreHandleChanges,
|
|
38
|
+
} from 'vs/base/common/observableInternal/autorun';
|
|
39
|
+
export type {
|
|
40
|
+
IObservableSignal,
|
|
41
|
+
} from 'vs/base/common/observableInternal/utils';
|
|
42
|
+
export {
|
|
43
|
+
constObservable,
|
|
44
|
+
debouncedObservable,
|
|
45
|
+
derivedObservableWithCache,
|
|
46
|
+
derivedObservableWithWritableCache,
|
|
47
|
+
keepObserved,
|
|
48
|
+
recomputeInitiallyAndOnChange,
|
|
49
|
+
observableFromEvent,
|
|
50
|
+
observableFromPromise,
|
|
51
|
+
observableSignal,
|
|
52
|
+
observableSignalFromEvent,
|
|
53
|
+
wasEventTriggeredRecently,
|
|
54
|
+
} from 'vs/base/common/observableInternal/utils';
|
|
55
|
+
export {
|
|
56
|
+
ObservableLazy,
|
|
57
|
+
ObservableLazyPromise,
|
|
58
|
+
ObservablePromise,
|
|
59
|
+
PromiseResult,
|
|
60
|
+
waitForState,
|
|
61
|
+
derivedWithCancellationToken,
|
|
62
|
+
} from 'vs/base/common/observableInternal/promise';
|
|
63
|
+
export {
|
|
64
|
+
observableValueOpts
|
|
65
|
+
} from 'vs/base/common/observableInternal/api';
|
|
66
|
+
|
|
67
|
+
import { ConsoleObservableLogger, setLogger } from 'vs/base/common/observableInternal/logging';
|
|
68
|
+
|
|
69
|
+
// Remove "//" in the next line to enable logging
|
|
70
|
+
const enableLogging = false
|
|
71
|
+
// || Boolean("true") // done "weirdly" so that a lint warning prevents you from pushing this
|
|
72
|
+
;
|
|
73
|
+
|
|
74
|
+
if (enableLogging) {
|
|
75
|
+
setLogger(new ConsoleObservableLogger());
|
|
76
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { EqualityComparer, strictEquals } from 'vs/base/common/equals';
|
|
7
|
+
import { ISettableObservable } from 'vs/base/common/observable';
|
|
8
|
+
import { ObservableValue } from 'vs/base/common/observableInternal/base';
|
|
9
|
+
import { IDebugNameData, DebugNameData } from 'vs/base/common/observableInternal/debugName';
|
|
10
|
+
import { LazyObservableValue } from 'vs/base/common/observableInternal/lazyObservableValue';
|
|
11
|
+
|
|
12
|
+
export function observableValueOpts<T, TChange = void>(
|
|
13
|
+
options: IDebugNameData & {
|
|
14
|
+
equalsFn?: EqualityComparer<T>;
|
|
15
|
+
lazy?: boolean;
|
|
16
|
+
},
|
|
17
|
+
initialValue: T
|
|
18
|
+
): ISettableObservable<T, TChange> {
|
|
19
|
+
if (options.lazy) {
|
|
20
|
+
return new LazyObservableValue(
|
|
21
|
+
new DebugNameData(options.owner, options.debugName, undefined),
|
|
22
|
+
initialValue,
|
|
23
|
+
options.equalsFn ?? strictEquals,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return new ObservableValue(
|
|
27
|
+
new DebugNameData(options.owner, options.debugName, undefined),
|
|
28
|
+
initialValue,
|
|
29
|
+
options.equalsFn ?? strictEquals,
|
|
30
|
+
);
|
|
31
|
+
}
|