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