Add editor selection and move keybindings

This commit is contained in:
2025-06-13 22:36:01 -05:00
parent 7b498d0602
commit c9c020385d
4 changed files with 143 additions and 7 deletions

View File

@@ -52,14 +52,65 @@ export class EditorsComponent {
this.loadSubscribers();
this.loadMainSubscribers();
let editor = this.createEditor();
this.activeEditor = editor.instance.uuid;
editor.instance.isDefault = true;
let leftEditor = this.createEditor();
let rightEditor = this.createEditor();
this.createEditor();
this.activeEditor = leftEditor.instance.uuid;
leftEditor.instance.isDefault = true;
leftEditor.instance.rightSiblingUUID = rightEditor.instance.uuid;
rightEditor.instance.leftSiblingUUID = leftEditor.instance.uuid;
}
loadSubscribers() {
this.editorsService.selectSessionLeftRequested$().pipe(
takeUntil(this.unsubscribe)
).subscribe((uuid: string) => {
let editorComponent = this.editors.get(uuid).instance;
if (!editorComponent.leftSiblingUUID) return;
let siblingComponent = this.editors.get(editorComponent.leftSiblingUUID).instance;
siblingComponent.editor.focus()
});
this.editorsService.selectSessionRightRequested$().pipe(
takeUntil(this.unsubscribe)
).subscribe((uuid: string) => {
let editorComponent = this.editors.get(uuid).instance;
if (!editorComponent.rightSiblingUUID) return;
let siblingComponent = this.editors.get(editorComponent.rightSiblingUUID).instance;
siblingComponent.editor.focus()
});
this.editorsService.moveSessionLeftRequested$().pipe(
takeUntil(this.unsubscribe)
).subscribe((uuid: string) => {
let editorComponent = this.editors.get(uuid).instance;
if (!editorComponent.leftSiblingUUID) return;
let siblingComponent = this.editors.get(editorComponent.leftSiblingUUID).instance;
let session = editorComponent.editor.getSession();
let siblingSession = siblingComponent.editor.getSession();
if (session == siblingSession) return;
siblingComponent.editor.setSession(session);
editorComponent.newBuffer();
siblingComponent.editor.focus()
});
this.editorsService.moveSessionRightRequested$().pipe(
takeUntil(this.unsubscribe)
).subscribe((uuid: string) => {
let editorComponent = this.editors.get(uuid).instance;
if (!editorComponent.rightSiblingUUID) return;
let siblingComponent = this.editors.get(editorComponent.rightSiblingUUID).instance;
let session = editorComponent.editor.getSession();
let siblingSession = siblingComponent.editor.getSession();
if (session == siblingSession) return;
siblingComponent.editor.setSession(session);
editorComponent.newBuffer();
siblingComponent.editor.focus()
});
this.editorsService.newActiveEditor$().pipe(
takeUntil(this.unsubscribe)
).subscribe((uuid: string) => {
@@ -96,6 +147,7 @@ export class EditorsComponent {
this.files.delete(path);
window.fs.closeFile(path);
});
}
loadMainSubscribers() {