diff --git a/src/main.tsx b/src/main.tsx index ccc3e122..4a417600 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -168,8 +168,8 @@ class LineText extends React.Component<{sw : ScreenWindow, line : LineType}, {}> render() { let {sw, line} = this.props; let formattedTime = getLineDateStr(line.ts); - let isSelected = (sw.selectedLine.get() == line.linenum); - let isFocused = (sw.focusType.get() == "cmd"); + let isSelected = mobx.computed(() => (sw.selectedLine.get() == line.linenum), {name: "computed-isSelected"}).get(); + let isFocused = mobx.computed(() => (sw.focusType.get() == "cmd"), {name: "computed-isFocused"}).get(); return (
@@ -391,6 +391,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width } if (snapshot.height != curHeight && this.props.onHeightChange != null) { this.props.onHeightChange(line.linenum, curHeight, snapshot.height); + // console.log("line height change: ", line.linenum, snapshot.height, "=>", curHeight); } this.checkLoad(); this.checkStateDiffLoad(); @@ -479,7 +480,7 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
{formattedTime}
({termOpts.rows}x{termOpts.cols}) - +
@@ -631,8 +632,19 @@ class TextAreaInput extends React.Component<{}, {}> { if (e.code == "Enter") { e.preventDefault(); if (!ctrlMod) { - setTimeout(() => GlobalModel.inputModel.uiSubmitCommand(), 0); - return; + if (GlobalModel.inputModel.isEmpty()) { + 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"); GlobalModel.inputModel.setCurLine(e.target.value); @@ -1874,8 +1886,8 @@ class LinesView extends React.Component<{sw : ScreenWindow, width : number, line lastOffsetWidth : number = 0; ignoreNextScroll : boolean = false; visibleMap : Map>; // lineid => OV - lastSelectedLine : number = 0; lastLinesLength : number = 0; + lastSelectedLine : number = 0; computeAnchorLine_throttled : () => void; computeVisibleMap_debounced : () => void; @@ -2074,6 +2086,9 @@ class LinesView extends React.Component<{sw : ScreenWindow, width : number, line return null; } let newLine = sw.selectedLine.get(); + if (newLine == 0) { + return; + } this.setLineVisible(newLine, true); // console.log("update selected line", this.lastSelectedLine, "=>", newLine, sprintf("anchor=%d:%d", sw.anchorLine, sw.anchorOffset)); let viewInfo = this.getLineViewInfo(newLine); diff --git a/src/model.ts b/src/model.ts index f8722b89..f59d0920 100644 --- a/src/model.ts +++ b/src/model.ts @@ -422,6 +422,9 @@ class ScreenWindow { if (lines == null || lines.length == 0) { return null; } + if (lineNum == 0) { + return null; + } for (let i=0; i { this.setInputMode(null); @@ -2054,6 +2061,7 @@ class Model { uicontext : this.getUIContext(), interactive : interactive, }; + // console.log("CMD", pk.metacmd + (pk.metasubcmd != null ? ":" + pk.metasubcmd : ""), pk.args, pk.kwargs, pk.interactive); this.submitCommandPacket(pk, interactive); } @@ -2345,6 +2353,14 @@ class CommandRunner { GlobalModel.submitCommand("sw", "set", null, kwargs, true); } + setLineHeight(lineArg : string, height : number) { + let kwargs : Record = {}; + 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 { let kwargs = { "nohist": "1",