mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-04-17 20:39:47 +02:00
input modes
This commit is contained in:
parent
c0b3db19d4
commit
babf4f392a
22
src/main.tsx
22
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 (
|
||||
<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})}/>
|
||||
@ -1652,10 +1662,12 @@ class CmdInput extends React.Component<{}, {}> {
|
||||
<Prompt rptr={rptr} rstate={remoteState}/>
|
||||
</div>
|
||||
</div>
|
||||
<div key="input" className="cmd-input-field field has-addons">
|
||||
<div className="control cmd-quick-context">
|
||||
<div className="button is-static">{remoteStr}</div>
|
||||
</div>
|
||||
<div key="input" className={cn("cmd-input-field field has-addons", (inputMode != null ? "inputmode-" + inputMode : null))}>
|
||||
<If condition={inputMode != null}>
|
||||
<div className="control cmd-quick-context">
|
||||
<div className="button is-static">{inputMode}</div>
|
||||
</div>
|
||||
</If>
|
||||
<TextAreaInput/>
|
||||
<div className="control cmd-exec">
|
||||
<div onClick={GlobalModel.inputModel.uiSubmitCommand} className="button">
|
||||
|
27
src/model.ts
27
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<boolean> = mobx.observable.box(false, {name: "remoteTermWrapFocus"});
|
||||
showNoInputMsg : OV<boolean> = mobx.observable.box(false);
|
||||
showNoInputTimeoutId : any = null;
|
||||
inputMode : OV<null | "comment" | "global"> = mobx.observable.box(null);
|
||||
|
||||
// focus
|
||||
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) {
|
||||
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) {
|
||||
|
10
src/sh2.less
10
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;
|
||||
|
Loading…
Reference in New Issue
Block a user