summaryrefslogtreecommitdiff
path: root/internal/tui/keys_normalize.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-18 09:29:33 +0200
committerPaul Buetow <paul@buetow.org>2026-03-18 09:29:33 +0200
commitc234be24815452fa1143c9a523f4615e0d745fb7 (patch)
tree8737bfef26f4208f31e296cdabf6849a3daf1cb8 /internal/tui/keys_normalize.go
parentdbb98cd8dbd70dd92b8a541653e64c45b18348fa (diff)
refactor: extract keyboardState, filterState, processState sub-structs from tui.Model (task 429)
tui.Model had 33 fields mixing keyboard tracking, filter chain, process selection, and UI presentation concerns (SRP violation). Extract three focused sub-structs: - keyboardState (kb): enhancements, lastEvent{ID,At,WasPress}, suppress{ID,Until} — 7 fields managed by keys_normalize.go - filterState (filter): global filter, history slice, label stack — 3 fields for the trace filter chain - processState (proc): pid, tid, pickerReturn — 3 fields for PID/TID selection and picker navigation Model drops from 33 to 23 top-level fields. All field accesses in tui.go, keys_normalize.go, and tui_test.go are updated accordingly. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'internal/tui/keys_normalize.go')
-rw-r--r--internal/tui/keys_normalize.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/internal/tui/keys_normalize.go b/internal/tui/keys_normalize.go
index 173847e..777749b 100644
--- a/internal/tui/keys_normalize.go
+++ b/internal/tui/keys_normalize.go
@@ -19,9 +19,9 @@ func (m *Model) normalizeKeyEvent(msg tea.Msg) (tea.Msg, bool) {
case tea.KeyReleaseMsg:
pressMsg := tea.KeyPressMsg(keyMsg)
keyID := keyEventID(pressMsg)
- if m.lastKeyEventWasPress && keyID != "" && keyID == m.lastKeyEventID && time.Since(m.lastKeyEventAt) <= 500*time.Millisecond {
+ if m.kb.lastEventWasPress && keyID != "" && keyID == m.kb.lastEventID && time.Since(m.kb.lastEventAt) <= 500*time.Millisecond {
// Some terminals emit both press+release; avoid handling release as a duplicate.
- m.lastKeyEventWasPress = false
+ m.kb.lastEventWasPress = false
return nil, false
}
if !releaseHasIdentity(pressMsg) {
@@ -41,14 +41,14 @@ func (m *Model) normalizeKeyEvent(msg tea.Msg) (tea.Msg, bool) {
}
func (m *Model) shouldSuppressPress(keyID string) bool {
- if m.suppressPressKeyID == "" {
+ if m.kb.suppressID == "" {
return false
}
- if time.Now().After(m.suppressPressUntil) {
+ if time.Now().After(m.kb.suppressUntil) {
m.clearPressSuppression()
return false
}
- if keyID == "" || keyID != m.suppressPressKeyID {
+ if keyID == "" || keyID != m.kb.suppressID {
return false
}
m.clearPressSuppression()
@@ -60,19 +60,19 @@ func (m *Model) armPressSuppression(keyID string) {
return
}
// Keep this short so fast repeated key presses still work naturally.
- m.suppressPressKeyID = keyID
- m.suppressPressUntil = time.Now().Add(60 * time.Millisecond)
+ m.kb.suppressID = keyID
+ m.kb.suppressUntil = time.Now().Add(60 * time.Millisecond)
}
func (m *Model) clearPressSuppression() {
- m.suppressPressKeyID = ""
- m.suppressPressUntil = time.Time{}
+ m.kb.suppressID = ""
+ m.kb.suppressUntil = time.Time{}
}
func (m *Model) recordKeyEvent(msg tea.KeyPressMsg, wasPress bool) {
- m.lastKeyEventID = keyEventID(msg)
- m.lastKeyEventAt = time.Now()
- m.lastKeyEventWasPress = wasPress
+ m.kb.lastEventID = keyEventID(msg)
+ m.kb.lastEventAt = time.Now()
+ m.kb.lastEventWasPress = wasPress
}
func keyEventID(msg tea.KeyPressMsg) string {