From 06c3a240b1f9771989dfd110e35bc19d5f15951d Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 23 Nov 2022 14:45:20 -0800 Subject: [PATCH] track rows in sw --- src/main.tsx | 19 ++++++++++++------- src/model.ts | 16 ++++------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index a96d1580..4e61d8e9 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2096,23 +2096,26 @@ class ScreenWindowView extends React.Component<{sw : ScreenWindow}, {}> { windowViewRef : React.RefObject; width : mobx.IObservableValue = mobx.observable.box(0, {name: "sw-view-width"}); - setWidth_debounced : (width : number) => void; + height : mobx.IObservableValue = mobx.observable.box(0, {name: "sw-view-height"}); + setSize_debounced : (width : number, height : number) => void; constructor(props : any) { super(props); - this.setWidth_debounced = debounce(1000, this.setWidth.bind(this)); + this.setSize_debounced = debounce(1000, this.setSize.bind(this)); this.windowViewRef = React.createRef(); } - setWidth(width : number) : void { + setSize(width : number, height : number) : void { mobx.action(() => { this.width.set(width); + this.height.set(height); let {sw} = this.props; let cols = widthToCols(width); - if (sw == null || cols == 0) { + let rows = termRowsFromHeight(height); + if (sw == null || cols == 0 || rows == 0) { return; } - sw.colsCallback(cols); + sw.termSizeCallback(rows, cols); })(); } @@ -2120,7 +2123,8 @@ class ScreenWindowView extends React.Component<{sw : ScreenWindow}, {}> { let wvElem = this.windowViewRef.current; if (wvElem != null) { let width = wvElem.offsetWidth; - this.setWidth(width); + let height = wvElem.offsetHeight; + this.setSize(width, height); this.rszObs = new ResizeObserver(this.handleResize.bind(this)); this.rszObs.observe(wvElem); } @@ -2138,7 +2142,8 @@ class ScreenWindowView extends React.Component<{sw : ScreenWindow}, {}> { } let entry = entries[0]; let width = entry.target.offsetWidth; - this.setWidth_debounced(width); + let height = entry.target.offsetHeight; + this.setSize_debounced(width, height); } getWindow() : Window { diff --git a/src/model.ts b/src/model.ts index 9b222b71..efd6d882 100644 --- a/src/model.ts +++ b/src/model.ts @@ -457,10 +457,11 @@ class ScreenWindow { return (this.sessionId == activeScreen.sessionId) && (this.screenId == activeScreen.screenId); } - colsCallback(cols : number) : void { - if (!this.isActive() || cols == 0) { + termSizeCallback(rows : number, cols : number) : void { + if (!this.isActive() || cols == 0 || rows == 0) { return; } + this.lastRows = rows; if (cols == this.lastCols) { return; } @@ -471,16 +472,6 @@ class ScreenWindow { GlobalCommandRunner.resizeWindow(this.windowId, cols); } - rowsCallback(rows : number) : void { - if (!this.isActive() || rows == 0) { - return; - } - if (rows == this.lastCols) { - return; - } - this.lastRows = rows; - } - getTermWrap(cmdId : string) : TermWrap { return this.terms[cmdId]; } @@ -1621,6 +1612,7 @@ class Model { windowid : null, remote : null, termopts : {}, + winsize: null, }; let session = this.getActiveSession(); if (session != null) {