l-cmd model update

This commit is contained in:
sawka
2022-10-07 14:37:25 -07:00
parent 0053ebbfa9
commit e7ceecee5b
+13
View File
@@ -72,6 +72,7 @@ type ElectronApi = {
getId : () => string,
onTCmd : (callback : (mods : KeyModsType) => void) => void,
onICmd : (callback : (mods : KeyModsType) => void) => void,
onLCmd : (callback : (mods : KeyModsType) => void) => void,
onHCmd : (callback : (mods : KeyModsType) => void) => void,
onMetaArrowUp : (callback : () => void) => void,
onMetaArrowDown : (callback : () => void) => void,
@@ -264,6 +265,7 @@ class ScreenWindow {
selectedLine : OV<number>;
scrollTop : OV<number>;
shouldFollow : OV<boolean> = mobx.observable.box(true);
focusType : OV<"input"|"lines"> = mobx.observable.box("input");
// cmdid => TermWrap
terms : Record<string, TermWrap> = {};
@@ -290,6 +292,12 @@ class ScreenWindow {
})();
}
setFocusType(ftype : "input" | "lines") : void {
mobx.action(() => {
this.focusType.set(ftype);
})();
}
setScrollTop(scrollTop : number) : void {
GlobalCommandRunner.swSetScrollTop(this.sessionId, this.screenId, this.windowId, scrollTop);
}
@@ -1341,6 +1349,7 @@ class Model {
this.inputModel = new InputModel();
getApi().onTCmd(this.onTCmd.bind(this));
getApi().onICmd(this.onICmd.bind(this));
getApi().onLCmd(this.onLCmd.bind(this));
getApi().onHCmd(this.onHCmd.bind(this));
getApi().onMetaArrowUp(this.onMetaArrowUp.bind(this));
getApi().onMetaArrowDown(this.onMetaArrowDown.bind(this));
@@ -1415,6 +1424,10 @@ class Model {
this.inputModel.giveFocus();
}
onLCmd(e : any, mods : KeyModsType) {
this.inputModel.giveFocus();
}
onHCmd(e : any, mods : KeyModsType) {
let focusedLine = this.getFocusedLine();
if (focusedLine != null && focusedLine.cmdInputFocus) {