feat: add configurable key bindings with ESC quit disable option

- Add unified application configuration system with JSON config file
- Implement configurable quit keys (default: "q", "ctrl+c")
- Add disable_esc_quit option for vim users to prevent accidental exits
- Auto-create default config file at ~/.config/sshm/config.json
- Maintain backward compatibility (ESC quit enabled by default)
- Include comprehensive tests and documentation
This commit is contained in:
zxr
2025-09-29 11:05:26 +08:00
parent 3d746ec49a
commit 120cd6c009
6 changed files with 416 additions and 3 deletions

View File

@@ -445,8 +445,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m Model) handleListViewKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd
key := msg.String()
switch msg.String() {
switch key {
case "esc", "ctrl+c":
if m.deleteMode {
// Exit delete mode
@@ -455,10 +456,16 @@ func (m Model) handleListViewKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
m.table.Focus()
return m, nil
}
return m, tea.Quit
// Use configurable key bindings for quit
if m.appConfig != nil && m.appConfig.KeyBindings.ShouldQuitOnKey(key) {
return m, tea.Quit
}
case "q":
if !m.searchMode && !m.deleteMode {
return m, tea.Quit
// Use configurable key bindings for quit
if m.appConfig != nil && m.appConfig.KeyBindings.ShouldQuitOnKey(key) {
return m, tea.Quit
}
}
case "/", "ctrl+f":
if !m.searchMode && !m.deleteMode {