get fontsize from clientdata

This commit is contained in:
sawka 2023-02-26 14:16:42 -08:00
parent d11d76c670
commit 3cb47da584
3 changed files with 26 additions and 3 deletions

View File

@ -2684,6 +2684,10 @@ class ScreenWindowView extends React.Component<{sw : ScreenWindow}, {}> {
if (this.width.get() == 0) {
return this.renderError("", false);
}
let cdata = GlobalModel.clientData.get();
if (cdata == null) {
return this.renderError("loading client data", true);
}
let idx = 0;
let line : LineType = null;
let screen = GlobalModel.getScreenById(sw.sessionId, sw.screenId);

View File

@ -72,6 +72,7 @@ function keyHasNoMods(e : any) {
type OV<V> = mobx.IObservableValue<V>;
type OArr<V> = mobx.IObservableArray<V>;
type OMap<K,V> = mobx.ObservableMap<K,V>;
type CV<V> = mobx.IComputedValue<V>;
function isBlank(s : string) {
return (s == null || s == "");
@ -1830,7 +1831,7 @@ class Model {
authKey : string;
isDev : boolean;
activeMainView : OV<"session" | "history" | "bookmarks"> = mobx.observable.box("session", {name: "activeMainView"});
termFontSize : OV<number> = mobx.observable.box(DefaultTermFontSize, {name: "termFontSize"});
termFontSize : CV<number>;
inputModel : InputModel;
bookmarksModel : BookmarksModel;
@ -1846,6 +1847,20 @@ class Model {
this.bookmarksModel = new BookmarksModel();
let isLocalServerRunning = getApi().getLocalServerStatus();
this.localServerRunning = mobx.observable.box(isLocalServerRunning, {name: "model-local-server-running"});
this.termFontSize = mobx.computed(() => {
let cdata = this.clientData.get();
if (cdata == null || cdata.feopts == null || cdata.feopts.termfontsize == null) {
return DefaultTermFontSize;
}
let fontSize = Math.ceil(cdata.feopts.termfontsize);
if (fontSize < MinFontSize) {
return MinFontSize;
}
if (fontSize > MaxFontSize) {
return MaxFontSize;
}
return fontSize;
});
getApi().onTCmd(this.onTCmd.bind(this));
getApi().onICmd(this.onICmd.bind(this));
getApi().onLCmd(this.onLCmd.bind(this));
@ -2175,6 +2190,9 @@ class Model {
else if ("bookmarks" in update) {
this.bookmarksModel.mergeBookmarks(update.bookmarks);
}
if ("clientdata" in update) {
this.clientData.set(update.clientdata);
}
if (interactive && "info" in update) {
let info : InfoType = update.info;
this.inputModel.flashInfoMsg(info, info.timeoutms);

View File

@ -271,6 +271,7 @@ type PtyDataUpdateType = {
};
type ModelUpdateType = {
interactive : boolean,
sessions? : SessionDataType[],
activesessionid? : string,
windows? : WindowDataType[],
@ -281,10 +282,10 @@ type ModelUpdateType = {
cmdline? : CmdLineUpdateType,
remotes? : RemoteType[],
history? : HistoryInfoType,
interactive : boolean,
connect? : boolean,
bookmarksview? : boolean,
bookmarks : BookmarkType[],
bookmarks? : BookmarkType[],
clientdata? : ClientDataType,
};
type BookmarkType = {