From 65e23f9f48b41a85636c4ca10e0b222597a9384b Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 31 Jan 2023 21:25:11 -0800 Subject: [PATCH] partial resize handling --- src/main.tsx | 13 +++++++++---- src/model.ts | 14 +++++++------- src/sh2.less | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 74e57857..ccc3e122 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -419,6 +419,11 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width GlobalCommandRunner.lineStar(line.lineid, 0); } } + + @boundMethod + handleResizeButton() { + console.log("resize button"); + } render() { let {sw, line, width, staticRender, visible} = this.props; @@ -472,12 +477,12 @@ class LineCmd extends React.Component<{sw : ScreenWindow, line : LineType, width
{line.userid}
{formattedTime}
+
+ ({termOpts.rows}x{termOpts.cols}) + +
-
- {line.cmdid} - ({termOpts.rows}x{termOpts.cols}) -
{this.renderCmdText(cmd, remote)}
diff --git a/src/model.ts b/src/model.ts index cd0c1fde..f8722b89 100644 --- a/src/model.ts +++ b/src/model.ts @@ -28,7 +28,7 @@ type SWLinePtr = { }; function widthToCols(width : number) : number { - let cols = Math.trunc((width - 32) / DefaultCellWidth) - 1; + let cols = Math.trunc((width - 50) / DefaultCellWidth) - 1; cols = boundInt(cols, MinTermCols, MaxTermCols); return cols; } @@ -42,7 +42,7 @@ function termHeightFromRows(rows : number) : number { } function termRowsFromHeight(height : number) : number { - let rows = Math.floor((height - 80)/DefaultCellHeight); + let rows = Math.floor((height - 80)/DefaultCellHeight) - 1; if (rows <= 0) { rows = 1; } @@ -472,15 +472,15 @@ class ScreenWindow { if (!this.isActive() || cols == 0 || rows == 0) { return; } - this.lastRows = rows; - if (cols == this.lastCols) { + if (rows == this.lastRows && cols == this.lastCols) { return; } + this.lastRows = rows; this.lastCols = cols; for (let cmdid in this.terms) { this.terms[cmdid].resizeCols(cols); } - GlobalCommandRunner.resizeWindow(this.windowId, cols); + GlobalCommandRunner.resizeWindow(this.windowId, rows, cols); } getTermWrap(cmdId : string) : TermWrap { @@ -2281,8 +2281,8 @@ class CommandRunner { GlobalModel.submitCommand("screen", "close", [screen], {"nohist": "1"}, false); } - resizeWindow(windowId : string, cols : number) { - GlobalModel.submitCommand("sw", "resize", null, {"nohist": "1", "window": windowId, "cols": String(cols)}, false); + resizeWindow(windowId : string, rows : number, cols : number) { + GlobalModel.submitCommand("sw", "resize", null, {"nohist": "1", "window": windowId, "cols": String(cols), "rows": String(rows)}, false); } showRemote(remoteid : string) { diff --git a/src/sh2.less b/src/sh2.less index 84ef3357..19031593 100644 --- a/src/sh2.less +++ b/src/sh2.less @@ -559,6 +559,10 @@ html, body, #main { background-color: #222; } + &:hover .meta .termopts { + display: block; + } + .focus-indicator { position: absolute; display: none; @@ -680,6 +684,21 @@ html, body, #main { margin-top: 5px; font-size: 12px; } + + .termopts { + margin-left: 10px; + color: #aaa; + margin-top: 7px; + font-size: 12px; + .mono-font(10px); + display: none; + + .resize-button { + cursor: pointer; + padding-left: 3px; + padding-right: 3px; + } + } .metapart-mono { color: #ddd; @@ -861,6 +880,7 @@ body .xterm .xterm-viewport { .mono-font(); padding-bottom: calc(0.5em - 1px); padding-top: calc(0.5em - 1px); + resize: none; &:active, &:focus { border-color: white !important;