mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
input modes
This commit is contained in:
+17
-5
@@ -485,7 +485,11 @@ class TextAreaInput extends React.Component<{}, {}> {
|
|||||||
}
|
}
|
||||||
if (e.code == "Escape") {
|
if (e.code == "Escape") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
GlobalModel.inputModel.toggleInfoMsg();
|
let inputModel = GlobalModel.inputModel;
|
||||||
|
inputModel.toggleInfoMsg();
|
||||||
|
if (inputModel.inputMode.get() != null) {
|
||||||
|
inputModel.resetInputMode();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.code == "KeyC" && e.getModifierState("Control")) {
|
if (e.code == "KeyC" && e.getModifierState("Control")) {
|
||||||
@@ -562,6 +566,11 @@ class TextAreaInput extends React.Component<{}, {}> {
|
|||||||
inputModel.grabSelectedHistoryItem();
|
inputModel.grabSelectedHistoryItem();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (e.code == "KeyG" && e.getModifierState("Control")) {
|
||||||
|
e.preventDefault();
|
||||||
|
inputModel.resetInput();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (e.code == "KeyC" && e.getModifierState("Control")) {
|
if (e.code == "KeyC" && e.getModifierState("Control")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
inputModel.resetInput();
|
inputModel.resetInput();
|
||||||
@@ -1631,6 +1640,7 @@ class CmdInput extends React.Component<{}, {}> {
|
|||||||
let hasInfo = (infoMsg != null);
|
let hasInfo = (infoMsg != null);
|
||||||
let remoteShow = (infoMsg != null && !isBlank(infoMsg.ptyremoteid));
|
let remoteShow = (infoMsg != null && !isBlank(infoMsg.ptyremoteid));
|
||||||
let focusVal = inputModel.physicalInputFocused.get();
|
let focusVal = inputModel.physicalInputFocused.get();
|
||||||
|
let inputMode : string = inputModel.inputMode.get();
|
||||||
return (
|
return (
|
||||||
<div className={cn("cmd-input has-background-black", {"has-info": infoShow}, {"has-history": historyShow}, {"has-remote": remoteShow})}>
|
<div className={cn("cmd-input has-background-black", {"has-info": infoShow}, {"has-history": historyShow}, {"has-remote": remoteShow})}>
|
||||||
<div key="focus" className={cn("focus-indicator", {"active": focusVal})}/>
|
<div key="focus" className={cn("focus-indicator", {"active": focusVal})}/>
|
||||||
@@ -1652,10 +1662,12 @@ class CmdInput extends React.Component<{}, {}> {
|
|||||||
<Prompt rptr={rptr} rstate={remoteState}/>
|
<Prompt rptr={rptr} rstate={remoteState}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div key="input" className="cmd-input-field field has-addons">
|
<div key="input" className={cn("cmd-input-field field has-addons", (inputMode != null ? "inputmode-" + inputMode : null))}>
|
||||||
<div className="control cmd-quick-context">
|
<If condition={inputMode != null}>
|
||||||
<div className="button is-static">{remoteStr}</div>
|
<div className="control cmd-quick-context">
|
||||||
</div>
|
<div className="button is-static">{inputMode}</div>
|
||||||
|
</div>
|
||||||
|
</If>
|
||||||
<TextAreaInput/>
|
<TextAreaInput/>
|
||||||
<div className="control cmd-exec">
|
<div className="control cmd-exec">
|
||||||
<div onClick={GlobalModel.inputModel.uiSubmitCommand} className="button">
|
<div onClick={GlobalModel.inputModel.uiSubmitCommand} className="button">
|
||||||
|
|||||||
+25
-2
@@ -176,7 +176,7 @@ class Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleData(data : string, termWrap : TermWrap) : void {
|
handleData(data : string, termWrap : TermWrap) : void {
|
||||||
console.log("handle data", {data: data});
|
// console.log("handle data", {data: data});
|
||||||
if (!this.isRunning()) {
|
if (!this.isRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -848,6 +848,7 @@ class InputModel {
|
|||||||
remoteTermWrapFocus : OV<boolean> = mobx.observable.box(false, {name: "remoteTermWrapFocus"});
|
remoteTermWrapFocus : OV<boolean> = mobx.observable.box(false, {name: "remoteTermWrapFocus"});
|
||||||
showNoInputMsg : OV<boolean> = mobx.observable.box(false);
|
showNoInputMsg : OV<boolean> = mobx.observable.box(false);
|
||||||
showNoInputTimeoutId : any = null;
|
showNoInputTimeoutId : any = null;
|
||||||
|
inputMode : OV<null | "comment" | "global"> = mobx.observable.box(null);
|
||||||
|
|
||||||
// focus
|
// focus
|
||||||
inputFocused : OV<boolean> = mobx.observable.box(false);
|
inputFocused : OV<boolean> = 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) {
|
setShowNoInputMsg(val : boolean) {
|
||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
if (this.showNoInputTimeoutId != null) {
|
if (this.showNoInputTimeoutId != null) {
|
||||||
@@ -1365,9 +1372,24 @@ class InputModel {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetInputMode() : void {
|
||||||
|
mobx.action(() => {
|
||||||
|
inputModel.setInputMode(null);
|
||||||
|
inputModel.setCurLine("");
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
setCurLine(val : string) : void {
|
setCurLine(val : string) : void {
|
||||||
let hidx = this.historyIndex.get();
|
let hidx = this.historyIndex.get();
|
||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
|
if (val == "\" ") {
|
||||||
|
this.setInputMode("comment");
|
||||||
|
val = "";
|
||||||
|
}
|
||||||
|
if (val == "//") {
|
||||||
|
this.setInputMode("global");
|
||||||
|
val = "";
|
||||||
|
}
|
||||||
if (this.modHistory.length <= hidx) {
|
if (this.modHistory.length <= hidx) {
|
||||||
this.modHistory.length = hidx + 1;
|
this.modHistory.length = hidx + 1;
|
||||||
}
|
}
|
||||||
@@ -1379,6 +1401,7 @@ class InputModel {
|
|||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
this.setHistoryShow(false);
|
this.setHistoryShow(false);
|
||||||
this.infoShow.set(false);
|
this.infoShow.set(false);
|
||||||
|
this.inputMode.set(null);
|
||||||
this.resetHistory();
|
this.resetHistory();
|
||||||
this.dropModHistory(false);
|
this.dropModHistory(false);
|
||||||
this.infoMsg.set(null);
|
this.infoMsg.set(null);
|
||||||
@@ -2165,7 +2188,7 @@ class CommandRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resizeWindow(windowId : string, cols : number) {
|
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) {
|
showRemote(remoteid : string) {
|
||||||
|
|||||||
@@ -787,6 +787,16 @@ body .xterm .xterm-viewport {
|
|||||||
color: white;
|
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 {
|
.cmd-exec .button {
|
||||||
background-color: #000 !important;
|
background-color: #000 !important;
|
||||||
color: #d3d7cf;
|
color: #d3d7cf;
|
||||||
|
|||||||
Reference in New Issue
Block a user