checkpoint

This commit is contained in:
sawka 2022-10-06 14:00:24 -07:00
parent 61071de644
commit 7c0476350d
2 changed files with 57 additions and 1 deletions

View File

@ -638,6 +638,14 @@ class TextAreaInput extends React.Component<{}, {}> {
e.preventDefault();
inputModel.giveFocus();
}
else {
inputModel.setPhysicalInputFocused(true);
}
}
@boundMethod
handleMainBlur(e : any) {
GlobalModel.inputModel.setPhysicalInputFocused(false);
}
@boundMethod
@ -647,6 +655,14 @@ class TextAreaInput extends React.Component<{}, {}> {
e.preventDefault();
inputModel.giveFocus();
}
else {
inputModel.setPhysicalInputFocused(true);
}
}
@boundMethod
handleHistoryBlur(e : any) {
GlobalModel.inputModel.setPhysicalInputFocused(false);
}
render() {
@ -664,7 +680,7 @@ class TextAreaInput extends React.Component<{}, {}> {
}
return (
<div className="control cmd-input-control is-expanded">
<textarea spellCheck="false" id="main-cmd-input" onFocus={this.handleMainFocus} rows={displayLines} value={curLine} onKeyDown={this.onKeyDown} onChange={this.onChange} className={cn("textarea", {"display-disabled": disabled})}></textarea>
<textarea spellCheck="false" id="main-cmd-input" onFocus={this.handleMainFocus} onBlur={this.handleMainBlur} rows={displayLines} value={curLine} onKeyDown={this.onKeyDown} onChange={this.onChange} className={cn("textarea", {"display-disabled": disabled})}></textarea>
<input spellCheck="false" className="history-input" type="text" onFocus={this.handleHistoryFocus} onKeyDown={this.onHistoryKeyDown} onChange={this.handleHistoryInput} value={inputModel.historyQueryOpts.get().queryStr}/>
</div>
);

View File

@ -254,6 +254,7 @@ class ScreenWindow {
layout : OV<LayoutType>;
shouldFollow : OV<boolean> = mobx.observable.box(true);
lastCols : number;
selectedLine : OV<number> = mobx.observable.box(null);
// cmdid => TermWrap
terms : Record<string, TermWrap> = {};
@ -628,6 +629,11 @@ class InputModel {
showNoInputMsg : OV<boolean> = mobx.observable.box(false);
showNoInputTimeoutId : any = null;
// focus
inputFocused : OV<boolean> = mobx.observable.box(false);
lineFocused : OV<boolean> = mobx.observable.box(false);
physicalInputFocused : OV<boolean> = mobx.observable.box(false);
constructor() {
this.filteredHistoryItems = mobx.computed(() => {
return this._getFilteredHistoryItems();
@ -650,6 +656,34 @@ class InputModel {
})();
}
onInputFocus(isFocused : boolean) : void {
mobx.action(() => {
if (isFocused) {
this.inputFocused.set(true);
this.lineFocused.set(false);
}
else {
if (this.inputFocused.get()) {
this.inputFocused.set(false);
}
}
})();
}
onLineFocus(isFocused : boolean) : void {
mobx.action(() => {
if (isFocused) {
this.inputFocused.set(false);
this.lineFocused.set(true);
}
else {
if (this.lineFocused.get()) {
this.lineFocused.set(false);
}
}
})();
}
_focusCmdInput() : void {
let elem = document.getElementById("main-cmd-input");
if (elem != null) {
@ -673,6 +707,12 @@ class InputModel {
}
}
setPhysicalInputFocused(isFocused : boolean) : void {
mobx.action(() => {
this.physicalInputFocused.set(isFocused);
})();
}
getPtyRemoteId() : string {
let info = this.infoMsg.get();
if (info == null || isBlank(info.ptyremoteid)) {