diff --git a/internal/termapp/command.go b/internal/termapp/command.go index 20d2f82..0df8664 100644 --- a/internal/termapp/command.go +++ b/internal/termapp/command.go @@ -439,8 +439,14 @@ func (d *CommandDispatcher) handleModeCommand(args []string) error { switch field { case "in": + if value == "" { + return fmt.Errorf("input charset must not be empty") + } d.app.cfg.InputCode = value case "out": + if value == "" { + return fmt.Errorf("output charset must not be empty") + } d.app.cfg.OutputCode = value case "end": d.app.cfg.EndStr = value @@ -457,6 +463,9 @@ func (d *CommandDispatcher) handleModeCommand(args []string) error { } d.app.cfg.TimesTamp = enabled case "timefmt": + if value == "" && d.app.cfg.TimesTamp { + return fmt.Errorf("timestamp format must not be empty") + } d.app.cfg.TimesFmt = value default: return fmt.Errorf("unknown mode field: %s", field) diff --git a/internal/termapp/tui_hotkeys.go b/internal/termapp/tui_hotkeys.go index 3704596..5a480c6 100644 --- a/internal/termapp/tui_hotkeys.go +++ b/internal/termapp/tui_hotkeys.go @@ -101,11 +101,11 @@ func (m *uiModel) handleViewportKey(msg tea.KeyMsg) bool { m.viewport, cmd = m.viewport.Update(msg) _ = cmd return true - case "home", "g": + case "home": m.viewport.GotoTop() m.followTail = false return true - case "end", "shift+g": + case "end": m.viewport.GotoBottom() m.followTail = true return true diff --git a/internal/termapp/tui_model.go b/internal/termapp/tui_model.go index a47516b..feee8fe 100644 --- a/internal/termapp/tui_model.go +++ b/internal/termapp/tui_model.go @@ -16,9 +16,10 @@ import ( type doneMsg struct{} type modeItem struct { - key string - label string - value string + key string + label string + value string + rawValue string } type panelLine struct { diff --git a/internal/termapp/tui_panels.go b/internal/termapp/tui_panels.go index 3293896..68ff218 100644 --- a/internal/termapp/tui_panels.go +++ b/internal/termapp/tui_panels.go @@ -71,7 +71,14 @@ func (m *uiModel) refreshPanel() { } func (m *uiModel) buildModeItems() []modeItem { - return []modeItem{{"in", "Input Charset", m.app.cfg.InputCode}, {"out", "Output Charset", m.app.cfg.OutputCode}, {"end", "Line End", fmt.Sprintf("%q", m.app.cfg.EndStr)}, {"frame", "Hex Frame Size", fmt.Sprintf("%d", m.app.cfg.FrameSize)}, {"timestamp", "Timestamp", fmt.Sprintf("%v", m.app.cfg.TimesTamp)}, {"timefmt", "Timestamp Format", m.app.cfg.TimesFmt}} + return []modeItem{ + {"in", "Input Charset", m.app.cfg.InputCode, m.app.cfg.InputCode}, + {"out", "Output Charset", m.app.cfg.OutputCode, m.app.cfg.OutputCode}, + {"end", "Line End", fmt.Sprintf("%q", m.app.cfg.EndStr), m.app.cfg.EndStr}, + {"frame", "Hex Frame Size", fmt.Sprintf("%d", m.app.cfg.FrameSize), fmt.Sprintf("%d", m.app.cfg.FrameSize)}, + {"timestamp", "Timestamp", fmt.Sprintf("%v", m.app.cfg.TimesTamp), fmt.Sprintf("%v", m.app.cfg.TimesTamp)}, + {"timefmt", "Timestamp Format", m.app.cfg.TimesFmt, m.app.cfg.TimesFmt}, + } } func (m *uiModel) handleForwardPanelKey(key string) bool { @@ -222,7 +229,7 @@ func (m *uiModel) handleModePanelKey(key string) bool { } return true case "enter", "e": - initial := strings.Trim(sel.value, "\"") + initial := sel.rawValue m.startPrompt("Edit Mode: "+sel.label, "new value", initial, func(v string) { m.app.handleLine(fmt.Sprintf(".mode set %s %s", sel.key, v)) m.refreshPanel()