mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-17 20:51:55 +01:00
fix cmdinput expand size calc
This commit is contained in:
parent
e76d74ada4
commit
8ffd537bb7
@ -97,6 +97,7 @@
|
||||
overflow-wrap: anywhere;
|
||||
border-color: transparent;
|
||||
border: none;
|
||||
font-family: @terminal-font;
|
||||
&.display-disabled {
|
||||
background-color: #444;
|
||||
}
|
@ -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<V> = mobx.IObservableValue<V>;
|
||||
@mobxReact.observer
|
||||
class CmdInput extends React.Component<{}, {}> {
|
||||
cmdInputRef: React.RefObject<any> = React.createRef();
|
||||
promptRef: React.RefObject<any> = 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<{}, {}> {
|
||||
</If>
|
||||
<div key="prompt" className="cmd-input-context">
|
||||
<div className="has-text-white">
|
||||
<Prompt rptr={rptr} festate={feState} />
|
||||
<span ref={this.promptRef}><Prompt rptr={rptr} festate={feState} /></span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
|
@ -13,7 +13,6 @@ import type { HistoryItem, HistoryQueryOpts } from "../../../types/types";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import { GlobalModel } from "../../../model/model";
|
||||
import { isBlank } from "../../../util/util";
|
||||
import "./cmdInput.less";
|
||||
|
||||
dayjs.extend(localizedFormat);
|
||||
|
||||
|
@ -9,7 +9,6 @@ import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import { GlobalModel } from "../../../model/model";
|
||||
import { makeExternLink } from "../../../util/util";
|
||||
import "./cmdInput.less";
|
||||
|
||||
dayjs.extend(localizedFormat);
|
||||
|
||||
|
@ -9,7 +9,6 @@ import cn from "classnames";
|
||||
import { GlobalModel, GlobalCommandRunner } from "../../../model/model";
|
||||
import { getMonoFontSize } from "../../../util/textmeasure";
|
||||
import { isModKeyPress, hasNoModifiers } from "../../../util/util";
|
||||
import "./cmdInput.less";
|
||||
|
||||
function pageSize(div: any): number {
|
||||
if (div == null) {
|
||||
@ -72,7 +71,7 @@ class TextAreaInput extends React.Component<{ onHeightChange: () => 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
|
||||
|
Loading…
Reference in New Issue
Block a user