summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/options.go4
-rw-r--r--src/terminal.go27
2 files changed, 31 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go
index a55dc340..0e612559 100644
--- a/src/options.go
+++ b/src/options.go
@@ -839,6 +839,8 @@ func parseKeymap(keymap map[tui.Event][]action, str string) {
appendAction(actDeleteChar)
case "delete-char/eof":
appendAction(actDeleteCharEOF)
+ case "deselect":
+ appendAction(actDeselect)
case "end-of-line":
appendAction(actEndOfLine)
case "cancel":
@@ -879,6 +881,8 @@ func parseKeymap(keymap map[tui.Event][]action, str string) {
appendAction(actToggleAll)
case "toggle-search":
appendAction(actToggleSearch)
+ case "select":
+ appendAction(actSelect)
case "select-all":
appendAction(actSelectAll)
case "deselect-all":
diff --git a/src/terminal.go b/src/terminal.go
index fa9adb88..2fcaa697 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -276,6 +276,8 @@ const (
actReload
actDisableSearch
actEnableSearch
+ actSelect
+ actDeselect
)
type placeholderFlags struct {
@@ -1785,11 +1787,26 @@ func (t *Terminal) selectItem(item *Item) bool {
return true
}
+func (t *Terminal) selectItemChanged(item *Item) bool {
+ if _, found := t.selected[item.Index()]; found {
+ return false
+ }
+ return t.selectItem(item)
+}
+
func (t *Terminal) deselectItem(item *Item) {
delete(t.selected, item.Index())
t.version++
}
+func (t *Terminal) deselectItemChanged(item *Item) bool {
+ if _, found := t.selected[item.Index()]; found {
+ t.deselectItem(item)
+ return true
+ }
+ return false
+}
+
func (t *Terminal) toggleItem(item *Item) bool {
if _, found := t.selected[item.Index()]; !found {
return t.selectItem(item)
@@ -2341,6 +2358,16 @@ func (t *Terminal) Loop() {
} else {
req(reqQuit)
}
+ case actSelect:
+ current := t.currentItem()
+ if t.multi > 0 && current != nil && t.selectItemChanged(current) {
+ req(reqList, reqInfo)
+ }
+ case actDeselect:
+ current := t.currentItem()
+ if t.multi > 0 && current != nil && t.deselectItemChanged(current) {
+ req(reqList, reqInfo)
+ }
case actToggle:
if t.multi > 0 && t.merger.Length() > 0 && toggle() {
req(reqList)