diff --git a/src/main.tsx b/src/main.tsx index 33087e8c8..02c0b4981 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -542,6 +542,12 @@ class TextAreaInput extends React.Component<{}, {}> { inputModel.resetInput(); return; } + if (e.code == "KeyM" && e.getModifierState("Meta")) { + e.preventDefault(); + let opts = mobx.toJS(inputModel.historyQueryOpts.get()); + opts.includeMeta = !opts.includeMeta; + inputModel.setHistoryQueryOpts(opts); + } if (e.code == "Tab") { e.preventDefault(); return; @@ -562,7 +568,9 @@ class TextAreaInput extends React.Component<{}, {}> { handleHistoryInput(e : any) { let inputModel = GlobalModel.inputModel; mobx.action(() => { - inputModel.historyQueryOpts.get().queryStr = e.target.value; + let opts = mobx.toJS(inputModel.historyQueryOpts.get()); + opts.queryStr = e.target.value; + inputModel.setHistoryQueryOpts(opts); })(); } @@ -646,7 +654,7 @@ class HistoryInfo extends React.Component<{}, {}> { let line : string = ""; let idx = 0; return ( -
this.handleItemClick(hitem)}> +
this.handleItemClick(hitem)}>
{(isSelected ? "*" : " ")}{sprintf("%5s", hitem.historynum)} {lines[0]}
{line}
@@ -667,12 +675,13 @@ class HistoryInfo extends React.Component<{}, {}> { let hitems = inputModel.getFilteredHistoryItems(); hitems = hitems.slice().reverse(); let hitem : HistoryItem = null; + let opts = inputModel.historyQueryOpts.get(); return (
history {" "} - [containing ''] + [containing '{opts.queryStr}'] {" "} [this session ⌘S] {" "} @@ -680,7 +689,7 @@ class HistoryInfo extends React.Component<{}, {}> { {" "} [this remote ⌘R] {" "} - [including metacmds ⌘M] + [{opts.includeMeta ? "including" : "excluding"} metacmds ⌘M] {" "} (close ESC)
diff --git a/src/model.ts b/src/model.ts index 7f19d75e4..b4d21e111 100644 --- a/src/model.ts +++ b/src/model.ts @@ -633,6 +633,37 @@ class InputModel { return false; } + setHistoryQueryOpts(opts : HistoryQueryOpts) : void { + mobx.action(() => { + let oldItem = this.getHistorySelectedItem(); + this.historyQueryOpts.set(opts); + if (oldItem == null) { + setTimeout(() => this.setHistoryIndex(0, true), 10); + return; + } + let newItems = this.getFilteredHistoryItems(); + if (newItems.length == 0) { + setTimeout(() => this.setHistoryIndex(0, true), 10); + return; + } + let bestIdx = 0; + for (let i=0; i this.setHistoryIndex(bestIdx+1, true), 10); + return; + })(); + } + setHistoryShow(show : boolean) : void { if (this.historyShow.get() == show) { return; @@ -746,7 +777,54 @@ class InputModel { getFilteredHistoryItems() : HistoryItem[] { let hitems : HistoryItem[] = this.historyItems.get() ?? []; - return hitems; + let rtn : HistoryItem[] = []; + let opts = mobx.toJS(this.historyQueryOpts.get()); + let ctx = GlobalModel.getUIContext(); + let curRemote = ctx.remote; + if (curRemote == null) { + curRemote : RemotePtrType = {ownerid: "", name: "", remoteid: ""}; + } + for (let i=0; i { diff --git a/src/sh2.less b/src/sh2.less index 90fcdb6fe..0cf3b2aab 100644 --- a/src/sh2.less +++ b/src/sh2.less @@ -667,6 +667,10 @@ body .xterm .xterm-viewport { margin-left: 58px; } + .history-item.history-haderror { + color: mix(@term-red, @term-white, 50%); + } + .history-line:first-child { margin-left: 0; } @@ -685,6 +689,10 @@ body .xterm .xterm-viewport { color: @term-bright-white; background-color: #444; } + + .history-item.is-selected.history-haderror { + color: mix(@term-bright-red, @term-bright-white, 50%); + } } }