Wiring in majority of minimap-view
This commit is contained in:
parent
96eaa64b2a
commit
1f51759048
@ -20,6 +20,7 @@ export class EditorsService {
|
|||||||
editorSettings: typeof EditorSettings;
|
editorSettings: typeof EditorSettings;
|
||||||
|
|
||||||
activeEditor!: string;
|
activeEditor!: string;
|
||||||
|
miniMapView!: CodeViewComponent;
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -37,6 +38,11 @@ export class EditorsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public set(uuid: string, component: CodeViewComponent) {
|
public set(uuid: string, component: CodeViewComponent) {
|
||||||
|
if (component.isMiniMap) {
|
||||||
|
this.miniMapView = component;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.editors.set(uuid, component);
|
this.editors.set(uuid, component);
|
||||||
|
|
||||||
if (Object.keys(this.editors).length < 1) return;
|
if (Object.keys(this.editors).length < 1) return;
|
||||||
@ -60,11 +66,14 @@ export class EditorsService {
|
|||||||
public async setSession(file: NewtonFile | undefined | null) {
|
public async setSession(file: NewtonFile | undefined | null) {
|
||||||
if ( !file ) return;
|
if ( !file ) return;
|
||||||
|
|
||||||
let editorComponent = this.getActiveEditorComponent();
|
let editorComponent = this.getActiveEditorComponent();
|
||||||
let editor = editorComponent.editor;
|
let editor = editorComponent.editor;
|
||||||
|
|
||||||
|
editorComponent.activeFile = file;
|
||||||
|
this.miniMapView.activeFile = file;
|
||||||
|
|
||||||
editorComponent.activeFile = file;
|
|
||||||
editor.setSession(file.session);
|
editor.setSession(file.session);
|
||||||
|
this.miniMapView.editor.setSession(file.session);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSession() {
|
public getSession() {
|
||||||
@ -75,13 +84,22 @@ export class EditorsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setActiveEditor(activeEditor: string) {
|
public setActiveEditor(activeEditor: string) {
|
||||||
this.activeEditor = activeEditor;
|
this.activeEditor = activeEditor;
|
||||||
|
let editorComponent = this.getActiveEditorComponent();
|
||||||
|
this.miniMapView.activeFile = editorComponent.editor.activeFile;
|
||||||
|
|
||||||
|
this.miniMapView.editor.setSession(editorComponent.editor.getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
public getActiveEditorComponent(): any {
|
public getActiveEditorComponent(): any {
|
||||||
return this.get(this.activeEditor);
|
return this.get(this.activeEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clearminiMapView() {
|
||||||
|
this.miniMapView.newSession();
|
||||||
|
this.miniMapView.activeFile = null;
|
||||||
|
}
|
||||||
|
|
||||||
protected getActiveEditor(): any {
|
protected getActiveEditor(): any {
|
||||||
let editorComponent = this.get(this.activeEditor);
|
let editorComponent = this.get(this.activeEditor);
|
||||||
let editor = editorComponent.editor;
|
let editor = editorComponent.editor;
|
||||||
|
@ -18,6 +18,7 @@ import { ServiceMessage } from '../../common/types/service-message.type';
|
|||||||
export class CodeViewBase {
|
export class CodeViewBase {
|
||||||
public uuid: string = uuid.v4();
|
public uuid: string = uuid.v4();
|
||||||
@Input() public isDefault: boolean = false;
|
@Input() public isDefault: boolean = false;
|
||||||
|
@Input() public isMiniMap: boolean = false;
|
||||||
public leftSiblingUUID!: string;
|
public leftSiblingUUID!: string;
|
||||||
public rightSiblingUUID!: string;
|
public rightSiblingUUID!: string;
|
||||||
|
|
||||||
@ -150,16 +151,30 @@ export class CodeViewBase {
|
|||||||
window.main.toggleFullScreen();
|
window.main.toggleFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setAsMiniMapView() {
|
||||||
|
this.editor.renderer.showLineNumbers = false;
|
||||||
|
this.editor.renderer.setShowGutter(false);
|
||||||
|
|
||||||
|
this.editor.setReadOnly(true);
|
||||||
|
this.editor.setFontSize(2);
|
||||||
|
this.editor.setHighlightActiveLine(false);
|
||||||
|
this.editor.setHighlightGutterLine(false);
|
||||||
|
this.editor.setShowFoldWidgets(false);
|
||||||
|
this.editor.setShowPrintMargin(false);
|
||||||
|
this.editorElm.nativeElement.parentElement.classList.add("col-1");
|
||||||
|
this.editorElm.nativeElement.parentElement.classList.add("zero-margin-padding");
|
||||||
|
}
|
||||||
|
|
||||||
public zoomIn() {
|
public zoomIn() {
|
||||||
this.editor.setFontSize(
|
this.editor.setFontSize(
|
||||||
parseInt(this.editor.getFontSize()) + 1
|
parseInt(this.editor.getFontSize()) + 1
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public zoomOut() {
|
public zoomOut() {
|
||||||
this.editor.setFontSize(
|
this.editor.setFontSize(
|
||||||
parseInt(this.editor.getFontSize()) - 1
|
parseInt(this.editor.getFontSize()) - 1
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public movelinesUp() {
|
public movelinesUp() {
|
||||||
|
@ -26,7 +26,7 @@ import { ServiceMessage } from '../../common/types/service-message.type';
|
|||||||
templateUrl: './view.component.html',
|
templateUrl: './view.component.html',
|
||||||
styleUrl: './view.component.css',
|
styleUrl: './view.component.css',
|
||||||
host: {
|
host: {
|
||||||
'class': 'col'
|
'class': 'col zero-margin-padding'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
export class CodeViewComponent extends CodeViewBase {
|
export class CodeViewComponent extends CodeViewBase {
|
||||||
@ -34,24 +34,28 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.editorsService.set(this.uuid, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ngAfterViewInit(): void {
|
private ngAfterViewInit(): void {
|
||||||
|
this.loadAce();
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadAce(): void {
|
||||||
|
this.editorsService.set(this.uuid, this);
|
||||||
|
|
||||||
|
this.configAceAndBindToElement()
|
||||||
|
this.loadAceKeyBindings();
|
||||||
|
this.loadAceEventBindings();
|
||||||
|
|
||||||
if (this.isDefault) {
|
if (this.isDefault) {
|
||||||
this.editorsService.setActiveEditor(this.uuid);
|
this.editorsService.setActiveEditor(this.uuid);
|
||||||
this.addActiveStyling();
|
this.addActiveStyling();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadAce();
|
if (this.isMiniMap) {
|
||||||
}
|
this.setAsMiniMapView();
|
||||||
|
}
|
||||||
private loadAce(): void {
|
|
||||||
this.configAceAndBindToElement()
|
|
||||||
this.loadAceKeyBindings();
|
|
||||||
this.loadAceEventBindings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private configAceAndBindToElement(): void {
|
private configAceAndBindToElement(): void {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
<code-view [isDefault]="true"></code-view>
|
<code-view [isDefault]="true"></code-view>
|
||||||
<hr class="col vr-pane-handle" pane-handle />
|
<hr class="col vr-pane-handle" pane-handle />
|
||||||
<code-view></code-view>
|
<code-view></code-view>
|
||||||
|
<code-view [isMiniMap]="true"></code-view>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
@ -106,6 +106,8 @@ export class EditorsComponent {
|
|||||||
|
|
||||||
editorComponent.activeFile = file;
|
editorComponent.activeFile = file;
|
||||||
editor.setSession(file.session);
|
editor.setSession(file.session);
|
||||||
|
this.editorsService.miniMapView.editor.setSession(file.session);
|
||||||
|
this.editorsService.miniMapView.activeFile = file;
|
||||||
} else if (message.action === "close-tab") {
|
} else if (message.action === "close-tab") {
|
||||||
let file = this.filesService.get(message.filePath);
|
let file = this.filesService.get(message.filePath);
|
||||||
let editors = this.editorsService.getEditorsAsArray();
|
let editors = this.editorsService.getEditorsAsArray();
|
||||||
@ -114,6 +116,10 @@ export class EditorsComponent {
|
|||||||
let editorComponent = editors[i];
|
let editorComponent = editors[i];
|
||||||
if (editorComponent.editor.session == file.session) {
|
if (editorComponent.editor.session == file.session) {
|
||||||
editorComponent.newSession();
|
editorComponent.newSession();
|
||||||
|
this.editorsService.miniMapView.editor.setSession(
|
||||||
|
editorComponent.editor.getSession()
|
||||||
|
);
|
||||||
|
this.editorsService.miniMapView.activeFile = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,10 @@ body {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.zero-margin-padding {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
|
Loading…
Reference in New Issue
Block a user