mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
cleanups for terminal interaction
This commit is contained in:
parent
4744eaa491
commit
c0b3db19d4
@ -190,7 +190,6 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
|
||||
termLoaded : mobx.IObservableValue<boolean> = mobx.observable.box(false);
|
||||
lineRef : React.RefObject<any> = React.createRef();
|
||||
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
@ -367,7 +366,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={cn("terminal-wrapper", {"focus": isFocused})}>
|
||||
<div className={cn("terminal-wrapper", {"focus": isFocused}, {"cmd-done": !cmd.isRunning()})}>
|
||||
<If condition={!isFocused}>
|
||||
<div className="term-block" onClick={this.clickTermBlock}></div>
|
||||
</If>
|
||||
|
30
src/model.ts
30
src/model.ts
@ -40,6 +40,10 @@ function cmdStatusIsRunning(status : string) : boolean {
|
||||
return status == "running" || status == "detached";
|
||||
}
|
||||
|
||||
function keyHasNoMods(e : any) {
|
||||
return !e.shiftKey && !e.ctrlKey && !e.metaKey && !e.altKey;
|
||||
}
|
||||
|
||||
type OV<V> = mobx.IObservableValue<V>;
|
||||
type OArr<V> = mobx.IObservableArray<V>;
|
||||
type OMap<K,V> = mobx.ObservableMap<K,V>;
|
||||
@ -480,12 +484,29 @@ class ScreenWindow {
|
||||
}
|
||||
}
|
||||
|
||||
termCustomKeyHandler(e : any, termWrap : TermWrap) : boolean {
|
||||
if (e.type != "keydown" || isModKeyPress(e)) {
|
||||
return termWrap.isRunning;
|
||||
isTermCapturedKey(e : any) : boolean {
|
||||
let keys = ["ArrowUp", "ArrowDown", "PageUp", "PageDown"];
|
||||
if (keys.includes(e.code) && keyHasNoMods(e)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
termCustomKeyHandler(e : any, termWrap : TermWrap) : boolean {
|
||||
if (termWrap.isRunning) {
|
||||
return true;
|
||||
}
|
||||
let isCaptured = this.isTermCapturedKey(e);
|
||||
if (!isCaptured) {
|
||||
return true;
|
||||
}
|
||||
if (e.type != "keydown" || isModKeyPress(e)) {
|
||||
return false;
|
||||
}
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
this.termCustomKeyHandlerInternal(e, termWrap);
|
||||
return termWrap.isRunning;
|
||||
return false;
|
||||
}
|
||||
|
||||
connectElem(elem : Element, line : LineType, cmd : Cmd, width : number) {
|
||||
@ -1928,6 +1949,7 @@ class Model {
|
||||
kwargs: null,
|
||||
uicontext: this.getUIContext(),
|
||||
interactive: interactive,
|
||||
rawstr: cmdStr,
|
||||
};
|
||||
if (!addToHistory) {
|
||||
pk.kwargs["nohist"] = "1";
|
||||
|
@ -430,6 +430,10 @@ html, body, #main {
|
||||
.terminal {
|
||||
margin-right: 8px; /* needed to show scrollbar */
|
||||
}
|
||||
|
||||
&.cmd-done .terminal .xterm-cursor {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,7 @@ type FeCmdPacketType = {
|
||||
metasubcmd? : string,
|
||||
args : string[],
|
||||
kwargs : Record<string, string>;
|
||||
rawstr? : string,
|
||||
uicontext : UIContextType,
|
||||
interactive : boolean,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user