aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/compose.go68
1 files changed, 48 insertions, 20 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index c52c381f..30c5268d 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -7,6 +7,7 @@ import (
"net/textproto"
"os"
"os/exec"
+ "strconv"
"strings"
"sync"
"time"
@@ -1239,17 +1240,6 @@ type reviewMessage struct {
grid *ui.Grid
}
-var reviewCommands = [][]string{
- {":send<enter>", "Send"},
- {":edit<enter>", "Edit"},
- {":attach<space>", "Add attachment"},
- {":detach<space>", "Remove attachment"},
- {":postpone<enter>", "Postpone"},
- {":preview<enter>", "Preview message"},
- {":abort<enter>", "Abort (discard message, no confirmation)"},
- {":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"},
-}
-
func newReviewMessage(composer *Composer, err error) *reviewMessage {
bindings := composer.config.MergeContextualBinds(
composer.config.Bindings.ComposeReview,
@@ -1258,18 +1248,56 @@ func newReviewMessage(composer *Composer, err error) *reviewMessage {
"compose::review",
)
+ reviewCommands := [][]string{
+ {":send<enter>", "Send", ""},
+ {":edit<enter>", "Edit", ""},
+ {":attach<space>", "Add attachment", ""},
+ {":detach<space>", "Remove attachment", ""},
+ {":postpone<enter>", "Postpone", ""},
+ {":preview<enter>", "Preview message", ""},
+ {":abort<enter>", "Abort (discard message, no confirmation)", ""},
+ {":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""},
+ }
var actions []string
+ for _, binding := range bindings.Bindings {
+ inputs := config.FormatKeyStrokes(binding.Input)
+ outputs := config.FormatKeyStrokes(binding.Output)
+ outputs = strings.ReplaceAll(outputs, "<space>", " ")
+ found := false
+ for i, rcmd := range reviewCommands {
+ if outputs == rcmd[0] {
+ found = true
+ if reviewCommands[i][2] == "" {
+ reviewCommands[i][2] = inputs
+ } else {
+ reviewCommands[i][2] += ", " + inputs
+ }
+ break
+ }
+ }
+ if !found {
+ rcmd := []string{outputs, "", inputs}
+ reviewCommands = append(reviewCommands, rcmd)
+ }
+ }
+ longest := 0
+ for _, rcmd := range reviewCommands {
+ if len(rcmd[2]) > longest {
+ longest = len(rcmd[2])
+ }
+ }
+
+ width := longest
+ if longest < 6 {
+ width = 6
+ }
+ widthstr := strconv.Itoa(width)
- for _, command := range reviewCommands {
- cmd := command[0]
- name := command[1]
- strokes, _ := config.ParseKeyStrokes(cmd)
- var inputs []string
- for _, input := range bindings.GetReverseBindings(strokes) {
- inputs = append(inputs, config.FormatKeyStrokes(input))
+ for _, rcmd := range reviewCommands {
+ if rcmd[2] != "" {
+ actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
+ rcmd[2], rcmd[1], rcmd[0]))
}
- actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
- strings.Join(inputs, ", "), name, cmd))
}
spec := []ui.GridSpec{