@theia/editor 1.45.0 → 1.46.0-next.72
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 +30 -30
- package/lib/browser/decorations/editor-decoration-style.d.ts +8 -8
- package/lib/browser/decorations/editor-decoration-style.js +36 -36
- package/lib/browser/decorations/editor-decoration.d.ts +106 -106
- package/lib/browser/decorations/editor-decoration.js +37 -37
- package/lib/browser/decorations/editor-decorator.d.ts +6 -6
- package/lib/browser/decorations/editor-decorator.js +43 -43
- package/lib/browser/decorations/index.d.ts +3 -3
- package/lib/browser/decorations/index.js +30 -30
- package/lib/browser/diff-navigator.d.ts +9 -10
- package/lib/browser/diff-navigator.d.ts.map +1 -1
- package/lib/browser/diff-navigator.js +19 -19
- package/lib/browser/diff-navigator.js.map +1 -1
- package/lib/browser/editor-command.d.ts +102 -102
- package/lib/browser/editor-command.js +426 -426
- package/lib/browser/editor-contribution.d.ts +26 -26
- package/lib/browser/editor-contribution.js +198 -198
- package/lib/browser/editor-frontend-module.d.ts +5 -5
- package/lib/browser/editor-frontend-module.js +74 -74
- package/lib/browser/editor-generated-preference-schema.d.ts +282 -249
- package/lib/browser/editor-generated-preference-schema.d.ts.map +1 -1
- package/lib/browser/editor-generated-preference-schema.js +2451 -2316
- package/lib/browser/editor-generated-preference-schema.js.map +1 -1
- package/lib/browser/editor-keybinding.d.ts +5 -5
- package/lib/browser/editor-keybinding.js +55 -55
- package/lib/browser/editor-linenumber-contribution.d.ts +15 -15
- package/lib/browser/editor-linenumber-contribution.d.ts.map +1 -1
- package/lib/browser/editor-linenumber-contribution.js +95 -96
- package/lib/browser/editor-linenumber-contribution.js.map +1 -1
- package/lib/browser/editor-manager.d.ts +115 -115
- package/lib/browser/editor-manager.js +428 -428
- package/lib/browser/editor-menu.d.ts +48 -48
- package/lib/browser/editor-menu.js +210 -210
- package/lib/browser/editor-navigation-contribution.d.ts +67 -67
- package/lib/browser/editor-navigation-contribution.js +343 -343
- package/lib/browser/editor-preferences.d.ts +41 -41
- package/lib/browser/editor-preferences.js +176 -176
- package/lib/browser/editor-variable-contribution.d.ts +8 -8
- package/lib/browser/editor-variable-contribution.js +64 -64
- package/lib/browser/editor-widget-factory.d.ts +17 -17
- package/lib/browser/editor-widget-factory.js +91 -91
- package/lib/browser/editor-widget.d.ts +24 -24
- package/lib/browser/editor-widget.d.ts.map +1 -1
- package/lib/browser/editor-widget.js +122 -114
- package/lib/browser/editor-widget.js.map +1 -1
- package/lib/browser/editor.d.ts +295 -293
- package/lib/browser/editor.d.ts.map +1 -1
- package/lib/browser/editor.js +103 -103
- package/lib/browser/editor.js.map +1 -1
- package/lib/browser/index.d.ts +10 -10
- package/lib/browser/index.js +37 -37
- package/lib/browser/language-status/editor-language-status-service.d.ts +77 -77
- package/lib/browser/language-status/editor-language-status-service.js +251 -251
- package/lib/browser/navigation/navigation-location-service.d.ts +103 -103
- package/lib/browser/navigation/navigation-location-service.js +281 -281
- package/lib/browser/navigation/navigation-location-service.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-service.spec.js +184 -184
- package/lib/browser/navigation/navigation-location-similarity.d.ts +15 -15
- package/lib/browser/navigation/navigation-location-similarity.js +62 -62
- package/lib/browser/navigation/navigation-location-similarity.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-similarity.spec.js +32 -32
- package/lib/browser/navigation/navigation-location-updater.d.ts +35 -35
- package/lib/browser/navigation/navigation-location-updater.js +210 -210
- package/lib/browser/navigation/navigation-location-updater.spec.d.ts +1 -1
- package/lib/browser/navigation/navigation-location-updater.spec.js +177 -177
- package/lib/browser/navigation/navigation-location.d.ts +191 -191
- package/lib/browser/navigation/navigation-location.js +300 -300
- package/lib/browser/navigation/test/mock-navigation-location-updater.d.ts +15 -15
- package/lib/browser/navigation/test/mock-navigation-location-updater.js +38 -38
- package/lib/browser/quick-editor-service.d.ts +16 -16
- package/lib/browser/quick-editor-service.js +109 -109
- package/lib/browser/undo-redo-service.d.ts +23 -23
- package/lib/browser/undo-redo-service.js +110 -110
- package/lib/common/language-selector.d.ts +13 -13
- package/lib/common/language-selector.js +90 -90
- package/lib/package.spec.js +25 -25
- package/package.json +5 -5
- package/src/browser/decorations/editor-decoration-style.ts +41 -41
- package/src/browser/decorations/editor-decoration.ts +127 -127
- package/src/browser/decorations/editor-decorator.ts +36 -36
- package/src/browser/decorations/index.ts +19 -19
- package/src/browser/diff-navigator.ts +27 -28
- package/src/browser/editor-command.ts +414 -414
- package/src/browser/editor-contribution.ts +185 -185
- package/src/browser/editor-frontend-module.ts +87 -87
- package/src/browser/editor-generated-preference-schema.ts +2707 -2539
- package/src/browser/editor-keybinding.ts +55 -55
- package/src/browser/editor-linenumber-contribution.ts +88 -89
- package/src/browser/editor-manager.ts +442 -442
- package/src/browser/editor-menu.ts +224 -224
- package/src/browser/editor-navigation-contribution.ts +343 -343
- package/src/browser/editor-preferences.ts +226 -226
- package/src/browser/editor-variable-contribution.ts +54 -54
- package/src/browser/editor-widget-factory.ts +82 -82
- package/src/browser/editor-widget.ts +137 -130
- package/src/browser/editor.ts +360 -358
- package/src/browser/index.ts +26 -26
- package/src/browser/language-status/editor-language-status-service.ts +271 -271
- package/src/browser/language-status/editor-language-status.css +101 -101
- package/src/browser/navigation/navigation-location-service.spec.ts +245 -245
- package/src/browser/navigation/navigation-location-service.ts +284 -284
- package/src/browser/navigation/navigation-location-similarity.spec.ts +46 -46
- package/src/browser/navigation/navigation-location-similarity.ts +58 -58
- package/src/browser/navigation/navigation-location-updater.spec.ts +197 -197
- package/src/browser/navigation/navigation-location-updater.ts +220 -220
- package/src/browser/navigation/navigation-location.ts +418 -418
- package/src/browser/navigation/test/mock-navigation-location-updater.ts +41 -41
- package/src/browser/quick-editor-service.ts +94 -94
- package/src/browser/style/index.css +19 -19
- package/src/browser/undo-redo-service.ts +120 -120
- package/src/common/language-selector.ts +104 -104
- package/src/package.spec.ts +28 -28
|
@@ -1,185 +1,185 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { EditorManager } from './editor-manager';
|
|
18
|
-
import { TextEditor } from './editor';
|
|
19
|
-
import { injectable, inject, optional } from '@theia/core/shared/inversify';
|
|
20
|
-
import { StatusBarAlignment, StatusBar } from '@theia/core/lib/browser/status-bar/status-bar';
|
|
21
|
-
import {
|
|
22
|
-
FrontendApplicationContribution, DiffUris, DockLayout,
|
|
23
|
-
QuickInputService, KeybindingRegistry, KeybindingContribution, SHELL_TABBAR_CONTEXT_SPLIT, ApplicationShell
|
|
24
|
-
} from '@theia/core/lib/browser';
|
|
25
|
-
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
|
|
26
|
-
import { CommandHandler, DisposableCollection, MenuContribution, MenuModelRegistry } from '@theia/core';
|
|
27
|
-
import { EditorCommands } from './editor-command';
|
|
28
|
-
import { CommandRegistry, CommandContribution } from '@theia/core/lib/common';
|
|
29
|
-
import { SUPPORTED_ENCODINGS } from '@theia/core/lib/browser/supported-encodings';
|
|
30
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
31
|
-
import { CurrentWidgetCommandAdapter } from '@theia/core/lib/browser/shell/current-widget-command-adapter';
|
|
32
|
-
import { EditorWidget } from './editor-widget';
|
|
33
|
-
import { EditorLanguageStatusService } from './language-status/editor-language-status-service';
|
|
34
|
-
|
|
35
|
-
@injectable()
|
|
36
|
-
export class EditorContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, MenuContribution {
|
|
37
|
-
|
|
38
|
-
@inject(StatusBar) protected readonly statusBar: StatusBar;
|
|
39
|
-
@inject(EditorManager) protected readonly editorManager: EditorManager;
|
|
40
|
-
@inject(EditorLanguageStatusService) protected readonly languageStatusService: EditorLanguageStatusService;
|
|
41
|
-
@inject(ApplicationShell) protected readonly shell: ApplicationShell;
|
|
42
|
-
|
|
43
|
-
@inject(ContextKeyService)
|
|
44
|
-
protected readonly contextKeyService: ContextKeyService;
|
|
45
|
-
|
|
46
|
-
@inject(QuickInputService) @optional()
|
|
47
|
-
protected readonly quickInputService: QuickInputService;
|
|
48
|
-
|
|
49
|
-
onStart(): void {
|
|
50
|
-
this.initEditorContextKeys();
|
|
51
|
-
|
|
52
|
-
this.updateStatusBar();
|
|
53
|
-
this.editorManager.onCurrentEditorChanged(() => this.updateStatusBar());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
protected initEditorContextKeys(): void {
|
|
57
|
-
const editorIsOpen = this.contextKeyService.createKey<boolean>('editorIsOpen', false);
|
|
58
|
-
const textCompareEditorVisible = this.contextKeyService.createKey<boolean>('textCompareEditorVisible', false);
|
|
59
|
-
const updateContextKeys = () => {
|
|
60
|
-
const widgets = this.editorManager.all;
|
|
61
|
-
editorIsOpen.set(!!widgets.length);
|
|
62
|
-
textCompareEditorVisible.set(widgets.some(widget => DiffUris.isDiffUri(widget.editor.uri)));
|
|
63
|
-
};
|
|
64
|
-
updateContextKeys();
|
|
65
|
-
for (const widget of this.editorManager.all) {
|
|
66
|
-
widget.disposed.connect(updateContextKeys);
|
|
67
|
-
}
|
|
68
|
-
this.editorManager.onCreated(widget => {
|
|
69
|
-
updateContextKeys();
|
|
70
|
-
widget.disposed.connect(updateContextKeys);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
protected readonly toDisposeOnCurrentEditorChanged = new DisposableCollection();
|
|
75
|
-
protected updateStatusBar(): void {
|
|
76
|
-
this.toDisposeOnCurrentEditorChanged.dispose();
|
|
77
|
-
|
|
78
|
-
const widget = this.editorManager.currentEditor;
|
|
79
|
-
const editor = widget && widget.editor;
|
|
80
|
-
this.updateLanguageStatus(editor);
|
|
81
|
-
this.updateEncodingStatus(editor);
|
|
82
|
-
this.setCursorPositionStatus(editor);
|
|
83
|
-
if (editor) {
|
|
84
|
-
this.toDisposeOnCurrentEditorChanged.pushAll([
|
|
85
|
-
editor.onLanguageChanged(() => this.updateLanguageStatus(editor)),
|
|
86
|
-
editor.onEncodingChanged(() => this.updateEncodingStatus(editor)),
|
|
87
|
-
editor.onCursorPositionChanged(() => this.setCursorPositionStatus(editor))
|
|
88
|
-
]);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
protected updateLanguageStatus(editor: TextEditor | undefined): void {
|
|
93
|
-
this.languageStatusService.updateLanguageStatus(editor);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
protected updateEncodingStatus(editor: TextEditor | undefined): void {
|
|
97
|
-
if (!editor) {
|
|
98
|
-
this.statusBar.removeElement('editor-status-encoding');
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
this.statusBar.setElement('editor-status-encoding', {
|
|
102
|
-
text: SUPPORTED_ENCODINGS[editor.getEncoding()].labelShort,
|
|
103
|
-
alignment: StatusBarAlignment.RIGHT,
|
|
104
|
-
priority: 10,
|
|
105
|
-
command: EditorCommands.CHANGE_ENCODING.id,
|
|
106
|
-
tooltip: nls.localizeByDefault('Select Encoding')
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
protected setCursorPositionStatus(editor: TextEditor | undefined): void {
|
|
111
|
-
if (!editor) {
|
|
112
|
-
this.statusBar.removeElement('editor-status-cursor-position');
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const { cursor } = editor;
|
|
116
|
-
this.statusBar.setElement('editor-status-cursor-position', {
|
|
117
|
-
text: nls.localizeByDefault('Ln {0}, Col {1}', cursor.line + 1, editor.getVisibleColumn(cursor)),
|
|
118
|
-
alignment: StatusBarAlignment.RIGHT,
|
|
119
|
-
priority: 100,
|
|
120
|
-
tooltip: EditorCommands.GOTO_LINE_COLUMN.label,
|
|
121
|
-
command: EditorCommands.GOTO_LINE_COLUMN.id
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
registerCommands(commands: CommandRegistry): void {
|
|
126
|
-
commands.registerCommand(EditorCommands.SHOW_ALL_OPENED_EDITORS, {
|
|
127
|
-
execute: () => this.quickInputService?.open('edt ')
|
|
128
|
-
});
|
|
129
|
-
const splitHandlerFactory = (splitMode: DockLayout.InsertMode): CommandHandler => new CurrentWidgetCommandAdapter(this.shell, {
|
|
130
|
-
isEnabled: title => title?.owner instanceof EditorWidget,
|
|
131
|
-
execute: async title => {
|
|
132
|
-
if (title?.owner instanceof EditorWidget) {
|
|
133
|
-
const selection = title.owner.editor.selection;
|
|
134
|
-
const newEditor = await this.editorManager.openToSide(title.owner.editor.uri, { selection, widgetOptions: { mode: splitMode, ref: title.owner } });
|
|
135
|
-
const oldEditorState = title.owner.editor.storeViewState();
|
|
136
|
-
newEditor.editor.restoreViewState(oldEditorState);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
commands.registerCommand(EditorCommands.SPLIT_EDITOR_HORIZONTAL, splitHandlerFactory('split-right'));
|
|
141
|
-
commands.registerCommand(EditorCommands.SPLIT_EDITOR_VERTICAL, splitHandlerFactory('split-bottom'));
|
|
142
|
-
commands.registerCommand(EditorCommands.SPLIT_EDITOR_RIGHT, splitHandlerFactory('split-right'));
|
|
143
|
-
commands.registerCommand(EditorCommands.SPLIT_EDITOR_DOWN, splitHandlerFactory('split-bottom'));
|
|
144
|
-
commands.registerCommand(EditorCommands.SPLIT_EDITOR_UP, splitHandlerFactory('split-top'));
|
|
145
|
-
commands.registerCommand(EditorCommands.SPLIT_EDITOR_LEFT, splitHandlerFactory('split-left'));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
149
|
-
keybindings.registerKeybinding({
|
|
150
|
-
command: EditorCommands.SHOW_ALL_OPENED_EDITORS.id,
|
|
151
|
-
keybinding: 'ctrlcmd+k ctrlcmd+p'
|
|
152
|
-
});
|
|
153
|
-
keybindings.registerKeybinding({
|
|
154
|
-
command: EditorCommands.SPLIT_EDITOR_HORIZONTAL.id,
|
|
155
|
-
keybinding: 'ctrlcmd+\\',
|
|
156
|
-
});
|
|
157
|
-
keybindings.registerKeybinding({
|
|
158
|
-
command: EditorCommands.SPLIT_EDITOR_VERTICAL.id,
|
|
159
|
-
keybinding: 'ctrlcmd+k ctrlcmd+\\',
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
registerMenus(registry: MenuModelRegistry): void {
|
|
164
|
-
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
|
|
165
|
-
commandId: EditorCommands.SPLIT_EDITOR_UP.id,
|
|
166
|
-
label: nls.localizeByDefault('Split Up'),
|
|
167
|
-
order: '1',
|
|
168
|
-
});
|
|
169
|
-
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
|
|
170
|
-
commandId: EditorCommands.SPLIT_EDITOR_DOWN.id,
|
|
171
|
-
label: nls.localizeByDefault('Split Down'),
|
|
172
|
-
order: '2',
|
|
173
|
-
});
|
|
174
|
-
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
|
|
175
|
-
commandId: EditorCommands.SPLIT_EDITOR_LEFT.id,
|
|
176
|
-
label: nls.localizeByDefault('Split Left'),
|
|
177
|
-
order: '3',
|
|
178
|
-
});
|
|
179
|
-
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
|
|
180
|
-
commandId: EditorCommands.SPLIT_EDITOR_RIGHT.id,
|
|
181
|
-
label: nls.localizeByDefault('Split Right'),
|
|
182
|
-
order: '4',
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { EditorManager } from './editor-manager';
|
|
18
|
+
import { TextEditor } from './editor';
|
|
19
|
+
import { injectable, inject, optional } from '@theia/core/shared/inversify';
|
|
20
|
+
import { StatusBarAlignment, StatusBar } from '@theia/core/lib/browser/status-bar/status-bar';
|
|
21
|
+
import {
|
|
22
|
+
FrontendApplicationContribution, DiffUris, DockLayout,
|
|
23
|
+
QuickInputService, KeybindingRegistry, KeybindingContribution, SHELL_TABBAR_CONTEXT_SPLIT, ApplicationShell
|
|
24
|
+
} from '@theia/core/lib/browser';
|
|
25
|
+
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
|
|
26
|
+
import { CommandHandler, DisposableCollection, MenuContribution, MenuModelRegistry } from '@theia/core';
|
|
27
|
+
import { EditorCommands } from './editor-command';
|
|
28
|
+
import { CommandRegistry, CommandContribution } from '@theia/core/lib/common';
|
|
29
|
+
import { SUPPORTED_ENCODINGS } from '@theia/core/lib/browser/supported-encodings';
|
|
30
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
31
|
+
import { CurrentWidgetCommandAdapter } from '@theia/core/lib/browser/shell/current-widget-command-adapter';
|
|
32
|
+
import { EditorWidget } from './editor-widget';
|
|
33
|
+
import { EditorLanguageStatusService } from './language-status/editor-language-status-service';
|
|
34
|
+
|
|
35
|
+
@injectable()
|
|
36
|
+
export class EditorContribution implements FrontendApplicationContribution, CommandContribution, KeybindingContribution, MenuContribution {
|
|
37
|
+
|
|
38
|
+
@inject(StatusBar) protected readonly statusBar: StatusBar;
|
|
39
|
+
@inject(EditorManager) protected readonly editorManager: EditorManager;
|
|
40
|
+
@inject(EditorLanguageStatusService) protected readonly languageStatusService: EditorLanguageStatusService;
|
|
41
|
+
@inject(ApplicationShell) protected readonly shell: ApplicationShell;
|
|
42
|
+
|
|
43
|
+
@inject(ContextKeyService)
|
|
44
|
+
protected readonly contextKeyService: ContextKeyService;
|
|
45
|
+
|
|
46
|
+
@inject(QuickInputService) @optional()
|
|
47
|
+
protected readonly quickInputService: QuickInputService;
|
|
48
|
+
|
|
49
|
+
onStart(): void {
|
|
50
|
+
this.initEditorContextKeys();
|
|
51
|
+
|
|
52
|
+
this.updateStatusBar();
|
|
53
|
+
this.editorManager.onCurrentEditorChanged(() => this.updateStatusBar());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected initEditorContextKeys(): void {
|
|
57
|
+
const editorIsOpen = this.contextKeyService.createKey<boolean>('editorIsOpen', false);
|
|
58
|
+
const textCompareEditorVisible = this.contextKeyService.createKey<boolean>('textCompareEditorVisible', false);
|
|
59
|
+
const updateContextKeys = () => {
|
|
60
|
+
const widgets = this.editorManager.all;
|
|
61
|
+
editorIsOpen.set(!!widgets.length);
|
|
62
|
+
textCompareEditorVisible.set(widgets.some(widget => DiffUris.isDiffUri(widget.editor.uri)));
|
|
63
|
+
};
|
|
64
|
+
updateContextKeys();
|
|
65
|
+
for (const widget of this.editorManager.all) {
|
|
66
|
+
widget.disposed.connect(updateContextKeys);
|
|
67
|
+
}
|
|
68
|
+
this.editorManager.onCreated(widget => {
|
|
69
|
+
updateContextKeys();
|
|
70
|
+
widget.disposed.connect(updateContextKeys);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
protected readonly toDisposeOnCurrentEditorChanged = new DisposableCollection();
|
|
75
|
+
protected updateStatusBar(): void {
|
|
76
|
+
this.toDisposeOnCurrentEditorChanged.dispose();
|
|
77
|
+
|
|
78
|
+
const widget = this.editorManager.currentEditor;
|
|
79
|
+
const editor = widget && widget.editor;
|
|
80
|
+
this.updateLanguageStatus(editor);
|
|
81
|
+
this.updateEncodingStatus(editor);
|
|
82
|
+
this.setCursorPositionStatus(editor);
|
|
83
|
+
if (editor) {
|
|
84
|
+
this.toDisposeOnCurrentEditorChanged.pushAll([
|
|
85
|
+
editor.onLanguageChanged(() => this.updateLanguageStatus(editor)),
|
|
86
|
+
editor.onEncodingChanged(() => this.updateEncodingStatus(editor)),
|
|
87
|
+
editor.onCursorPositionChanged(() => this.setCursorPositionStatus(editor))
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected updateLanguageStatus(editor: TextEditor | undefined): void {
|
|
93
|
+
this.languageStatusService.updateLanguageStatus(editor);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
protected updateEncodingStatus(editor: TextEditor | undefined): void {
|
|
97
|
+
if (!editor) {
|
|
98
|
+
this.statusBar.removeElement('editor-status-encoding');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.statusBar.setElement('editor-status-encoding', {
|
|
102
|
+
text: SUPPORTED_ENCODINGS[editor.getEncoding()].labelShort,
|
|
103
|
+
alignment: StatusBarAlignment.RIGHT,
|
|
104
|
+
priority: 10,
|
|
105
|
+
command: EditorCommands.CHANGE_ENCODING.id,
|
|
106
|
+
tooltip: nls.localizeByDefault('Select Encoding')
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
protected setCursorPositionStatus(editor: TextEditor | undefined): void {
|
|
111
|
+
if (!editor) {
|
|
112
|
+
this.statusBar.removeElement('editor-status-cursor-position');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const { cursor } = editor;
|
|
116
|
+
this.statusBar.setElement('editor-status-cursor-position', {
|
|
117
|
+
text: nls.localizeByDefault('Ln {0}, Col {1}', cursor.line + 1, editor.getVisibleColumn(cursor)),
|
|
118
|
+
alignment: StatusBarAlignment.RIGHT,
|
|
119
|
+
priority: 100,
|
|
120
|
+
tooltip: EditorCommands.GOTO_LINE_COLUMN.label,
|
|
121
|
+
command: EditorCommands.GOTO_LINE_COLUMN.id
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
registerCommands(commands: CommandRegistry): void {
|
|
126
|
+
commands.registerCommand(EditorCommands.SHOW_ALL_OPENED_EDITORS, {
|
|
127
|
+
execute: () => this.quickInputService?.open('edt ')
|
|
128
|
+
});
|
|
129
|
+
const splitHandlerFactory = (splitMode: DockLayout.InsertMode): CommandHandler => new CurrentWidgetCommandAdapter(this.shell, {
|
|
130
|
+
isEnabled: title => title?.owner instanceof EditorWidget,
|
|
131
|
+
execute: async title => {
|
|
132
|
+
if (title?.owner instanceof EditorWidget) {
|
|
133
|
+
const selection = title.owner.editor.selection;
|
|
134
|
+
const newEditor = await this.editorManager.openToSide(title.owner.editor.uri, { selection, widgetOptions: { mode: splitMode, ref: title.owner } });
|
|
135
|
+
const oldEditorState = title.owner.editor.storeViewState();
|
|
136
|
+
newEditor.editor.restoreViewState(oldEditorState);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
commands.registerCommand(EditorCommands.SPLIT_EDITOR_HORIZONTAL, splitHandlerFactory('split-right'));
|
|
141
|
+
commands.registerCommand(EditorCommands.SPLIT_EDITOR_VERTICAL, splitHandlerFactory('split-bottom'));
|
|
142
|
+
commands.registerCommand(EditorCommands.SPLIT_EDITOR_RIGHT, splitHandlerFactory('split-right'));
|
|
143
|
+
commands.registerCommand(EditorCommands.SPLIT_EDITOR_DOWN, splitHandlerFactory('split-bottom'));
|
|
144
|
+
commands.registerCommand(EditorCommands.SPLIT_EDITOR_UP, splitHandlerFactory('split-top'));
|
|
145
|
+
commands.registerCommand(EditorCommands.SPLIT_EDITOR_LEFT, splitHandlerFactory('split-left'));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
149
|
+
keybindings.registerKeybinding({
|
|
150
|
+
command: EditorCommands.SHOW_ALL_OPENED_EDITORS.id,
|
|
151
|
+
keybinding: 'ctrlcmd+k ctrlcmd+p'
|
|
152
|
+
});
|
|
153
|
+
keybindings.registerKeybinding({
|
|
154
|
+
command: EditorCommands.SPLIT_EDITOR_HORIZONTAL.id,
|
|
155
|
+
keybinding: 'ctrlcmd+\\',
|
|
156
|
+
});
|
|
157
|
+
keybindings.registerKeybinding({
|
|
158
|
+
command: EditorCommands.SPLIT_EDITOR_VERTICAL.id,
|
|
159
|
+
keybinding: 'ctrlcmd+k ctrlcmd+\\',
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
registerMenus(registry: MenuModelRegistry): void {
|
|
164
|
+
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
|
|
165
|
+
commandId: EditorCommands.SPLIT_EDITOR_UP.id,
|
|
166
|
+
label: nls.localizeByDefault('Split Up'),
|
|
167
|
+
order: '1',
|
|
168
|
+
});
|
|
169
|
+
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
|
|
170
|
+
commandId: EditorCommands.SPLIT_EDITOR_DOWN.id,
|
|
171
|
+
label: nls.localizeByDefault('Split Down'),
|
|
172
|
+
order: '2',
|
|
173
|
+
});
|
|
174
|
+
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
|
|
175
|
+
commandId: EditorCommands.SPLIT_EDITOR_LEFT.id,
|
|
176
|
+
label: nls.localizeByDefault('Split Left'),
|
|
177
|
+
order: '3',
|
|
178
|
+
});
|
|
179
|
+
registry.registerMenuAction(SHELL_TABBAR_CONTEXT_SPLIT, {
|
|
180
|
+
commandId: EditorCommands.SPLIT_EDITOR_RIGHT.id,
|
|
181
|
+
label: nls.localizeByDefault('Split Right'),
|
|
182
|
+
order: '4',
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import '../../src/browser/style/index.css';
|
|
18
|
-
import '../../src/browser/language-status/editor-language-status.css';
|
|
19
|
-
|
|
20
|
-
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
21
|
-
import { CommandContribution, MenuContribution } from '@theia/core/lib/common';
|
|
22
|
-
import { OpenHandler, WidgetFactory, FrontendApplicationContribution, KeybindingContribution } from '@theia/core/lib/browser';
|
|
23
|
-
import { VariableContribution } from '@theia/variable-resolver/lib/browser';
|
|
24
|
-
import { EditorManager, EditorAccess, ActiveEditorAccess, CurrentEditorAccess } from './editor-manager';
|
|
25
|
-
import { EditorContribution } from './editor-contribution';
|
|
26
|
-
import { EditorMenuContribution } from './editor-menu';
|
|
27
|
-
import { EditorCommandContribution } from './editor-command';
|
|
28
|
-
import { EditorKeybindingContribution } from './editor-keybinding';
|
|
29
|
-
import { bindEditorPreferences } from './editor-preferences';
|
|
30
|
-
import { EditorWidgetFactory } from './editor-widget-factory';
|
|
31
|
-
import { EditorNavigationContribution } from './editor-navigation-contribution';
|
|
32
|
-
import { NavigationLocationUpdater } from './navigation/navigation-location-updater';
|
|
33
|
-
import { NavigationLocationService } from './navigation/navigation-location-service';
|
|
34
|
-
import { NavigationLocationSimilarity } from './navigation/navigation-location-similarity';
|
|
35
|
-
import { EditorVariableContribution } from './editor-variable-contribution';
|
|
36
|
-
import { QuickAccessContribution } from '@theia/core/lib/browser/quick-input/quick-access';
|
|
37
|
-
import { QuickEditorService } from './quick-editor-service';
|
|
38
|
-
import { EditorLanguageStatusService } from './language-status/editor-language-status-service';
|
|
39
|
-
import { EditorLineNumberContribution } from './editor-linenumber-contribution';
|
|
40
|
-
import { UndoRedoService } from './undo-redo-service';
|
|
41
|
-
|
|
42
|
-
export default new ContainerModule(bind => {
|
|
43
|
-
bindEditorPreferences(bind);
|
|
44
|
-
|
|
45
|
-
bind(EditorWidgetFactory).toSelf().inSingletonScope();
|
|
46
|
-
bind(WidgetFactory).toService(EditorWidgetFactory);
|
|
47
|
-
|
|
48
|
-
bind(EditorManager).toSelf().inSingletonScope();
|
|
49
|
-
bind(OpenHandler).toService(EditorManager);
|
|
50
|
-
|
|
51
|
-
bind(EditorCommandContribution).toSelf().inSingletonScope();
|
|
52
|
-
bind(CommandContribution).toService(EditorCommandContribution);
|
|
53
|
-
|
|
54
|
-
bind(EditorMenuContribution).toSelf().inSingletonScope();
|
|
55
|
-
bind(MenuContribution).toService(EditorMenuContribution);
|
|
56
|
-
|
|
57
|
-
bind(EditorKeybindingContribution).toSelf().inSingletonScope();
|
|
58
|
-
bind(KeybindingContribution).toService(EditorKeybindingContribution);
|
|
59
|
-
|
|
60
|
-
bind(EditorContribution).toSelf().inSingletonScope();
|
|
61
|
-
bind(FrontendApplicationContribution).toService(EditorContribution);
|
|
62
|
-
bind(EditorLanguageStatusService).toSelf().inSingletonScope();
|
|
63
|
-
|
|
64
|
-
bind(EditorLineNumberContribution).toSelf().inSingletonScope();
|
|
65
|
-
bind(FrontendApplicationContribution).toService(EditorLineNumberContribution);
|
|
66
|
-
|
|
67
|
-
bind(EditorNavigationContribution).toSelf().inSingletonScope();
|
|
68
|
-
bind(FrontendApplicationContribution).toService(EditorNavigationContribution);
|
|
69
|
-
bind(NavigationLocationService).toSelf().inSingletonScope();
|
|
70
|
-
bind(NavigationLocationUpdater).toSelf().inSingletonScope();
|
|
71
|
-
bind(NavigationLocationSimilarity).toSelf().inSingletonScope();
|
|
72
|
-
|
|
73
|
-
bind(VariableContribution).to(EditorVariableContribution).inSingletonScope();
|
|
74
|
-
|
|
75
|
-
[CommandContribution, KeybindingContribution, MenuContribution].forEach(serviceIdentifier => {
|
|
76
|
-
bind(serviceIdentifier).toService(EditorContribution);
|
|
77
|
-
});
|
|
78
|
-
bind(QuickEditorService).toSelf().inSingletonScope();
|
|
79
|
-
bind(QuickAccessContribution).to(QuickEditorService);
|
|
80
|
-
|
|
81
|
-
bind(CurrentEditorAccess).toSelf().inSingletonScope();
|
|
82
|
-
bind(ActiveEditorAccess).toSelf().inSingletonScope();
|
|
83
|
-
bind(EditorAccess).to(CurrentEditorAccess).inSingletonScope().whenTargetNamed(EditorAccess.CURRENT);
|
|
84
|
-
bind(EditorAccess).to(ActiveEditorAccess).inSingletonScope().whenTargetNamed(EditorAccess.ACTIVE);
|
|
85
|
-
|
|
86
|
-
bind(UndoRedoService).toSelf().inSingletonScope();
|
|
87
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import '../../src/browser/style/index.css';
|
|
18
|
+
import '../../src/browser/language-status/editor-language-status.css';
|
|
19
|
+
|
|
20
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
21
|
+
import { CommandContribution, MenuContribution } from '@theia/core/lib/common';
|
|
22
|
+
import { OpenHandler, WidgetFactory, FrontendApplicationContribution, KeybindingContribution } from '@theia/core/lib/browser';
|
|
23
|
+
import { VariableContribution } from '@theia/variable-resolver/lib/browser';
|
|
24
|
+
import { EditorManager, EditorAccess, ActiveEditorAccess, CurrentEditorAccess } from './editor-manager';
|
|
25
|
+
import { EditorContribution } from './editor-contribution';
|
|
26
|
+
import { EditorMenuContribution } from './editor-menu';
|
|
27
|
+
import { EditorCommandContribution } from './editor-command';
|
|
28
|
+
import { EditorKeybindingContribution } from './editor-keybinding';
|
|
29
|
+
import { bindEditorPreferences } from './editor-preferences';
|
|
30
|
+
import { EditorWidgetFactory } from './editor-widget-factory';
|
|
31
|
+
import { EditorNavigationContribution } from './editor-navigation-contribution';
|
|
32
|
+
import { NavigationLocationUpdater } from './navigation/navigation-location-updater';
|
|
33
|
+
import { NavigationLocationService } from './navigation/navigation-location-service';
|
|
34
|
+
import { NavigationLocationSimilarity } from './navigation/navigation-location-similarity';
|
|
35
|
+
import { EditorVariableContribution } from './editor-variable-contribution';
|
|
36
|
+
import { QuickAccessContribution } from '@theia/core/lib/browser/quick-input/quick-access';
|
|
37
|
+
import { QuickEditorService } from './quick-editor-service';
|
|
38
|
+
import { EditorLanguageStatusService } from './language-status/editor-language-status-service';
|
|
39
|
+
import { EditorLineNumberContribution } from './editor-linenumber-contribution';
|
|
40
|
+
import { UndoRedoService } from './undo-redo-service';
|
|
41
|
+
|
|
42
|
+
export default new ContainerModule(bind => {
|
|
43
|
+
bindEditorPreferences(bind);
|
|
44
|
+
|
|
45
|
+
bind(EditorWidgetFactory).toSelf().inSingletonScope();
|
|
46
|
+
bind(WidgetFactory).toService(EditorWidgetFactory);
|
|
47
|
+
|
|
48
|
+
bind(EditorManager).toSelf().inSingletonScope();
|
|
49
|
+
bind(OpenHandler).toService(EditorManager);
|
|
50
|
+
|
|
51
|
+
bind(EditorCommandContribution).toSelf().inSingletonScope();
|
|
52
|
+
bind(CommandContribution).toService(EditorCommandContribution);
|
|
53
|
+
|
|
54
|
+
bind(EditorMenuContribution).toSelf().inSingletonScope();
|
|
55
|
+
bind(MenuContribution).toService(EditorMenuContribution);
|
|
56
|
+
|
|
57
|
+
bind(EditorKeybindingContribution).toSelf().inSingletonScope();
|
|
58
|
+
bind(KeybindingContribution).toService(EditorKeybindingContribution);
|
|
59
|
+
|
|
60
|
+
bind(EditorContribution).toSelf().inSingletonScope();
|
|
61
|
+
bind(FrontendApplicationContribution).toService(EditorContribution);
|
|
62
|
+
bind(EditorLanguageStatusService).toSelf().inSingletonScope();
|
|
63
|
+
|
|
64
|
+
bind(EditorLineNumberContribution).toSelf().inSingletonScope();
|
|
65
|
+
bind(FrontendApplicationContribution).toService(EditorLineNumberContribution);
|
|
66
|
+
|
|
67
|
+
bind(EditorNavigationContribution).toSelf().inSingletonScope();
|
|
68
|
+
bind(FrontendApplicationContribution).toService(EditorNavigationContribution);
|
|
69
|
+
bind(NavigationLocationService).toSelf().inSingletonScope();
|
|
70
|
+
bind(NavigationLocationUpdater).toSelf().inSingletonScope();
|
|
71
|
+
bind(NavigationLocationSimilarity).toSelf().inSingletonScope();
|
|
72
|
+
|
|
73
|
+
bind(VariableContribution).to(EditorVariableContribution).inSingletonScope();
|
|
74
|
+
|
|
75
|
+
[CommandContribution, KeybindingContribution, MenuContribution].forEach(serviceIdentifier => {
|
|
76
|
+
bind(serviceIdentifier).toService(EditorContribution);
|
|
77
|
+
});
|
|
78
|
+
bind(QuickEditorService).toSelf().inSingletonScope();
|
|
79
|
+
bind(QuickAccessContribution).to(QuickEditorService);
|
|
80
|
+
|
|
81
|
+
bind(CurrentEditorAccess).toSelf().inSingletonScope();
|
|
82
|
+
bind(ActiveEditorAccess).toSelf().inSingletonScope();
|
|
83
|
+
bind(EditorAccess).to(CurrentEditorAccess).inSingletonScope().whenTargetNamed(EditorAccess.CURRENT);
|
|
84
|
+
bind(EditorAccess).to(ActiveEditorAccess).inSingletonScope().whenTargetNamed(EditorAccess.ACTIVE);
|
|
85
|
+
|
|
86
|
+
bind(UndoRedoService).toSelf().inSingletonScope();
|
|
87
|
+
});
|