Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.ts
3296 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 { Emitter } from '../../../../../base/common/event.js';
7
import { Disposable } from '../../../../../base/common/lifecycle.js';
8
import { IDiffElementLayoutInfo } from './notebookDiffEditorBrowser.js';
9
import { NotebookLayoutChangeEvent, NotebookLayoutInfo } from '../notebookViewEvents.js';
10
11
export enum NotebookDiffViewEventType {
12
LayoutChanged = 1,
13
CellLayoutChanged = 2
14
// MetadataChanged = 2,
15
// CellStateChanged = 3
16
}
17
18
export class NotebookDiffLayoutChangedEvent {
19
public readonly type = NotebookDiffViewEventType.LayoutChanged;
20
21
constructor(readonly source: NotebookLayoutChangeEvent, readonly value: NotebookLayoutInfo) {
22
23
}
24
}
25
26
export class NotebookCellLayoutChangedEvent {
27
public readonly type = NotebookDiffViewEventType.CellLayoutChanged;
28
29
constructor(readonly source: IDiffElementLayoutInfo) {
30
31
}
32
}
33
34
export type NotebookDiffViewEvent = NotebookDiffLayoutChangedEvent | NotebookCellLayoutChangedEvent;
35
36
export class NotebookDiffEditorEventDispatcher extends Disposable {
37
protected readonly _onDidChangeLayout = this._register(new Emitter<NotebookDiffLayoutChangedEvent>());
38
readonly onDidChangeLayout = this._onDidChangeLayout.event;
39
40
protected readonly _onDidChangeCellLayout = this._register(new Emitter<NotebookCellLayoutChangedEvent>());
41
readonly onDidChangeCellLayout = this._onDidChangeCellLayout.event;
42
43
emit(events: NotebookDiffViewEvent[]) {
44
for (let i = 0, len = events.length; i < len; i++) {
45
const e = events[i];
46
47
switch (e.type) {
48
case NotebookDiffViewEventType.LayoutChanged:
49
this._onDidChangeLayout.fire(e);
50
break;
51
case NotebookDiffViewEventType.CellLayoutChanged:
52
this._onDidChangeCellLayout.fire(e);
53
break;
54
}
55
}
56
}
57
}
58
59