- ): any {
+ render() {
+ let { hitem, isSelected, opts, snames, scrNames } = this.props;
let lines = hitem.cmdstr.split("\n");
let line: string = "";
let idx = 0;
@@ -163,7 +132,7 @@ class HistoryInfo extends React.Component<{}, {}> {
{ "history-haderror": hitem.haderror },
"hnum-" + hitem.historynum
)}
- onClick={() => this.handleItemClick(hitem)}
+ onClick={() => this.props.onClick(hitem)}
>
{infoText} {lines[0]}
@@ -176,12 +145,51 @@ class HistoryInfo extends React.Component<{}, {}> {
);
}
+}
+
+@mobxReact.observer
+class HistoryInfo extends React.Component<{}, {}> {
+ lastClickHNum: string = null;
+ lastClickTs: number = 0;
+ containingText: mobx.IObservableValue = mobx.observable.box("");
+
+ componentDidMount() {
+ let inputModel = GlobalModel.inputModel;
+ let hitem = inputModel.getHistorySelectedItem();
+ if (hitem == null) {
+ hitem = inputModel.getFirstHistoryItem();
+ }
+ if (hitem != null) {
+ inputModel.scrollHistoryItemIntoView(hitem.historynum);
+ }
+ }
@boundMethod
handleClose() {
GlobalModel.inputModel.toggleInfoMsg();
}
+ @boundMethod
+ handleItemClick(hitem: HistoryItem) {
+ let inputModel = GlobalModel.inputModel;
+ let selItem = inputModel.getHistorySelectedItem();
+ if (this.lastClickHNum == hitem.historynum && selItem != null && selItem.historynum == hitem.historynum) {
+ inputModel.grabSelectedHistoryItem();
+ return;
+ }
+ inputModel.giveFocus();
+ inputModel.setHistorySelectionNum(hitem.historynum);
+ let now = Date.now();
+ this.lastClickHNum = hitem.historynum;
+ this.lastClickTs = now;
+ setTimeout(() => {
+ if (this.lastClickTs == now) {
+ this.lastClickHNum = null;
+ this.lastClickTs = 0;
+ }
+ }, 3000);
+ }
+
render() {
let inputModel = GlobalModel.inputModel;
let idx: number = 0;
@@ -224,7 +232,15 @@ class HistoryInfo extends React.Component<{}, {}> {
[no history]
0}>
- {this.renderHItem(hitem, opts, hitem == selItem, snames, scrNames)}
+