@@ -109,6 +109,9 @@ type SelectKeys struct {
109
109
110
110
// Search is the key used to trigger the search mode for the list. Default to the "/" key.
111
111
Search Key
112
+
113
+ // Select is the key used to trigger the multiple select mode for the list. Default to the space key.
114
+ Select Key
112
115
}
113
116
114
117
// Key defines a keyboard code and a display representation for the help menu.
@@ -314,7 +317,7 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error)
314
317
header := SearchPrompt + cur .Format ()
315
318
sb .WriteString (header )
316
319
} else if ! s .HideHelp {
317
- help := s .renderHelp (canSearch )
320
+ help := s .renderHelp (canSearch , s . Checkbox )
318
321
sb .Write (help )
319
322
}
320
323
@@ -512,8 +515,9 @@ func (s *Select) prepareTemplates() error {
512
515
513
516
if tpls .Help == "" {
514
517
tpls .Help = fmt .Sprintf (`{{ "Use the arrow keys to navigate:" | faint }} {{ .NextKey | faint }} ` +
515
- `{{ .PrevKey | faint }} {{ .PageDownKey | faint }} {{ .PageUpKey | faint }} ` +
516
- `{{ if .Search }} {{ "and" | faint }} {{ .SearchKey | faint }} {{ "toggles search" | faint }}{{ end }}` )
518
+ `{{ .PrevKey | faint }} {{ .PageDownKey | faint }} {{ .PageUpKey | faint }}` +
519
+ `{{ if .Search }} {{ " and" | faint }} {{ .SearchKey | faint }} {{ "toggles search" | faint }}{{ end }}` +
520
+ `{{ if .MultipleSelect }} {{ " and" | faint }} {{ .SelectKey | faint }} {{ "toggles select" | faint }}{{ end }}` )
517
521
}
518
522
519
523
tpl , err = template .New ("" ).Funcs (tpls .FuncMap ).Parse (tpls .Help )
@@ -619,6 +623,7 @@ func (s *Select) setKeys() {
619
623
PageUp : Key {Code : KeyBackward , Display : KeyBackwardDisplay },
620
624
PageDown : Key {Code : KeyForward , Display : KeyForwardDisplay },
621
625
Search : Key {Code : '/' , Display : "/" },
626
+ Select : Key {Code : KeySpace , Display : KeySpaceDisplay },
622
627
}
623
628
}
624
629
@@ -643,21 +648,25 @@ func (s *Select) renderDetails(item interface{}) [][]byte {
643
648
return bytes .Split (output , []byte ("\n " ))
644
649
}
645
650
646
- func (s * Select ) renderHelp (b bool ) []byte {
651
+ func (s * Select ) renderHelp (b bool , c bool ) []byte {
647
652
keys := struct {
648
- NextKey string
649
- PrevKey string
650
- PageDownKey string
651
- PageUpKey string
652
- Search bool
653
- SearchKey string
653
+ NextKey string
654
+ PrevKey string
655
+ PageDownKey string
656
+ PageUpKey string
657
+ Search bool
658
+ SearchKey string
659
+ MultipleSelect bool
660
+ SelectKey string
654
661
}{
655
- NextKey : s .Keys .Next .Display ,
656
- PrevKey : s .Keys .Prev .Display ,
657
- PageDownKey : s .Keys .PageDown .Display ,
658
- PageUpKey : s .Keys .PageUp .Display ,
659
- SearchKey : s .Keys .Search .Display ,
660
- Search : b ,
662
+ NextKey : s .Keys .Next .Display ,
663
+ PrevKey : s .Keys .Prev .Display ,
664
+ PageDownKey : s .Keys .PageDown .Display ,
665
+ PageUpKey : s .Keys .PageUp .Display ,
666
+ SearchKey : s .Keys .Search .Display ,
667
+ SelectKey : s .Keys .Select .Display ,
668
+ Search : b ,
669
+ MultipleSelect : c ,
661
670
}
662
671
663
672
return render (s .Templates .help , keys )
0 commit comments