fix: replace Ctrl+Enter with Ctrl+S in forms to avoid terminal conflicts

This commit is contained in:
Gu1llaum-3 2025-09-13 11:47:30 +02:00
parent 2425695992
commit 45eccabc23
2 changed files with 10 additions and 8 deletions

View File

@ -4,9 +4,10 @@ import (
"os"
"os/user"
"path/filepath"
"strings"
"github.com/Gu1llaum-3/sshm/internal/config"
"github.com/Gu1llaum-3/sshm/internal/validation"
"strings"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
@ -148,8 +149,8 @@ func (m *addFormModel) Update(msg tea.Msg) (*addFormModel, tea.Cmd) {
case "ctrl+c", "esc":
return m, func() tea.Msg { return addFormCancelMsg{} }
case "ctrl+enter":
// Allow submission from any field with Ctrl+Enter
case "ctrl+s":
// Allow submission from any field with Ctrl+S (Save)
return m, m.submitForm()
case "tab", "shift+tab", "enter", "up", "down":
@ -238,7 +239,7 @@ func (m *addFormModel) View() string {
b.WriteString("\n\n")
}
b.WriteString(m.styles.FormHelp.Render("Tab/Shift+Tab: navigate • Enter on last field: submit • Ctrl+Enter: submit • Ctrl+C/Esc: cancel"))
b.WriteString(m.styles.FormHelp.Render("Tab/Shift+Tab: navigate • Enter on last field: submit • Ctrl+S: save • Ctrl+C/Esc: cancel"))
b.WriteString("\n")
b.WriteString(m.styles.FormHelp.Render("* Required fields"))

View File

@ -1,9 +1,10 @@
package ui
import (
"strings"
"github.com/Gu1llaum-3/sshm/internal/config"
"github.com/Gu1llaum-3/sshm/internal/validation"
"strings"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
@ -139,8 +140,8 @@ func (m *editFormModel) Update(msg tea.Msg) (*editFormModel, tea.Cmd) {
case "ctrl+c", "esc":
return m, func() tea.Msg { return editFormCancelMsg{} }
case "ctrl+enter":
// Allow submission from any field with Ctrl+Enter
case "ctrl+s":
// Allow submission from any field with Ctrl+S (Save)
return m, m.submitEditForm()
case "tab", "shift+tab", "enter", "up", "down":
@ -247,7 +248,7 @@ func (m *editFormModel) View() string {
b.WriteString("\n\n")
}
b.WriteString(m.styles.FormHelp.Render("Tab/Shift+Tab: navigate • Enter on last field: submit • Ctrl+Enter: submit • Ctrl+C/Esc: cancel"))
b.WriteString(m.styles.FormHelp.Render("Tab/Shift+Tab: navigate • Enter on last field: submit • Ctrl+S: save • Ctrl+C/Esc: cancel"))
b.WriteString("\n")
b.WriteString(m.styles.FormHelp.Render("* Required fields"))