mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-03-09 13:00:53 +01:00
a bare enter will focus the last line in a window
This commit is contained in:
parent
65e23f9f48
commit
d7d6067fbb
27
src/main.tsx
27
src/main.tsx
@ -168,8 +168,8 @@ class LineText extends React.Component<{sw : ScreenWindow, line : LineType}, {}>
|
|||||||
render() {
|
render() {
|
||||||
let {sw, line} = this.props;
|
let {sw, line} = this.props;
|
||||||
let formattedTime = getLineDateStr(line.ts);
|
let formattedTime = getLineDateStr(line.ts);
|
||||||
let isSelected = (sw.selectedLine.get() == line.linenum);
|
let isSelected = mobx.computed(() => (sw.selectedLine.get() == line.linenum), {name: "computed-isSelected"}).get();
|
||||||
let isFocused = (sw.focusType.get() == "cmd");
|
let isFocused = mobx.computed(() => (sw.focusType.get() == "cmd"), {name: "computed-isFocused"}).get();
|
||||||
return (
|
return (
|
||||||
<div className="line line-text" data-lineid={line.lineid} data-linenum={line.linenum} data-windowid={line.windowid} onClick={this.clickHandler}>
|
<div className="line line-text" data-lineid={line.lineid} data-linenum={line.linenum} data-windowid={line.windowid} onClick={this.clickHandler}>
|
||||||
<div className={cn("focus-indicator", {"selected": isSelected}, {"active": isSelected && isFocused})}/>
|
<div className={cn("focus-indicator", {"selected": isSelected}, {"active": isSelected && isFocused})}/>
|
||||||
@ -391,6 +391,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
|
|||||||
}
|
}
|
||||||
if (snapshot.height != curHeight && this.props.onHeightChange != null) {
|
if (snapshot.height != curHeight && this.props.onHeightChange != null) {
|
||||||
this.props.onHeightChange(line.linenum, curHeight, snapshot.height);
|
this.props.onHeightChange(line.linenum, curHeight, snapshot.height);
|
||||||
|
// console.log("line height change: ", line.linenum, snapshot.height, "=>", curHeight);
|
||||||
}
|
}
|
||||||
this.checkLoad();
|
this.checkLoad();
|
||||||
this.checkStateDiffLoad();
|
this.checkStateDiffLoad();
|
||||||
@ -479,7 +480,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
|
|||||||
<div className="ts">{formattedTime}</div>
|
<div className="ts">{formattedTime}</div>
|
||||||
<div className="termopts">
|
<div className="termopts">
|
||||||
({termOpts.rows}x{termOpts.cols})
|
({termOpts.rows}x{termOpts.cols})
|
||||||
<If condition={cmd.isRunning() && false}><i onClick={this.doResizeButton} className="resize-button fa fa-arrows-alt"/></If>
|
<If condition={cmd.isRunning() && false}><i onClick={this.handleResizeButton} className="resize-button fa fa-arrows-alt"/></If>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div key="meta2" className="meta">
|
<div key="meta2" className="meta">
|
||||||
@ -631,8 +632,19 @@ class TextAreaInput extends React.Component<{}, {}> {
|
|||||||
if (e.code == "Enter") {
|
if (e.code == "Enter") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!ctrlMod) {
|
if (!ctrlMod) {
|
||||||
setTimeout(() => GlobalModel.inputModel.uiSubmitCommand(), 0);
|
if (GlobalModel.inputModel.isEmpty()) {
|
||||||
return;
|
let activeWindow = GlobalModel.getActiveWindow();
|
||||||
|
let activeSW = GlobalModel.getActiveSW();
|
||||||
|
if (activeSW != null && activeWindow != null && activeWindow.lines.length > 0) {
|
||||||
|
activeSW.setSelectedLine(0);
|
||||||
|
GlobalCommandRunner.swSelectLine("E");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setTimeout(() => GlobalModel.inputModel.uiSubmitCommand(), 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
e.target.setRangeText("\n", e.target.selectionStart, e.target.selectionEnd, "end");
|
e.target.setRangeText("\n", e.target.selectionStart, e.target.selectionEnd, "end");
|
||||||
GlobalModel.inputModel.setCurLine(e.target.value);
|
GlobalModel.inputModel.setCurLine(e.target.value);
|
||||||
@ -1874,8 +1886,8 @@ class LinesView extends React.Component<{sw : ScreenWindow, width : number, line
|
|||||||
lastOffsetWidth : number = 0;
|
lastOffsetWidth : number = 0;
|
||||||
ignoreNextScroll : boolean = false;
|
ignoreNextScroll : boolean = false;
|
||||||
visibleMap : Map<string, OV<boolean>>; // lineid => OV<vis>
|
visibleMap : Map<string, OV<boolean>>; // lineid => OV<vis>
|
||||||
lastSelectedLine : number = 0;
|
|
||||||
lastLinesLength : number = 0;
|
lastLinesLength : number = 0;
|
||||||
|
lastSelectedLine : number = 0;
|
||||||
|
|
||||||
computeAnchorLine_throttled : () => void;
|
computeAnchorLine_throttled : () => void;
|
||||||
computeVisibleMap_debounced : () => void;
|
computeVisibleMap_debounced : () => void;
|
||||||
@ -2074,6 +2086,9 @@ class LinesView extends React.Component<{sw : ScreenWindow, width : number, line
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let newLine = sw.selectedLine.get();
|
let newLine = sw.selectedLine.get();
|
||||||
|
if (newLine == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.setLineVisible(newLine, true);
|
this.setLineVisible(newLine, true);
|
||||||
// console.log("update selected line", this.lastSelectedLine, "=>", newLine, sprintf("anchor=%d:%d", sw.anchorLine, sw.anchorOffset));
|
// console.log("update selected line", this.lastSelectedLine, "=>", newLine, sprintf("anchor=%d:%d", sw.anchorLine, sw.anchorOffset));
|
||||||
let viewInfo = this.getLineViewInfo(newLine);
|
let viewInfo = this.getLineViewInfo(newLine);
|
||||||
|
16
src/model.ts
16
src/model.ts
@ -422,6 +422,9 @@ class ScreenWindow {
|
|||||||
if (lines == null || lines.length == 0) {
|
if (lines == null || lines.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (lineNum == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
for (let i=0; i<lines.length; i++) {
|
for (let i=0; i<lines.length; i++) {
|
||||||
let line = lines[i];
|
let line = lines[i];
|
||||||
if (line.linenum == lineNum) {
|
if (line.linenum == lineNum) {
|
||||||
@ -1406,6 +1409,10 @@ class InputModel {
|
|||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEmpty() : boolean {
|
||||||
|
return this.getCurLine().trim() == "";
|
||||||
|
}
|
||||||
|
|
||||||
resetInputMode() : void {
|
resetInputMode() : void {
|
||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
this.setInputMode(null);
|
this.setInputMode(null);
|
||||||
@ -2054,6 +2061,7 @@ class Model {
|
|||||||
uicontext : this.getUIContext(),
|
uicontext : this.getUIContext(),
|
||||||
interactive : interactive,
|
interactive : interactive,
|
||||||
};
|
};
|
||||||
|
// console.log("CMD", pk.metacmd + (pk.metasubcmd != null ? ":" + pk.metasubcmd : ""), pk.args, pk.kwargs, pk.interactive);
|
||||||
this.submitCommandPacket(pk, interactive);
|
this.submitCommandPacket(pk, interactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2345,6 +2353,14 @@ class CommandRunner {
|
|||||||
GlobalModel.submitCommand("sw", "set", null, kwargs, true);
|
GlobalModel.submitCommand("sw", "set", null, kwargs, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLineHeight(lineArg : string, height : number) {
|
||||||
|
let kwargs : Record<string, string> = {};
|
||||||
|
kwargs["line"] = lineArg;
|
||||||
|
kwargs["height"] = String(height);
|
||||||
|
kwargs["hohist"] = "1";
|
||||||
|
GlobalModel.submitCommand("line", "setheight", null, kwargs, false);
|
||||||
|
}
|
||||||
|
|
||||||
swSetAnchor(sessionId : string, screenId : string, windowId : string, anchorVal : string) : void {
|
swSetAnchor(sessionId : string, screenId : string, windowId : string, anchorVal : string) : void {
|
||||||
let kwargs = {
|
let kwargs = {
|
||||||
"nohist": "1",
|
"nohist": "1",
|
||||||
|
Loading…
Reference in New Issue
Block a user