|
9 | 9 | "net/textproto"
|
10 | 10 | "os"
|
11 | 11 | "os/exec"
|
12 |
| - "strconv" |
13 | 12 | "strings"
|
14 | 13 | "sync"
|
15 | 14 | "sync/atomic"
|
@@ -1686,62 +1685,35 @@ type reviewMessage struct {
|
1686 | 1685 | grid *ui.Grid
|
1687 | 1686 | }
|
1688 | 1687 |
|
| 1688 | +var reviewCommands = [][]string{ |
| 1689 | + {":send<enter>", "Send"}, |
| 1690 | + {":edit<enter>", "Edit"}, |
| 1691 | + {":attach<space>", "Add attachment"}, |
| 1692 | + {":detach<space>", "Remove attachment"}, |
| 1693 | + {":postpone<enter>", "Postpone"}, |
| 1694 | + {":preview<enter>", "Preview message"}, |
| 1695 | + {":abort<enter>", "Abort (discard message, no confirmation)"}, |
| 1696 | + {":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"}, |
| 1697 | +} |
| 1698 | + |
1689 | 1699 | func newReviewMessage(composer *Composer, err error) *reviewMessage {
|
1690 | 1700 | bindings := config.Binds.ComposeReview.ForAccount(
|
1691 | 1701 | composer.acctConfig.Name,
|
1692 | 1702 | )
|
1693 | 1703 | bindings = bindings.ForFolder(composer.SelectedDirectory())
|
1694 | 1704 |
|
1695 |
| - reviewCommands := [][]string{ |
1696 |
| - {":send<enter>", "Send", ""}, |
1697 |
| - {":edit<enter>", "Edit", ""}, |
1698 |
| - {":attach<space>", "Add attachment", ""}, |
1699 |
| - {":detach<space>", "Remove attachment", ""}, |
1700 |
| - {":postpone<enter>", "Postpone", ""}, |
1701 |
| - {":preview<enter>", "Preview message", ""}, |
1702 |
| - {":abort<enter>", "Abort (discard message, no confirmation)", ""}, |
1703 |
| - {":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""}, |
1704 |
| - } |
1705 | 1705 | var actions []string
|
1706 |
| - for _, binding := range bindings.Bindings { |
1707 |
| - inputs := config.FormatKeyStrokes(binding.Input) |
1708 |
| - outputs := config.FormatKeyStrokes(binding.Output) |
1709 |
| - outputs = strings.ReplaceAll(outputs, "<space>", " ") |
1710 |
| - found := false |
1711 |
| - for i, rcmd := range reviewCommands { |
1712 |
| - if outputs == rcmd[0] { |
1713 |
| - found = true |
1714 |
| - if reviewCommands[i][2] == "" { |
1715 |
| - reviewCommands[i][2] = inputs |
1716 |
| - } else { |
1717 |
| - reviewCommands[i][2] += ", " + inputs |
1718 |
| - } |
1719 |
| - break |
1720 |
| - } |
1721 |
| - } |
1722 |
| - if !found { |
1723 |
| - rcmd := []string{outputs, "", inputs} |
1724 |
| - reviewCommands = append(reviewCommands, rcmd) |
1725 |
| - } |
1726 |
| - } |
1727 |
| - longest := 0 |
1728 |
| - for _, rcmd := range reviewCommands { |
1729 |
| - if len(rcmd[2]) > longest { |
1730 |
| - longest = len(rcmd[2]) |
1731 |
| - } |
1732 |
| - } |
1733 |
| - |
1734 |
| - width := longest |
1735 |
| - if longest < 6 { |
1736 |
| - width = 6 |
1737 |
| - } |
1738 |
| - widthstr := strconv.Itoa(width) |
1739 | 1706 |
|
1740 |
| - for _, rcmd := range reviewCommands { |
1741 |
| - if rcmd[2] != "" { |
1742 |
| - actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s", |
1743 |
| - rcmd[2], rcmd[1], rcmd[0])) |
| 1707 | + for _, command := range reviewCommands { |
| 1708 | + cmd := command[0] |
| 1709 | + name := command[1] |
| 1710 | + strokes, _ := config.ParseKeyStrokes(cmd) |
| 1711 | + var inputs []string |
| 1712 | + for _, input := range bindings.GetReverseBindings(strokes) { |
| 1713 | + inputs = append(inputs, config.FormatKeyStrokes(input)) |
1744 | 1714 | }
|
| 1715 | + actions = append(actions, fmt.Sprintf(" %-6s %-40s %s", |
| 1716 | + strings.Join(inputs, ", "), name, cmd)) |
1745 | 1717 | }
|
1746 | 1718 |
|
1747 | 1719 | spec := []ui.GridSpec{
|
|
0 commit comments