mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-15 05:09:29 +00:00
renamed customization folder to theia.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { injectable } from 'inversify';
|
||||
import { EditorContribution as TheiaEditorContribution } from '@theia/editor/lib/browser/editor-contribution';
|
||||
import { TextEditor } from '@theia/editor/lib/browser';
|
||||
import { StatusBarAlignment } from '@theia/core/lib/browser';
|
||||
|
||||
@injectable()
|
||||
export class EditorContribution extends TheiaEditorContribution {
|
||||
|
||||
protected updateLanguageStatus(editor: TextEditor | undefined): void {
|
||||
}
|
||||
|
||||
protected setCursorPositionStatus(editor: TextEditor | undefined): void {
|
||||
if (!editor) {
|
||||
this.statusBar.removeElement('editor-status-cursor-position');
|
||||
return;
|
||||
}
|
||||
const { cursor } = editor;
|
||||
this.statusBar.setElement('editor-status-cursor-position', {
|
||||
text: `${cursor.line + 1}`,
|
||||
alignment: StatusBarAlignment.LEFT,
|
||||
priority: 100
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { inject, injectable } from 'inversify';
|
||||
import URI from '@theia/core/lib/common/uri';
|
||||
import { EditorManager as TheiaEditorManager, EditorOpenerOptions } from '@theia/editor/lib/browser/editor-manager';
|
||||
import { ConfigService } from '../../../common/protocol/config-service';
|
||||
import { EditorWidget } from '@theia/editor/lib/browser';
|
||||
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
|
||||
|
||||
@injectable()
|
||||
export class EditorManager extends TheiaEditorManager {
|
||||
|
||||
@inject(ConfigService)
|
||||
protected readonly configService: ConfigService;
|
||||
|
||||
async open(uri: URI, options?: EditorOpenerOptions): Promise<EditorWidget> {
|
||||
const [widget, readOnly] = await Promise.all([super.open(uri, options), this.isReadOnly(uri)]);
|
||||
if (readOnly) {
|
||||
const { editor } = widget;
|
||||
if (editor instanceof MonacoEditor) {
|
||||
const codeEditor = editor.getControl();
|
||||
codeEditor.updateOptions({ readOnly });
|
||||
}
|
||||
}
|
||||
return widget;
|
||||
}
|
||||
|
||||
protected async isReadOnly(uri: URI): Promise<boolean> {
|
||||
const [config, configFileUri] = await Promise.all([
|
||||
this.configService.getConfiguration(),
|
||||
this.configService.getCliConfigFileUri()
|
||||
]);
|
||||
if (new URI(configFileUri).toString(true) === uri.toString(true)) {
|
||||
return false;
|
||||
}
|
||||
return new URI(config.dataDirUri).isEqualOrParent(uri)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user