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
@ -186,11 +186,10 @@ class Prompt extends React.Component<{rptr : RemotePtrType, rstate : RemoteState
|
||||
}
|
||||
|
||||
@mobxReact.observer
|
||||
class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width : number, staticRender: boolean, visible : OV<boolean>, onHeightChange : HeightChangeCallbackType}, {}> {
|
||||
class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width : number, staticRender : boolean, visible : OV<boolean>, onHeightChange : HeightChangeCallbackType}, {}> {
|
||||
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>
|
||||
|
34
src/model.ts
34
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) {
|
||||
@ -1926,8 +1947,9 @@ class Model {
|
||||
metacmd: "eval",
|
||||
args: [cmdStr],
|
||||
kwargs: null,
|
||||
uicontext : this.getUIContext(),
|
||||
interactive : interactive,
|
||||
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