mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-06 19:18:22 +01:00
cleanup input model
This commit is contained in:
parent
648d98f065
commit
29cd754358
@ -3,125 +3,22 @@
|
|||||||
|
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
import * as mobx from "mobx";
|
import * as mobx from "mobx";
|
||||||
import { sprintf } from "sprintf-js";
|
|
||||||
import { v4 as uuidv4 } from "uuid";
|
|
||||||
import { boundMethod } from "autobind-decorator";
|
import { boundMethod } from "autobind-decorator";
|
||||||
import { debounce } from "throttle-debounce";
|
import { isBlank } from "../util/util";
|
||||||
import * as mobxReact from "mobx-react";
|
|
||||||
import {
|
import {
|
||||||
handleJsonFetchResponse,
|
|
||||||
base64ToString,
|
|
||||||
stringToBase64,
|
|
||||||
base64ToArray,
|
|
||||||
genMergeData,
|
|
||||||
genMergeDataMap,
|
|
||||||
genMergeSimpleData,
|
|
||||||
boundInt,
|
|
||||||
isModKeyPress,
|
|
||||||
isBlank,
|
|
||||||
} from "../util/util";
|
|
||||||
import { TermWrap } from "../plugins/terminal/term";
|
|
||||||
import { PluginModel } from "../plugins/plugins";
|
|
||||||
import {
|
|
||||||
SessionDataType,
|
|
||||||
LineType,
|
|
||||||
RemoteType,
|
|
||||||
HistoryItem,
|
HistoryItem,
|
||||||
RemoteInstanceType,
|
|
||||||
RemotePtrType,
|
RemotePtrType,
|
||||||
CmdDataType,
|
|
||||||
FeCmdPacketType,
|
|
||||||
TermOptsType,
|
|
||||||
ScreenDataType,
|
|
||||||
ScreenOptsType,
|
|
||||||
PtyDataUpdateType,
|
|
||||||
ModelUpdateType,
|
|
||||||
UpdateMessage,
|
|
||||||
InfoType,
|
InfoType,
|
||||||
UIContextType,
|
|
||||||
HistoryInfoType,
|
HistoryInfoType,
|
||||||
HistoryQueryOpts,
|
HistoryQueryOpts,
|
||||||
FeInputPacketType,
|
|
||||||
RemoteInputPacketType,
|
|
||||||
ContextMenuOpts,
|
|
||||||
RendererContext,
|
|
||||||
RendererModel,
|
|
||||||
PtyDataType,
|
|
||||||
BookmarkType,
|
|
||||||
ClientDataType,
|
|
||||||
HistoryViewDataType,
|
|
||||||
AlertMessageType,
|
|
||||||
HistorySearchParams,
|
|
||||||
FocusTypeStrs,
|
|
||||||
ScreenLinesType,
|
|
||||||
HistoryTypeStrs,
|
HistoryTypeStrs,
|
||||||
RendererPluginType,
|
|
||||||
WindowSize,
|
|
||||||
WebShareOpts,
|
|
||||||
TermContextUnion,
|
|
||||||
RemoteEditType,
|
|
||||||
RemoteViewType,
|
|
||||||
CommandRtnType,
|
|
||||||
WebCmd,
|
|
||||||
WebRemote,
|
|
||||||
OpenAICmdInfoChatMessageType,
|
OpenAICmdInfoChatMessageType,
|
||||||
StatusIndicatorLevel,
|
|
||||||
} from "../types/types";
|
} from "../types/types";
|
||||||
import * as T from "../types/types";
|
import { StrWithPos } from "../types/types";
|
||||||
import { WSControl } from "./ws";
|
|
||||||
import {
|
|
||||||
getMonoFontSize,
|
|
||||||
windowWidthToCols,
|
|
||||||
windowHeightToRows,
|
|
||||||
termWidthFromCols,
|
|
||||||
termHeightFromRows,
|
|
||||||
} from "../util/textmeasure";
|
|
||||||
import dayjs from "dayjs";
|
|
||||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
||||||
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
||||||
import { getRendererContext, cmdStatusIsRunning } from "../app/line/lineutil";
|
|
||||||
import { MagicLayout } from "../app/magiclayout";
|
|
||||||
import { modalsRegistry } from "../app/common/modals/registry";
|
|
||||||
import * as appconst from "../app/appconst";
|
import * as appconst from "../app/appconst";
|
||||||
import { checkKeyPressed, adaptFromReactOrNativeKeyEvent, setKeyUtilPlatform } from "../util/keyutil";
|
import { OV } from "../types/types";
|
||||||
import { OV, OArr, OMap, CV } from "../types/types";
|
|
||||||
import { Session } from "./session";
|
|
||||||
import { GlobalCommandRunner } from "./commandrunner";
|
|
||||||
import { Model } from "./model";
|
import { Model } from "./model";
|
||||||
import { ScreenLines } from "./screenlines";
|
import { CommandRunner } from "./commandrunner";
|
||||||
|
|
||||||
dayjs.extend(customParseFormat);
|
|
||||||
dayjs.extend(localizedFormat);
|
|
||||||
|
|
||||||
const RemotePtyRows = 8; // also in main.tsx
|
|
||||||
const RemotePtyCols = 80;
|
|
||||||
const ProdServerEndpoint = "http://127.0.0.1:1619";
|
|
||||||
const ProdServerWsEndpoint = "ws://127.0.0.1:1623";
|
|
||||||
const DevServerEndpoint = "http://127.0.0.1:8090";
|
|
||||||
const DevServerWsEndpoint = "ws://127.0.0.1:8091";
|
|
||||||
const DefaultTermFontSize = 12;
|
|
||||||
const MinFontSize = 8;
|
|
||||||
const MaxFontSize = 24;
|
|
||||||
const InputChunkSize = 500;
|
|
||||||
const RemoteColors = ["red", "green", "yellow", "blue", "magenta", "cyan", "white", "orange"];
|
|
||||||
const TabColors = ["red", "orange", "yellow", "green", "mint", "cyan", "blue", "violet", "pink", "white"];
|
|
||||||
const TabIcons = [
|
|
||||||
"sparkle",
|
|
||||||
"fire",
|
|
||||||
"ghost",
|
|
||||||
"cloud",
|
|
||||||
"compass",
|
|
||||||
"crown",
|
|
||||||
"droplet",
|
|
||||||
"graduation-cap",
|
|
||||||
"heart",
|
|
||||||
"file",
|
|
||||||
];
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const VERSION = __WAVETERM_VERSION__;
|
|
||||||
// @ts-ignore
|
|
||||||
const BUILD = __WAVETERM_BUILD__;
|
|
||||||
|
|
||||||
function getDefaultHistoryQueryOpts(): HistoryQueryOpts {
|
function getDefaultHistoryQueryOpts(): HistoryQueryOpts {
|
||||||
return {
|
return {
|
||||||
@ -137,7 +34,8 @@ function getDefaultHistoryQueryOpts(): HistoryQueryOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class InputModel {
|
class InputModel {
|
||||||
globalModel: Model = null;
|
globalCommandRunner: CommandRunner;
|
||||||
|
globalModel: Model;
|
||||||
historyShow: OV<boolean> = mobx.observable.box(false);
|
historyShow: OV<boolean> = mobx.observable.box(false);
|
||||||
infoShow: OV<boolean> = mobx.observable.box(false);
|
infoShow: OV<boolean> = mobx.observable.box(false);
|
||||||
aIChatShow: OV<boolean> = mobx.observable.box(false);
|
aIChatShow: OV<boolean> = mobx.observable.box(false);
|
||||||
@ -187,6 +85,7 @@ class InputModel {
|
|||||||
|
|
||||||
constructor(globalModel: Model) {
|
constructor(globalModel: Model) {
|
||||||
this.globalModel = globalModel;
|
this.globalModel = globalModel;
|
||||||
|
this.globalCommandRunner = CommandRunner.getInstance();
|
||||||
this.filteredHistoryItems = mobx.computed(() => {
|
this.filteredHistoryItems = mobx.computed(() => {
|
||||||
return this._getFilteredHistoryItems();
|
return this._getFilteredHistoryItems();
|
||||||
});
|
});
|
||||||
@ -254,7 +153,7 @@ class InputModel {
|
|||||||
let screen = this.globalModel.getActiveScreen();
|
let screen = this.globalModel.getActiveScreen();
|
||||||
if (screen != null) {
|
if (screen != null) {
|
||||||
if (screen.focusType.get() != "input") {
|
if (screen.focusType.get() != "input") {
|
||||||
GlobalCommandRunner.screenSetFocus("input");
|
this.globalCommandRunner.screenSetFocus("input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +251,7 @@ class InputModel {
|
|||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
this.historyLoading.set(true);
|
this.historyLoading.set(true);
|
||||||
})();
|
})();
|
||||||
GlobalCommandRunner.loadHistory(show, htype);
|
this.globalCommandRunner.loadHistory(show, htype);
|
||||||
}
|
}
|
||||||
|
|
||||||
openHistory(): void {
|
openHistory(): void {
|
||||||
@ -373,7 +272,7 @@ class InputModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCmdLine(cmdLine: T.StrWithPos): void {
|
updateCmdLine(cmdLine: StrWithPos): void {
|
||||||
mobx.action(() => {
|
mobx.action(() => {
|
||||||
this.setCurLine(cmdLine.str);
|
this.setCurLine(cmdLine.str);
|
||||||
if (cmdLine.pos != appconst.NoStrPos) {
|
if (cmdLine.pos != appconst.NoStrPos) {
|
||||||
|
Loading…
Reference in New Issue
Block a user