Skip to content

Commit 8396705

Browse files
committed
Revert "compose: show relevant bindings on review screen"
This reverts commit effff93.
1 parent 8770adb commit 8396705

File tree

1 file changed

+20
-48
lines changed

1 file changed

+20
-48
lines changed

widgets/compose.go

+20-48
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"net/textproto"
99
"os"
1010
"os/exec"
11-
"strconv"
1211
"strings"
1312
"sync"
1413
"sync/atomic"
@@ -1589,61 +1588,34 @@ type reviewMessage struct {
15891588
grid *ui.Grid
15901589
}
15911590

1591+
var reviewCommands = [][]string{
1592+
{":send<enter>", "Send"},
1593+
{":edit<enter>", "Edit"},
1594+
{":attach<space>", "Add attachment"},
1595+
{":detach<space>", "Remove attachment"},
1596+
{":postpone<enter>", "Postpone"},
1597+
{":preview<enter>", "Preview message"},
1598+
{":abort<enter>", "Abort (discard message, no confirmation)"},
1599+
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"},
1600+
}
1601+
15921602
func newReviewMessage(composer *Composer, err error) *reviewMessage {
15931603
bindings := config.Binds.ComposeReview.ForAccount(
15941604
composer.acctConfig.Name,
15951605
)
15961606

1597-
reviewCommands := [][]string{
1598-
{":send<enter>", "Send", ""},
1599-
{":edit<enter>", "Edit", ""},
1600-
{":attach<space>", "Add attachment", ""},
1601-
{":detach<space>", "Remove attachment", ""},
1602-
{":postpone<enter>", "Postpone", ""},
1603-
{":preview<enter>", "Preview message", ""},
1604-
{":abort<enter>", "Abort (discard message, no confirmation)", ""},
1605-
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""},
1606-
}
16071607
var actions []string
1608-
for _, binding := range bindings.Bindings {
1609-
inputs := config.FormatKeyStrokes(binding.Input)
1610-
outputs := config.FormatKeyStrokes(binding.Output)
1611-
outputs = strings.ReplaceAll(outputs, "<space>", " ")
1612-
found := false
1613-
for i, rcmd := range reviewCommands {
1614-
if outputs == rcmd[0] {
1615-
found = true
1616-
if reviewCommands[i][2] == "" {
1617-
reviewCommands[i][2] = inputs
1618-
} else {
1619-
reviewCommands[i][2] += ", " + inputs
1620-
}
1621-
break
1622-
}
1623-
}
1624-
if !found {
1625-
rcmd := []string{outputs, "", inputs}
1626-
reviewCommands = append(reviewCommands, rcmd)
1627-
}
1628-
}
1629-
longest := 0
1630-
for _, rcmd := range reviewCommands {
1631-
if len(rcmd[2]) > longest {
1632-
longest = len(rcmd[2])
1633-
}
1634-
}
1635-
1636-
width := longest
1637-
if longest < 6 {
1638-
width = 6
1639-
}
1640-
widthstr := strconv.Itoa(width)
16411608

1642-
for _, rcmd := range reviewCommands {
1643-
if rcmd[2] != "" {
1644-
actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
1645-
rcmd[2], rcmd[1], rcmd[0]))
1609+
for _, command := range reviewCommands {
1610+
cmd := command[0]
1611+
name := command[1]
1612+
strokes, _ := config.ParseKeyStrokes(cmd)
1613+
var inputs []string
1614+
for _, input := range bindings.GetReverseBindings(strokes) {
1615+
inputs = append(inputs, config.FormatKeyStrokes(input))
16461616
}
1617+
actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
1618+
strings.Join(inputs, ", "), name, cmd))
16471619
}
16481620

16491621
spec := []ui.GridSpec{

0 commit comments

Comments
 (0)