From 1d7113d91b962b0787dbdc34079fb8594b634263 Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 3 Feb 2023 14:26:46 -0800 Subject: [PATCH] stub out some history view code (disabled in UI right now) --- src/main.tsx | 55 +++++++++++++++++++++++++++++++++++++++++++++------- src/model.ts | 1 + src/sh2.less | 23 +++++++++++++++++++++- 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index c154d6b6..8292305b 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -14,8 +14,6 @@ import localizedFormat from 'dayjs/plugin/localizedFormat'; import {GlobalModel, GlobalCommandRunner, Session, Cmd, Window, Screen, ScreenWindow, riToRPtr, widthToCols, termWidthFromCols, termHeightFromRows, termRowsFromHeight} from "./model"; import {isModKeyPress} from "./util"; -let IS_DEV = __PROMPT_DEV__; - dayjs.extend(localizedFormat) const RemotePtyRows = 8; @@ -1591,6 +1589,14 @@ class InfoMsg extends React.Component<{}, {}> { return s.substr(slashIdx+1); } + hasSpace(s : string) : boolean { + return s.indexOf(" ") != -1; + } + + handleCompClick(s : string) : void { + // TODO -> complete to this completion + } + render() { let model = GlobalModel; let inputModel = model.inputModel; @@ -1634,12 +1640,12 @@ class InfoMsg extends React.Component<{}, {}> { 0}>
-
+
this.handleCompClick(istr)} key={idx} className={cn("info-comp", {"has-space": this.hasSpace(istr)}, {"metacmd-comp": istr.startsWith("^")})}> {this.getAfterSlash(istr)}
-
+
...
@@ -2417,8 +2423,9 @@ class SessionView extends React.Component<{}, {}> { if (cmdInputHeight == 0) { cmdInputHeight = 110; } + let isHidden = GlobalModel.historyViewActive.get(); return ( -
+
@@ -2428,6 +2435,28 @@ class SessionView extends React.Component<{}, {}> { } } +@mobxReact.observer +class HistoryView extends React.Component<{}, {}> { + render() { + let model = GlobalModel; + let session = model.getActiveSession(); + if (session == null) { + return
(no active session)
; + } + let activeScreen = session.getActiveScreen(); + let cmdInputHeight = model.inputModel.cmdInputHeight.get(); + if (cmdInputHeight == 0) { + cmdInputHeight = 110; + } + let isHidden = !GlobalModel.historyViewActive.get(); + return ( +
+
HISTORY
+
+ ); + } +} + function getConnVal(r : RemoteType) : number { if (r.status == "connected") { return 1; @@ -2505,6 +2534,14 @@ class MainSideBar extends React.Component<{}, {}> { GlobalCommandRunner.openCreateRemote(); } + @boundMethod + handleHistoryClick() : void { + mobx.action(() => { + let isActive = GlobalModel.historyViewActive.get(); + GlobalModel.historyViewActive.set(!isActive); + })(); + } + render() { let model = GlobalModel; let activeSessionId = model.activeSessionId.get(); @@ -2533,8 +2570,8 @@ class MainSideBar extends React.Component<{}, {}> { } let isCollapsed = this.collapsed.get(); return ( -
-

+
+

{(isCollapsed ? "[p]" : "[prompt]")}

@@ -2566,6 +2603,9 @@ class MainSideBar extends React.Component<{}, {}> {
  • this.handleNewSession()}> New Session
  • +
    @@ -2750,6 +2790,7 @@ class Main extends React.Component<{}, {}> {
    +
    diff --git a/src/model.ts b/src/model.ts index 565ea6c1..dac162d9 100644 --- a/src/model.ts +++ b/src/model.ts @@ -1574,6 +1574,7 @@ class Model { localServerRunning : OV; authKey : string; isDev : boolean; + historyViewActive : OV = mobx.observable.box(false, {name: "historyViewActive"}); constructor() { this.clientId = getApi().getId(); diff --git a/src/sh2.less b/src/sh2.less index 49e88540..fa67bde3 100644 --- a/src/sh2.less +++ b/src/sh2.less @@ -51,12 +51,16 @@ html, body, #main { background-color: black; height: 100%; - .session-view { + .session-view, .history-view { flex-grow: 1; display: flex; flex-direction: column; min-width: 300px; position: relative; + + &.is-hidden { + display: none; + } } .screen-view { @@ -105,6 +109,14 @@ html, body, #main { } } +.history-view { + .history-title { + margin: 10px 0 10px 15px; + .mono-font(1.5rem); + color: @term-bright-white; + } +} + .screen-tabs { height: 30px; display: flex; @@ -266,6 +278,10 @@ html, body, #main { li.menu-loading-message { .mono-font(); } + + li.menu-history { + margin-left: -10px; + } } .menu-list.remotes-menu-list { @@ -1048,6 +1064,11 @@ body .xterm .xterm-viewport { .info-comp { min-width: 200px; color: @term-white; + margin-right: 10px; + + &.has-space { + text-decoration: underline dotted #777; + } } .metacmd-comp {