diff --git a/src/main.tsx b/src/main.tsx
index cab59775..afd1cea6 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -527,6 +527,69 @@ class TextAreaInput extends React.Component<{}, {}> {
}
}
+@mobxReact.observer
+class HistoryInfo extends React.Component<{}, {}> {
+ componentDidMount() {
+ let inputModel = GlobalModel.inputModel;
+ let selNum = inputModel.historySelectedNum.get();
+ if (selNum != null) {
+ let elem = document.querySelector(".cmd-history .hnum-" + selNum);
+ if (elem != null) {
+ elem.scrollIntoView({block: "nearest"});
+ }
+ }
+ }
+
+ renderHItem(hitem : HistoryItem, selNum : number) : any {
+ let lines = hitem.cmdstr.split("\n");
+ let line : string = "";
+ let idx = 0;
+ return (
+
+
{(selNum == hitem.historynum ? "*" : " ")}{sprintf("%5s", hitem.historynum)} {lines[0]}
+
+ {line}
+
+
+ );
+ }
+
+ render() {
+ let inputModel = GlobalModel.inputModel;
+ let idx : number = 0;
+ let hitems : HistoryItem[] = inputModel.historyItems.get() ?? [];
+ let selNum = inputModel.historySelectedNum.get();
+ hitems = hitems.slice().reverse();
+ return (
+
+
+ showing history for
+ {" "}
+ [containing '']
+ {" "}
+ [this session ⌘S]
+ {" "}
+ [this window ⌘W]
+ {" "}
+ [this remote ⌘R]
+ {" "}
+ [including metacmds ⌘M]
+
+
+
+ [no history]
+
+ 0}>
+
+ {this.renderHItem(hitem, selNum)}
+
+
+
+
+ );
+ }
+}
+
@mobxReact.observer
class CmdInput extends React.Component<{}, {}> {
getAfterSlash(s : string) : string {
@@ -568,32 +631,11 @@ class CmdInput extends React.Component<{}, {}> {
let istrIdx : number = 0;
let line : string = null;
let idx : number = 0;
- let hitems : HistoryItem[] = inputModel.historyItems.get() ?? [];
return (
-
-
- showing history for
- {" "}
- [this session ⌘S]
- {" "}
- [this window ⌘W]
- {" "}
- [this remote ⌘R]
- {" "}
- [including metacmds ⌘M]
-
-
-
- [no history]
-
-
0}>
-
- {idx+1} item
-
-
-
-
+
+
+
diff --git a/src/model.ts b/src/model.ts
index fec0681c..e05050c1 100644
--- a/src/model.ts
+++ b/src/model.ts
@@ -584,6 +584,7 @@ class InputModel {
queryOpts : OV = mobx.observable.box(null);
infoMsg : OV = mobx.observable.box(null);
infoTimeoutId : any = null;
+ historySelectedNum : OV = mobx.observable.box(null);
updateCmdLine(cmdLine : CmdLineUpdateType) : void {
mobx.action(() => {
@@ -603,7 +604,14 @@ class InputModel {
this.infoShow.set(false);
}
this.historyShow.set(true);
- this.historyItems.set(hinfo.items);
+ let items = hinfo.items ?? [];
+ this.historyItems.set(items);
+ if (items.length == 0) {
+ this.historySelectedNum.set(null);
+ }
+ else {
+ this.historySelectedNum.set(items[0].historynum);
+ }
})();
}
diff --git a/src/sh2.less b/src/sh2.less
index 726c027e..2e56042d 100644
--- a/src/sh2.less
+++ b/src/sh2.less
@@ -634,11 +634,29 @@ body .xterm .xterm-viewport {
.history-items {
margin-top: 24px;
- color: #d3d7cf;
+ color: @term-white;
font-size: 12px;
font-family: 'JetBrains Mono', monospace;
- white-space: pre;
padding-bottom: 6px;
+
+ .history-line {
+ white-space: pre;
+ margin-left: 58px;
+ }
+
+ .history-line:first-child {
+ margin-left: 0;
+ }
+
+ .history-item {
+ padding-left: 5px;
+ }
+
+ .history-item.is-selected {
+ font-weight: bold;
+ color: @term-bright-white;
+ background-color: #444;
+ }
}
}