Skip to content

Commit bbaf8ff

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

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
"time"
@@ -1322,61 +1321,34 @@ type reviewMessage struct {
13221321
grid *ui.Grid
13231322
}
13241323

1324+
var reviewCommands = [][]string{
1325+
{":send<enter>", "Send"},
1326+
{":edit<enter>", "Edit"},
1327+
{":attach<space>", "Add attachment"},
1328+
{":detach<space>", "Remove attachment"},
1329+
{":postpone<enter>", "Postpone"},
1330+
{":preview<enter>", "Preview message"},
1331+
{":abort<enter>", "Abort (discard message, no confirmation)"},
1332+
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"},
1333+
}
1334+
13251335
func newReviewMessage(composer *Composer, err error) *reviewMessage {
13261336
bindings := config.Binds.ComposeReview.ForAccount(
13271337
composer.acctConfig.Name,
13281338
)
13291339

1330-
reviewCommands := [][]string{
1331-
{":send<enter>", "Send", ""},
1332-
{":edit<enter>", "Edit", ""},
1333-
{":attach<space>", "Add attachment", ""},
1334-
{":detach<space>", "Remove attachment", ""},
1335-
{":postpone<enter>", "Postpone", ""},
1336-
{":preview<enter>", "Preview message", ""},
1337-
{":abort<enter>", "Abort (discard message, no confirmation)", ""},
1338-
{":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""},
1339-
}
13401340
var actions []string
1341-
for _, binding := range bindings.Bindings {
1342-
inputs := config.FormatKeyStrokes(binding.Input)
1343-
outputs := config.FormatKeyStrokes(binding.Output)
1344-
outputs = strings.ReplaceAll(outputs, "<space>", " ")
1345-
found := false
1346-
for i, rcmd := range reviewCommands {
1347-
if outputs == rcmd[0] {
1348-
found = true
1349-
if reviewCommands[i][2] == "" {
1350-
reviewCommands[i][2] = inputs
1351-
} else {
1352-
reviewCommands[i][2] += ", " + inputs
1353-
}
1354-
break
1355-
}
1356-
}
1357-
if !found {
1358-
rcmd := []string{outputs, "", inputs}
1359-
reviewCommands = append(reviewCommands, rcmd)
1360-
}
1361-
}
1362-
longest := 0
1363-
for _, rcmd := range reviewCommands {
1364-
if len(rcmd[2]) > longest {
1365-
longest = len(rcmd[2])
1366-
}
1367-
}
1368-
1369-
width := longest
1370-
if longest < 6 {
1371-
width = 6
1372-
}
1373-
widthstr := strconv.Itoa(width)
13741341

1375-
for _, rcmd := range reviewCommands {
1376-
if rcmd[2] != "" {
1377-
actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s",
1378-
rcmd[2], rcmd[1], rcmd[0]))
1342+
for _, command := range reviewCommands {
1343+
cmd := command[0]
1344+
name := command[1]
1345+
strokes, _ := config.ParseKeyStrokes(cmd)
1346+
var inputs []string
1347+
for _, input := range bindings.GetReverseBindings(strokes) {
1348+
inputs = append(inputs, config.FormatKeyStrokes(input))
13791349
}
1350+
actions = append(actions, fmt.Sprintf(" %-6s %-40s %s",
1351+
strings.Join(inputs, ", "), name, cmd))
13801352
}
13811353

13821354
spec := []ui.GridSpec{

0 commit comments

Comments
 (0)