diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2022-12-11 00:59:34 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2022-12-11 00:59:34 +0900 |
commit | 18e3b38c69da2828efac6adc2ea3a5e85f70e571 (patch) | |
tree | 8ed4829217eafe73e836c1890eefa213a1e39dd3 /src/terminal.go | |
parent | 0ad30063ff8f96eb311bf502056b96644216ad60 (diff) |
Add 'next-selected' and 'prev-selected' actions
Close #2749
Diffstat (limited to 'src/terminal.go')
-rw-r--r-- | src/terminal.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/terminal.go b/src/terminal.go index a5d54694..2bb785c1 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -316,7 +316,9 @@ const ( actPreviewHalfPageUp actPreviewHalfPageDown actPrevHistory + actPrevSelected actNextHistory + actNextSelected actExecute actExecuteSilent actExecuteMulti // Deprecated @@ -3016,6 +3018,22 @@ func (t *Terminal) Loop() { scrollPreviewTo(t.evaluateScrollOffset()) } } + case actNextSelected, actPrevSelected: + if len(t.selected) > 0 { + total := t.merger.Length() + for i := 1; i < total; i++ { + y := (t.cy + i) % total + if t.layout == layoutDefault && a.t == actNextSelected || + t.layout != layoutDefault && a.t == actPrevSelected { + y = (t.cy - i + total) % total + } + if _, found := t.selected[t.merger.Get(y).item.Index()]; found { + t.vset(y) + req(reqList) + break + } + } + } } return true } |