From 1a02bb53d0235eb01a297414b59330d65889073b Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 14 Sep 2022 17:14:27 -0700 Subject: [PATCH] refactor infomsg --- src/main.tsx | 125 ++++++++++++++++++++++++++++----------------------- src/types.ts | 1 + 2 files changed, 69 insertions(+), 57 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index b21bb29a..3d2f44b9 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -664,6 +664,73 @@ class TextAreaInput extends React.Component<{}, {}> { } } +@mobxReact.observer +class InfoMsg extends React.Component<{}, {}> { + getAfterSlash(s : string) : string { + if (s.startsWith("^/")) { + return s.substr(1); + } + let slashIdx = s.lastIndexOf("/"); + if (slashIdx == s.length-1) { + slashIdx = s.lastIndexOf("/", slashIdx-1); + } + if (slashIdx == -1) { + return s; + } + return s.substr(slashIdx+1); + } + + render() { + let model = GlobalModel; + let inputModel = model.inputModel; + let infoMsg = inputModel.infoMsg.get(); + let infoShow = inputModel.infoShow.get(); + let line : string = null; + let istr : string = null; + let idx : number = 0; + return ( +
+ +
+ {infoMsg.infotitle} +
+
+ +
+ {infoMsg.infomsg} +
+
+ +
+ +
{line == "" ? " " : line}
+
+
+
+ 0}> +
+ +
+ {this.getAfterSlash(istr)} +
+
+ +
+ ... +
+
+
+
+ +
+ [error] {infoMsg.infoerror} +
+
+
+ ); + } +} + @mobxReact.observer class HistoryInfo extends React.Component<{}, {}> { lastClickHNum : string = null; @@ -798,20 +865,6 @@ class HistoryInfo extends React.Component<{}, {}> { @mobxReact.observer class CmdInput extends React.Component<{}, {}> { - getAfterSlash(s : string) : string { - if (s.startsWith("^/")) { - return s.substr(1); - } - let slashIdx = s.lastIndexOf("/"); - if (slashIdx == s.length-1) { - slashIdx = s.lastIndexOf("/", slashIdx-1); - } - if (slashIdx == -1) { - return s; - } - return s.substr(slashIdx+1); - } - render() { let model = GlobalModel; let inputModel = model.inputModel; @@ -830,57 +883,15 @@ class CmdInput extends React.Component<{}, {}> { } let remoteStr = getRemoteStr(rptr); let cwdStr = getCwdStr(remote, remoteState); - let infoMsg = inputModel.infoMsg.get(); let infoShow = inputModel.infoShow.get(); let historyShow = !infoShow && inputModel.historyShow.get(); - let istr : string = null; - let istrIdx : number = 0; - let line : string = null; - let idx : number = 0; return (
-
- -
- {infoMsg.infotitle} -
-
- -
- {infoMsg.infomsg} -
-
- -
- -
{line == "" ? " " : line}
-
-
-
- 0}> -
- -
- {this.getAfterSlash(istr)} -
-
- -
- ... -
-
-
-
- -
- [error] {infoMsg.infoerror} -
-
-
+
diff --git a/src/types.ts b/src/types.ts index 524e6c38..7c9b9d9a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -80,6 +80,7 @@ type RemoteType = { defaultstate : RemoteStateType, connectmode : string, remoteidx : number, + archived : boolean, remove? : boolean, };