|
8 | 8 | "net/textproto"
|
9 | 9 | "os"
|
10 | 10 | "os/exec"
|
11 |
| - "strconv" |
12 | 11 | "strings"
|
13 | 12 | "sync"
|
14 | 13 | "sync/atomic"
|
@@ -1629,61 +1628,34 @@ type reviewMessage struct {
|
1629 | 1628 | grid *ui.Grid
|
1630 | 1629 | }
|
1631 | 1630 |
|
| 1631 | +var reviewCommands = [][]string{ |
| 1632 | + {":send<enter>", "Send"}, |
| 1633 | + {":edit<enter>", "Edit"}, |
| 1634 | + {":attach<space>", "Add attachment"}, |
| 1635 | + {":detach<space>", "Remove attachment"}, |
| 1636 | + {":postpone<enter>", "Postpone"}, |
| 1637 | + {":preview<enter>", "Preview message"}, |
| 1638 | + {":abort<enter>", "Abort (discard message, no confirmation)"}, |
| 1639 | + {":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone"}, |
| 1640 | +} |
| 1641 | + |
1632 | 1642 | func newReviewMessage(composer *Composer, err error) *reviewMessage {
|
1633 | 1643 | bindings := config.Binds.ComposeReview.ForAccount(
|
1634 | 1644 | composer.acctConfig.Name,
|
1635 | 1645 | )
|
1636 | 1646 |
|
1637 |
| - reviewCommands := [][]string{ |
1638 |
| - {":send<enter>", "Send", ""}, |
1639 |
| - {":edit<enter>", "Edit", ""}, |
1640 |
| - {":attach<space>", "Add attachment", ""}, |
1641 |
| - {":detach<space>", "Remove attachment", ""}, |
1642 |
| - {":postpone<enter>", "Postpone", ""}, |
1643 |
| - {":preview<enter>", "Preview message", ""}, |
1644 |
| - {":abort<enter>", "Abort (discard message, no confirmation)", ""}, |
1645 |
| - {":choose -o d discard abort -o p postpone postpone<enter>", "Abort or postpone", ""}, |
1646 |
| - } |
1647 | 1647 | var actions []string
|
1648 |
| - for _, binding := range bindings.Bindings { |
1649 |
| - inputs := config.FormatKeyStrokes(binding.Input) |
1650 |
| - outputs := config.FormatKeyStrokes(binding.Output) |
1651 |
| - outputs = strings.ReplaceAll(outputs, "<space>", " ") |
1652 |
| - found := false |
1653 |
| - for i, rcmd := range reviewCommands { |
1654 |
| - if outputs == rcmd[0] { |
1655 |
| - found = true |
1656 |
| - if reviewCommands[i][2] == "" { |
1657 |
| - reviewCommands[i][2] = inputs |
1658 |
| - } else { |
1659 |
| - reviewCommands[i][2] += ", " + inputs |
1660 |
| - } |
1661 |
| - break |
1662 |
| - } |
1663 |
| - } |
1664 |
| - if !found { |
1665 |
| - rcmd := []string{outputs, "", inputs} |
1666 |
| - reviewCommands = append(reviewCommands, rcmd) |
1667 |
| - } |
1668 |
| - } |
1669 |
| - longest := 0 |
1670 |
| - for _, rcmd := range reviewCommands { |
1671 |
| - if len(rcmd[2]) > longest { |
1672 |
| - longest = len(rcmd[2]) |
1673 |
| - } |
1674 |
| - } |
1675 |
| - |
1676 |
| - width := longest |
1677 |
| - if longest < 6 { |
1678 |
| - width = 6 |
1679 |
| - } |
1680 |
| - widthstr := strconv.Itoa(width) |
1681 | 1648 |
|
1682 |
| - for _, rcmd := range reviewCommands { |
1683 |
| - if rcmd[2] != "" { |
1684 |
| - actions = append(actions, fmt.Sprintf(" %-"+widthstr+"s %-40s %s", |
1685 |
| - rcmd[2], rcmd[1], rcmd[0])) |
| 1649 | + for _, command := range reviewCommands { |
| 1650 | + cmd := command[0] |
| 1651 | + name := command[1] |
| 1652 | + strokes, _ := config.ParseKeyStrokes(cmd) |
| 1653 | + var inputs []string |
| 1654 | + for _, input := range bindings.GetReverseBindings(strokes) { |
| 1655 | + inputs = append(inputs, config.FormatKeyStrokes(input)) |
1686 | 1656 | }
|
| 1657 | + actions = append(actions, fmt.Sprintf(" %-6s %-40s %s", |
| 1658 | + strings.Join(inputs, ", "), name, cmd)) |
1687 | 1659 | }
|
1688 | 1660 |
|
1689 | 1661 | spec := []ui.GridSpec{
|
|
0 commit comments