Add editor selection and move keybindings
This commit is contained in:
parent
7b498d0602
commit
c9c020385d
@ -13,10 +13,15 @@ export class EditorsService {
|
|||||||
private activationSubject: ReplaySubject<string> = new ReplaySubject<string>(1);
|
private activationSubject: ReplaySubject<string> = new ReplaySubject<string>(1);
|
||||||
private switchSessionSubject: ReplaySubject<string> = new ReplaySubject<string>(1);
|
private switchSessionSubject: ReplaySubject<string> = new ReplaySubject<string>(1);
|
||||||
private closeTabSubject: ReplaySubject<string> = new ReplaySubject<string>(1);
|
private closeTabSubject: ReplaySubject<string> = new ReplaySubject<string>(1);
|
||||||
|
private selectSessionLeftSubject: ReplaySubject<any> = new ReplaySubject<any>(1);
|
||||||
|
private selectSessionRightSubject: ReplaySubject<any> = new ReplaySubject<any>(1);
|
||||||
|
private moveSessionLeftSubject: ReplaySubject<any> = new ReplaySubject<any>(1);
|
||||||
|
private moveSessionRightSubject: ReplaySubject<any> = new ReplaySubject<any>(1);
|
||||||
|
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
|
|
||||||
setData(data: ServiceMessage): void {
|
setData(data: ServiceMessage): void {
|
||||||
this.messageSubject.next(data);
|
this.messageSubject.next(data);
|
||||||
}
|
}
|
||||||
@ -48,4 +53,37 @@ export class EditorsService {
|
|||||||
closeTabRequested$(): Observable<string> {
|
closeTabRequested$(): Observable<string> {
|
||||||
return this.closeTabSubject.asObservable();
|
return this.closeTabSubject.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moveSessionLeft(data: string): void {
|
||||||
|
this.moveSessionLeftSubject.next(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
moveSessionLeftRequested$(): Observable<string> {
|
||||||
|
return this.moveSessionLeftSubject.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
moveSessionRight(data: string): void {
|
||||||
|
this.moveSessionRightSubject.next(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
moveSessionRightRequested$(): Observable<string> {
|
||||||
|
return this.moveSessionRightSubject.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
selectSessionLeft(data: string): void {
|
||||||
|
this.selectSessionLeftSubject.next(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
selectSessionLeftRequested$(): Observable<string> {
|
||||||
|
return this.selectSessionLeftSubject.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
selectSessionRight(data: string): void {
|
||||||
|
this.selectSessionRightSubject.next(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
selectSessionRightRequested$(): Observable<string> {
|
||||||
|
return this.selectSessionRightSubject.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -52,14 +52,65 @@ export class EditorsComponent {
|
|||||||
this.loadSubscribers();
|
this.loadSubscribers();
|
||||||
this.loadMainSubscribers();
|
this.loadMainSubscribers();
|
||||||
|
|
||||||
let editor = this.createEditor();
|
let leftEditor = this.createEditor();
|
||||||
this.activeEditor = editor.instance.uuid;
|
let rightEditor = this.createEditor();
|
||||||
editor.instance.isDefault = true;
|
|
||||||
|
|
||||||
this.createEditor();
|
this.activeEditor = leftEditor.instance.uuid;
|
||||||
|
leftEditor.instance.isDefault = true;
|
||||||
|
leftEditor.instance.rightSiblingUUID = rightEditor.instance.uuid;
|
||||||
|
rightEditor.instance.leftSiblingUUID = leftEditor.instance.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSubscribers() {
|
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(
|
this.editorsService.newActiveEditor$().pipe(
|
||||||
takeUntil(this.unsubscribe)
|
takeUntil(this.unsubscribe)
|
||||||
).subscribe((uuid: string) => {
|
).subscribe((uuid: string) => {
|
||||||
@ -96,6 +147,7 @@ export class EditorsComponent {
|
|||||||
this.files.delete(path);
|
this.files.delete(path);
|
||||||
window.fs.closeFile(path);
|
window.fs.closeFile(path);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMainSubscribers() {
|
loadMainSubscribers() {
|
||||||
|
@ -12,6 +12,8 @@ export class NewtonEditorBase {
|
|||||||
@Input() editorSettings!: typeof EditorSettings;
|
@Input() editorSettings!: typeof EditorSettings;
|
||||||
editor!: any;
|
editor!: any;
|
||||||
uuid!: string;
|
uuid!: string;
|
||||||
|
leftSiblingUUID!: string;
|
||||||
|
rightSiblingUUID!: string;
|
||||||
cutBuffer: string = "";
|
cutBuffer: string = "";
|
||||||
timerId: number = -1;
|
timerId: number = -1;
|
||||||
activeFile!: NewtonFile;
|
activeFile!: NewtonFile;
|
||||||
|
@ -56,7 +56,7 @@ export class NewtonEditorComponent extends NewtonEditorBase {
|
|||||||
this.editor.commands.addCommands([
|
this.editor.commands.addCommands([
|
||||||
{
|
{
|
||||||
name: "openCommandPalette2",
|
name: "openCommandPalette2",
|
||||||
bindKey: {linux: "Command-Shift-/|F1", win: "Ctrl-Shift-/|F1"},
|
bindKey: {linux: "Command-shift-/|F1", win: "ctrl-shift-/|F1"},
|
||||||
exec: () => {
|
exec: () => {
|
||||||
this.commander();
|
this.commander();
|
||||||
},
|
},
|
||||||
@ -68,6 +68,34 @@ export class NewtonEditorComponent extends NewtonEditorBase {
|
|||||||
this.search();
|
this.search();
|
||||||
},
|
},
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
}, {
|
||||||
|
name: "selectSessionLeft",
|
||||||
|
bindKey: {win: "ctrl-pageup", mac: "ctrl-pageup"},
|
||||||
|
exec: () => {
|
||||||
|
this.selectSessionLeft();
|
||||||
|
},
|
||||||
|
readOnly: false
|
||||||
|
}, {
|
||||||
|
name: "selectSessionRight",
|
||||||
|
bindKey: {win: "ctrl-pagedown", mac: "ctrl-pagedown"},
|
||||||
|
exec: () => {
|
||||||
|
this.selectSessionRight();
|
||||||
|
},
|
||||||
|
readOnly: false
|
||||||
|
}, {
|
||||||
|
name: "moveSessionLeft",
|
||||||
|
bindKey: {win: "ctrl-shift-up", mac: "ctrl-shift-up"},
|
||||||
|
exec: () => {
|
||||||
|
this.moveSessionLeft();
|
||||||
|
},
|
||||||
|
readOnly: false
|
||||||
|
}, {
|
||||||
|
name: "moveSessionRight",
|
||||||
|
bindKey: {win: "ctrl-shift-down", mac: "ctrl-shift-down"},
|
||||||
|
exec: () => {
|
||||||
|
this.moveSessionRight();
|
||||||
|
},
|
||||||
|
readOnly: false
|
||||||
}, {
|
}, {
|
||||||
name: "movelinesUp",
|
name: "movelinesUp",
|
||||||
bindKey: {win: "ctrl-up", mac: "ctrl-up"},
|
bindKey: {win: "ctrl-up", mac: "ctrl-up"},
|
||||||
@ -151,8 +179,8 @@ export class NewtonEditorComponent extends NewtonEditorBase {
|
|||||||
|
|
||||||
|
|
||||||
// Note: https://ajaxorg.github.io/ace-api-docs/interfaces/ace.Ace.EditorEvents.html
|
// Note: https://ajaxorg.github.io/ace-api-docs/interfaces/ace.Ace.EditorEvents.html
|
||||||
this.editor.on("changeStatus", (e) => {
|
this.editor.on("focus", (e) => {
|
||||||
console.log(e);
|
this.updateInfoBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.editor.on("click", () => {
|
this.editor.on("click", () => {
|
||||||
@ -205,4 +233,20 @@ export class NewtonEditorComponent extends NewtonEditorBase {
|
|||||||
this.updateInfoBar();
|
this.updateInfoBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public selectSessionLeft() {
|
||||||
|
this.editorsService.selectSessionLeft(this.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public selectSessionRight() {
|
||||||
|
this.editorsService.selectSessionRight(this.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public moveSessionLeft() {
|
||||||
|
this.editorsService.moveSessionLeft(this.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public moveSessionRight() {
|
||||||
|
this.editorsService.moveSessionRight(this.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user