summaryrefslogtreecommitdiff
path: root/internal/tmuxedit/agent.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tmuxedit/agent.go')
-rw-r--r--internal/tmuxedit/agent.go21
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.