make keybinds configurable and consolidate

This commit is contained in:
2026-07-28 14:55:38 +02:00
parent bb8e91039f
commit 948f3e1a79
12 changed files with 1469 additions and 158 deletions

View File

@@ -34,6 +34,7 @@ func (m *App) startPREdit() tea.Cmd {
m.prEditEditors[prEditBodyField].highlightMarkdown = true
for index := range m.prEditEditors {
m.prEditEditors[index].hardwareCursor = m.cursorOutput != nil
m.prEditEditors[index].keys = m.keybindings
}
m.prEditOriginal = m.currentPRMetadata()
m.prEditBranches = nil
@@ -83,7 +84,18 @@ func (m App) pullRequestUpdateUnavailable() string {
}
func (m App) updatePREditInput(key tea.KeyMsg) (tea.Model, tea.Cmd) {
k := key.String()
k := m.keybindings.canonicalPREditKey(
key.String(), m.prEditField, m.writeMode == writePREditConfirm,
)
if m.prEditField != prEditBodyField &&
key.Type != tea.KeyRunes && key.Type != tea.KeySpace {
switch {
case keyMatches(key.String(), m.keybindings.Navigation.Up):
k = "up"
case keyMatches(key.String(), m.keybindings.Navigation.Down):
k = "down"
}
}
editorWidth := m.prEditEditorWidth()
if m.writeMode == writePREditConfirm {
switch k {
@@ -375,17 +387,6 @@ func (m App) dashboardEditLayout() ([]string, int) {
appendField("title", prEditTitleField)
appendField("target branch", prEditBaseField)
appendField("description", prEditBodyField)
help := "tab/shift-tab field • ctrl-s review • esc normal/cancel"
if m.prEditEditors[prEditBodyField].Modal {
help += " • i/a/s insert • v/V select • y copy • p paste • hjkl/wWbBeE move • ctrl-d/u page • fFtT + ; find"
} else {
help += " • arrows/home/end move • ctrl-d/u page • enter newline"
}
wrapped := ansi.Hardwrap(ansi.Wordwrap(help, width, ""), width, false)
lines = append(lines, "")
for _, line := range strings.Split(wrapped, "\n") {
lines = append(lines, dimStyle.Render(line))
}
return lines, cursorLine
}
@@ -467,6 +468,10 @@ func (m App) prEditConfirmationLines(width int) []string {
len([]rune(m.prEditOriginal.Body)), len([]rune(update.Body)),
), "")
}
lines = append(lines, warnStyle.Render("y submit • n/esc continue editing"))
lines = append(lines, warnStyle.Render(fmt.Sprintf(
"%s submit • %s continue editing",
primaryKeyLabel(m.keybindings.General.Confirm),
primaryCombinedKeyLabel(m.keybindings.General.Reject, m.keybindings.Input.Cancel),
)))
return lines
}