Wiring file watch events WIP
This commit is contained in:
@@ -4,6 +4,7 @@ import { Subject, takeUntil } from 'rxjs';
|
||||
import { NewtonEditorComponent } from "./newton-editor/newton-editor.component";
|
||||
import { FilesModalComponent } from "./modals/files-modal.component";
|
||||
import { EditorsService } from '../common/services/editor/editors.service';
|
||||
import { TabsService } from '../common/services/editor/tabs/tabs.service';
|
||||
import { FilesService } from '../common/services/editor/files.service';
|
||||
|
||||
import { DndDirective } from '../common/directives/dnd.directive';
|
||||
@@ -34,6 +35,7 @@ export class EditorsComponent {
|
||||
|
||||
constructor(
|
||||
private editorsService: EditorsService,
|
||||
private tabsService: TabsService,
|
||||
private filesService: FilesService
|
||||
) {
|
||||
}
|
||||
@@ -57,17 +59,17 @@ export class EditorsComponent {
|
||||
this.editorsService.getMessage$().pipe(
|
||||
takeUntil(this.unsubscribe)
|
||||
).subscribe((message: ServiceMessage) => {
|
||||
if (message.action == "select-left-editor") {
|
||||
if (message.action === "select-left-editor") {
|
||||
let editorComponent = this.editorsService.get(message.editorUUID);
|
||||
if (!editorComponent.leftSiblingUUID) return;
|
||||
let siblingComponent = this.editorsService.get(editorComponent.leftSiblingUUID);
|
||||
siblingComponent.editor.focus()
|
||||
} else if (message.action == "select-right-editor") {
|
||||
} else if (message.action === "select-right-editor") {
|
||||
let editorComponent = this.editorsService.get(message.editorUUID);
|
||||
if (!editorComponent.rightSiblingUUID) return;
|
||||
let siblingComponent = this.editorsService.get(editorComponent.rightSiblingUUID);
|
||||
siblingComponent.editor.focus()
|
||||
} else if (message.action == "move-session-left") {
|
||||
} else if (message.action === "move-session-left") {
|
||||
let editorComponent = this.editorsService.get(message.editorUUID);
|
||||
if (!editorComponent.leftSiblingUUID) return;
|
||||
let siblingComponent = this.editorsService.get(editorComponent.leftSiblingUUID);
|
||||
@@ -78,7 +80,7 @@ export class EditorsComponent {
|
||||
siblingComponent.editor.setSession(session);
|
||||
editorComponent.newBuffer();
|
||||
siblingComponent.editor.focus()
|
||||
} else if (message.action == "move-session-right") {
|
||||
} else if (message.action === "move-session-right") {
|
||||
let editorComponent = this.editorsService.get(message.editorUUID);
|
||||
if (!editorComponent.rightSiblingUUID) return;
|
||||
let siblingComponent = this.editorsService.get(editorComponent.rightSiblingUUID);
|
||||
@@ -89,18 +91,18 @@ export class EditorsComponent {
|
||||
siblingComponent.editor.setSession(session);
|
||||
editorComponent.newBuffer();
|
||||
siblingComponent.editor.focus()
|
||||
} else if (message.action == "set-active-editor") {
|
||||
} else if (message.action === "set-active-editor") {
|
||||
this.editorsService.get(this.activeEditor).removeActiveStyling();
|
||||
this.activeEditor = message.editorUUID;
|
||||
this.editorsService.get(this.activeEditor).addActiveStyling();
|
||||
} else if (message.action == "set-tab-to-editor") {
|
||||
} else if (message.action === "set-tab-to-editor") {
|
||||
let file = this.filesService.get(message.filePath);
|
||||
let editorComponent = this.getActiveEditorComponent();
|
||||
let editor = editorComponent.editor;
|
||||
|
||||
editorComponent.activeFile = file;
|
||||
editor.setSession(file.session);
|
||||
} else if (message.action == "close-tab") {
|
||||
} else if (message.action === "close-tab") {
|
||||
let file = this.filesService.get(message.filePath);
|
||||
let editors = this.editorsService.getEditorsAsArray();
|
||||
|
||||
@@ -135,11 +137,33 @@ export class EditorsComponent {
|
||||
});
|
||||
|
||||
window.fs.onChangedFile(async (path: string) => {
|
||||
console.log(path);
|
||||
let message = new ServiceMessage();
|
||||
message.action = "file-changed";
|
||||
message.filePath = path;
|
||||
this.tabsService.sendMessage(message);
|
||||
});
|
||||
|
||||
window.fs.onDeletedFile(async (path: string) => {
|
||||
let message = new ServiceMessage();
|
||||
message.action = "file-deleted";
|
||||
message.filePath = path;
|
||||
|
||||
this.tabsService.sendMessage(message);
|
||||
this.filesService.sendMessage(message);
|
||||
});
|
||||
|
||||
window.fs.onSavedFile(async (path: string) => {
|
||||
let message = new ServiceMessage();
|
||||
message.action = "file-saved";
|
||||
message.filePath = path;
|
||||
|
||||
this.tabsService.sendMessage(message);
|
||||
});
|
||||
|
||||
window.fs.onUpdateFilePath(async (path: string) => {
|
||||
console.log(path);
|
||||
// this.tabsService.sendMessage(message);
|
||||
// this.filesService.sendMessage(message);
|
||||
});
|
||||
|
||||
window.main.onMenuActions(async (action: string) => {
|
||||
|
@@ -12,6 +12,7 @@ import "ace-builds/src-noconflict/theme-dracula";
|
||||
import { InfoBarService } from '../../common/services/editor/info-bar/info-bar.service';
|
||||
import { FilesModalService } from '../../common/services/editor/modals/files-modal.service';
|
||||
import { LSPService } from '../../common/services/lsp.service';
|
||||
import { TabsService } from '../../common/services/editor/tabs/tabs.service';
|
||||
import { EditorsService } from '../../common/services/editor/editors.service';
|
||||
|
||||
import { NewtonEditorBase } from './newton-editor.base';
|
||||
@@ -38,6 +39,7 @@ export class NewtonEditorComponent extends NewtonEditorBase {
|
||||
private infoBarService: InfoBarService,
|
||||
private editorsService: EditorsService,
|
||||
private lspService: LSPService,
|
||||
private tabsService: TabsService,
|
||||
private filesModalService: FilesModalService
|
||||
) {
|
||||
super();
|
||||
@@ -124,6 +126,13 @@ export class NewtonEditorComponent extends NewtonEditorBase {
|
||||
this.editorsService.sendMessage(message);
|
||||
});
|
||||
|
||||
this.editor.on("change", () => {
|
||||
let message = new ServiceMessage();
|
||||
message.action = "file-changed";
|
||||
message.filePath = this.activeFile.path;
|
||||
this.tabsService.sendMessage(message);
|
||||
});
|
||||
|
||||
this.editor.on("changeSession", (session) => {
|
||||
this.lspService.registerEditor(this.editor);
|
||||
this.updateInfoBar();
|
||||
|
@@ -19,13 +19,25 @@
|
||||
border-right-style: solid;
|
||||
border-right-color: #ffffff64;
|
||||
border-right-width: 2px;
|
||||
}
|
||||
|
||||
.active-tab {
|
||||
background-color: rgba(255, 255, 255, 0.46);
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.tab:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.file-changed {
|
||||
color: rgba(255, 168, 0, 0.64);
|
||||
}
|
||||
|
||||
.file-deleted {
|
||||
color: rgba(255, 0, 0, 0.64);
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-left: 2em;
|
||||
margin-right: 2em;
|
||||
|
@@ -42,9 +42,21 @@ export class TabsComponent {
|
||||
public ngAfterViewInit(): void {
|
||||
this.tabsService.getMessage$().pipe(
|
||||
takeUntil(this.unsubscribe)
|
||||
).subscribe((data: ServiceMessage) => {
|
||||
if (data.action === "create-tab") {
|
||||
this.createTab(data.fileName, data.fileUUID, data.filePath);
|
||||
).subscribe((message: ServiceMessage) => {
|
||||
if (message.action === "create-tab") {
|
||||
this.createTab(message.fileName, message.fileUUID, message.filePath);
|
||||
} else if (message.action === "file-changed") {
|
||||
let elm = document.querySelectorAll(`[title="${message.filePath}"]`)[1];
|
||||
elm.classList.add("file-changed");
|
||||
elm.classList.remove("file-deleted");
|
||||
} else if (message.action === "file-deleted") {
|
||||
let elm = document.querySelectorAll(`[title="${message.filePath}"]`)[1];
|
||||
elm.classList.add("file-deleted");
|
||||
elm.classList.remove("file-changed");
|
||||
} else if (message.action === "file-saved") {
|
||||
let elm = document.querySelectorAll(`[title="${message.filePath}"]`)[1];
|
||||
elm.classList.remove("file-deleted");
|
||||
elm.classList.remove("file-changed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user