diff --git a/src/main.tsx b/src/main.tsx index dd5a06c1..d06f8055 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -12,7 +12,7 @@ import type {SessionDataType, LineType, CmdDataType, RemoteType, RemoteStateType import type * as T from "./types"; import localizedFormat from 'dayjs/plugin/localizedFormat'; import {GlobalModel, GlobalCommandRunner, Session, Cmd, ScreenLines, Screen, riToRPtr, TabColors, RemoteColors} from "./model"; -import {windowWidthToCols, windowHeightToRows, termHeightFromRows, termWidthFromCols} from "./textmeasure"; +import {windowWidthToCols, windowHeightToRows, termHeightFromRows, termWidthFromCols, getMonoFontSize} from "./textmeasure"; import {isModKeyPress, boundInt, sortAndFilterRemotes} from "./util"; import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' @@ -116,6 +116,21 @@ class TextAreaInput extends React.Component<{onHeightChange : () => void}, {}> { } } + getTextAreaMaxCols() : number { + let taElem = this.mainInputRef.current; + if (taElem == null) { + return 0; + } + let cs = window.getComputedStyle(taElem); + let padding = parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight); + let borders = parseFloat(cs.borderLeft) + parseFloat(cs.borderRight); + let contentWidth = taElem.clientWidth - padding - borders; + let fontSize = getMonoFontSize(parseInt(cs.fontSize)); + let maxCols = Math.floor(contentWidth / fontSize.width); + console.log("getareamaxcols", contentWidth, fontSize, maxCols); + return maxCols; + } + checkHeight(shouldFire : boolean) : void { let elem = this.controlRef.current; if (elem == null) { @@ -559,9 +574,10 @@ class TextAreaInput extends React.Component<{onHeightChange : () => void}, {}> { if (activeScreen != null) { activeScreen.focusType.get(); // for reaction } + let computedHeight = (displayLines*24)+14; return (