|
8 | 8 | "net/textproto"
|
9 | 9 | "os"
|
10 | 10 | "os/exec"
|
11 |
| - "strconv" |
12 | 11 | "strings"
|
13 | 12 | "sync"
|
14 | 13 | "sync/atomic"
|
@@ -1589,61 +1588,34 @@ type reviewMessage struct {
|
1589 | 1588 | grid *ui.Grid
|
1590 | 1589 | }
|
1591 | 1590 |
|
| 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 | + |
1592 | 1602 | func newReviewMessage(composer *Composer, err error) *reviewMessage {
|
1593 | 1603 | bindings := config.Binds.ComposeReview.ForAccount(
|
1594 | 1604 | composer.acctConfig.Name,
|
1595 | 1605 | )
|
1596 | 1606 |
|
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 |
| - } |
1607 | 1607 | 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) |
1641 | 1608 |
|
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)) |
1646 | 1616 | }
|
| 1617 | + actions = append(actions, fmt.Sprintf(" %-6s %-40s %s", |
| 1618 | + strings.Join(inputs, ", "), name, cmd)) |
1647 | 1619 | }
|
1648 | 1620 |
|
1649 | 1621 | spec := []ui.GridSpec{
|
|
0 commit comments