diff --git a/src/main.tsx b/src/main.tsx index b194d99a..30b50126 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -485,7 +485,11 @@ class TextAreaInput extends React.Component<{}, {}> { } if (e.code == "Escape") { e.preventDefault(); - GlobalModel.inputModel.toggleInfoMsg(); + let inputModel = GlobalModel.inputModel; + inputModel.toggleInfoMsg(); + if (inputModel.inputMode.get() != null) { + inputModel.resetInputMode(); + } return; } if (e.code == "KeyC" && e.getModifierState("Control")) { @@ -562,6 +566,11 @@ class TextAreaInput extends React.Component<{}, {}> { inputModel.grabSelectedHistoryItem(); return; } + if (e.code == "KeyG" && e.getModifierState("Control")) { + e.preventDefault(); + inputModel.resetInput(); + return; + } if (e.code == "KeyC" && e.getModifierState("Control")) { e.preventDefault(); inputModel.resetInput(); @@ -1631,6 +1640,7 @@ class CmdInput extends React.Component<{}, {}> { let hasInfo = (infoMsg != null); let remoteShow = (infoMsg != null && !isBlank(infoMsg.ptyremoteid)); let focusVal = inputModel.physicalInputFocused.get(); + let inputMode : string = inputModel.inputMode.get(); return (
@@ -1652,10 +1662,12 @@ class CmdInput extends React.Component<{}, {}> {
-
-
-
{remoteStr}
-
+
+ +
+
{inputMode}
+
+
diff --git a/src/model.ts b/src/model.ts index 79816a5f..d35a4d48 100644 --- a/src/model.ts +++ b/src/model.ts @@ -176,7 +176,7 @@ class Cmd { } handleData(data : string, termWrap : TermWrap) : void { - console.log("handle data", {data: data}); + // console.log("handle data", {data: data}); if (!this.isRunning()) { return; } @@ -848,6 +848,7 @@ class InputModel { remoteTermWrapFocus : OV = mobx.observable.box(false, {name: "remoteTermWrapFocus"}); showNoInputMsg : OV = mobx.observable.box(false); showNoInputTimeoutId : any = null; + inputMode : OV = mobx.observable.box(null); // focus inputFocused : OV = mobx.observable.box(false); @@ -866,6 +867,12 @@ class InputModel { })(); } + setInputMode(inputMode : null | "comment" | "global") : void { + mobx.action(() => { + this.inputMode.set(inputMode); + })(); + } + setShowNoInputMsg(val : boolean) { mobx.action(() => { if (this.showNoInputTimeoutId != null) { @@ -1365,9 +1372,24 @@ class InputModel { })(); } + resetInputMode() : void { + mobx.action(() => { + inputModel.setInputMode(null); + inputModel.setCurLine(""); + })(); + } + setCurLine(val : string) : void { let hidx = this.historyIndex.get(); mobx.action(() => { + if (val == "\" ") { + this.setInputMode("comment"); + val = ""; + } + if (val == "//") { + this.setInputMode("global"); + val = ""; + } if (this.modHistory.length <= hidx) { this.modHistory.length = hidx + 1; } @@ -1379,6 +1401,7 @@ class InputModel { mobx.action(() => { this.setHistoryShow(false); this.infoShow.set(false); + this.inputMode.set(null); this.resetHistory(); this.dropModHistory(false); this.infoMsg.set(null); @@ -2165,7 +2188,7 @@ class CommandRunner { } resizeWindow(windowId : string, cols : number) { - GlobalModel.submitCommand("window", "resize", null, {"nohist": "1", "window": windowId, "cols": String(cols)}, false); + GlobalModel.submitCommand("sw", "resize", null, {"nohist": "1", "window": windowId, "cols": String(cols)}, false); } showRemote(remoteid : string) { diff --git a/src/sh2.less b/src/sh2.less index 8aa4d793..c775691b 100644 --- a/src/sh2.less +++ b/src/sh2.less @@ -787,6 +787,16 @@ body .xterm .xterm-viewport { color: white; } + &.inputmode-global .cmd-quick-context .button { + color: black; + background-color: @tab-green !important; + } + + &.inputmode-comment .cmd-quick-context .button { + color: black; + background-color: @tab-blue !important; + } + .cmd-exec .button { background-color: #000 !important; color: #d3d7cf;