|
8 | 8 | "net/textproto"
|
9 | 9 | "os"
|
10 | 10 | "os/exec"
|
11 |
| - "strconv" |
12 | 11 | "strings"
|
13 | 12 | "sync"
|
14 | 13 | "time"
|
@@ -1322,61 +1321,34 @@ type reviewMessage struct {
|
1322 | 1321 | grid *ui.Grid
|
1323 | 1322 | }
|
1324 | 1323 |
|
| 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 | + |
1325 | 1335 | func newReviewMessage(composer *Composer, err error) *reviewMessage {
|
1326 | 1336 | bindings := config.Binds.ComposeReview.ForAccount(
|
1327 | 1337 | composer.acctConfig.Name,
|
1328 | 1338 | )
|
1329 | 1339 |
|
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 |
| - } |
1340 | 1340 | 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) |
1374 | 1341 |
|
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)) |
1379 | 1349 | }
|
| 1350 | + actions = append(actions, fmt.Sprintf(" %-6s %-40s %s", |
| 1351 | + strings.Join(inputs, ", "), name, cmd)) |
1380 | 1352 | }
|
1381 | 1353 |
|
1382 | 1354 | spec := []ui.GridSpec{
|
|
0 commit comments