diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-18 07:45:37 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-18 07:45:37 +0300 |
| commit | 4ffb22e7f69f1c9c79b095d4e60bad3d97aac55b (patch) | |
| tree | 2dc708cbb95975d34084eb5afd376871caa13e27 /internal/tmuxedit/agent.go | |
| parent | ece7dcfd232b780f5650326c8ac2379ca70387d4 (diff) | |
ik0 replace test seams with dependency injection
Diffstat (limited to 'internal/tmuxedit/agent.go')
| -rw-r--r-- | internal/tmuxedit/agent.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/internal/tmuxedit/agent.go b/internal/tmuxedit/agent.go index 1ae8f13..42213ce 100644 --- a/internal/tmuxedit/agent.go +++ b/internal/tmuxedit/agent.go @@ -40,6 +40,7 @@ type baseAgent struct { clearKeys string // tmux key sequence to clear input newlineKeys string // tmux key to insert a newline submitKeys string // tmux key to submit the prompt + deps tmuxEditDeps } // Base returns a pointer to the baseAgent for config merging. @@ -95,10 +96,10 @@ func (b *baseAgent) ClearInput(paneID string) error { if !b.clearFirst || b.clearKeys == "" { return nil } - if err := sendClearSequence(paneID, b.clearKeys); err != nil { + if err := b.deps.sendClearSequence(paneID, b.clearKeys); err != nil { return err } - sleepAfterClear() + b.deps.sleep() return nil } @@ -108,7 +109,21 @@ func (b *baseAgent) SendText(paneID, text string) error { if strings.TrimSpace(text) == "" { return nil } - return sendLines(paneID, text, b.newlineKeys) + return b.deps.sendLines(paneID, text, b.newlineKeys) +} + +func withAgentDeps(agents []Agent, deps tmuxEditDeps) []Agent { + for _, agent := range agents { + withAgentDep(agent, deps) + } + return agents +} + +func withAgentDep(agent Agent, deps tmuxEditDeps) Agent { + if c, ok := agent.(Configurable); ok { + c.Base().deps = deps + } + return agent } // detectAgent tries each agent's Detect method against pane content. |
