From 8ffd537bb7c28a4ec5f1b55097b4aa68cc06f4a0 Mon Sep 17 00:00:00 2001 From: sawka Date: Tue, 7 Nov 2023 01:14:26 -0800 Subject: [PATCH] fix cmdinput expand size calc --- .../cmdinput/{cmdInput.less => cmdinput.less} | 1 + src/app/workspace/cmdinput/cmdinput.tsx | 12 +++++++++--- src/app/workspace/cmdinput/historyinfo.tsx | 1 - src/app/workspace/cmdinput/infomsg.tsx | 1 - src/app/workspace/cmdinput/textareainput.tsx | 16 ++-------------- 5 files changed, 12 insertions(+), 19 deletions(-) rename src/app/workspace/cmdinput/{cmdInput.less => cmdinput.less} (99%) diff --git a/src/app/workspace/cmdinput/cmdInput.less b/src/app/workspace/cmdinput/cmdinput.less similarity index 99% rename from src/app/workspace/cmdinput/cmdInput.less rename to src/app/workspace/cmdinput/cmdinput.less index 6b5c63c07..3c9224a88 100644 --- a/src/app/workspace/cmdinput/cmdInput.less +++ b/src/app/workspace/cmdinput/cmdinput.less @@ -97,6 +97,7 @@ overflow-wrap: anywhere; border-color: transparent; border: none; + font-family: @terminal-font; &.display-disabled { background-color: #444; } diff --git a/src/app/workspace/cmdinput/cmdinput.tsx b/src/app/workspace/cmdinput/cmdinput.tsx index 10b4c1ffc..7d17304dc 100644 --- a/src/app/workspace/cmdinput/cmdinput.tsx +++ b/src/app/workspace/cmdinput/cmdinput.tsx @@ -17,7 +17,7 @@ import { InfoMsg } from "./infomsg"; import { HistoryInfo } from "./historyinfo"; import { Prompt } from "../../common/prompt/prompt"; import { ReactComponent as ExecIcon } from "../../assets/icons/exec.svg"; -import "./cmdInput.less"; +import "./cmdinput.less"; dayjs.extend(localizedFormat); @@ -28,6 +28,7 @@ type OV = mobx.IObservableValue; @mobxReact.observer class CmdInput extends React.Component<{}, {}> { cmdInputRef: React.RefObject = React.createRef(); + promptRef: React.RefObject = React.createRef(); componentDidMount() { this.updateCmdInputHeight(); @@ -62,7 +63,12 @@ class CmdInput extends React.Component<{}, {}> { } @boundMethod - cmdInputClick(): void { + cmdInputClick(e: any): void { + if (this.promptRef.current != null) { + if (this.promptRef.current.contains(e.target)) { + return; + } + } GlobalModel.inputModel.giveFocus(); } @@ -135,7 +141,7 @@ class CmdInput extends React.Component<{}, {}> {
- +
void }, {}> 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); + let maxCols = Math.floor(contentWidth / Math.ceil(fontSize.width)); return maxCols; } @@ -388,7 +387,6 @@ class TextAreaInput extends React.Component<{ onHeightChange: () => void }, {}> let cutValue = value.substr(0, selStart); let restValue = value.substr(selStart); let cmdLineUpdate = { cmdline: restValue, cursorpos: 0 }; - console.log("ss", selStart, value, "[" + cutValue + "]", "[" + restValue + "]"); navigator.clipboard.writeText(cutValue); GlobalModel.inputModel.updateCmdLine(cmdLineUpdate); } @@ -426,7 +424,6 @@ class TextAreaInput extends React.Component<{ onHeightChange: () => void }, {}> let initial = true; for (; cutSpot >= 0; cutSpot--) { let ch = value[cutSpot]; - console.log(cutSpot, "[" + ch + "]"); if (ch == " " && initial) { continue; } @@ -440,15 +437,6 @@ class TextAreaInput extends React.Component<{ onHeightChange: () => void }, {}> let prevValue = value.slice(0, cutSpot); let restValue = value.slice(selStart); let cmdLineUpdate = { cmdline: prevValue + restValue, cursorpos: prevValue.length }; - console.log( - "ss", - selStart, - value, - "prev[" + prevValue + "]", - "cut[" + cutValue + "]", - "rest[" + restValue + "]" - ); - console.log(" ", cmdLineUpdate); navigator.clipboard.writeText(cutValue); GlobalModel.inputModel.updateCmdLine(cmdLineUpdate); } @@ -548,7 +536,7 @@ class TextAreaInput extends React.Component<{ onHeightChange: () => void }, {}> if (activeScreen != null) { activeScreen.focusType.get(); // for reaction } - let termFontSize = GlobalModel.termFontSize.get(); + let termFontSize = 14; // fontSize*1.5 (line-height) + 2 * 0.5em padding let computedInnerHeight = displayLines * (termFontSize * 1.5) + 2 * 0.5 * termFontSize; // inner height + 2*1em padding