Skip to content

Commit 4093e99

Browse files
committed
docs: Additional asyncio docs
1 parent 6af2009 commit 4093e99

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

docs/api/async.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,101 @@ await window.akill(all_except=True)
121121

122122
See {meth}`Window.akill` for full documentation.
123123

124+
### Pane Async Methods
125+
126+
```{eval-rst}
127+
.. autosummary::
128+
:toctree: _autosummary
129+
130+
Pane.asend_keys
131+
Pane.acapture_pane
132+
Pane.asplit
133+
```
134+
135+
#### Pane.asend_keys()
136+
137+
Send keys to pane asynchronously, enabling non-blocking command execution.
138+
139+
```python
140+
# Basic usage
141+
await pane.asend_keys('echo "Hello"', enter=True)
142+
143+
# Send without executing
144+
await pane.asend_keys('ls -la', enter=False)
145+
146+
# Literal mode (special chars as text)
147+
await pane.asend_keys('C-c', literal=True)
148+
149+
# Suppress shell history
150+
await pane.asend_keys('secret_command', suppress_history=True)
151+
152+
# Concurrent execution across multiple panes
153+
await asyncio.gather(
154+
pane1.asend_keys('echo "pane1"'),
155+
pane2.asend_keys('echo "pane2"'),
156+
pane3.asend_keys('echo "pane3"'),
157+
)
158+
```
159+
160+
See {meth}`Pane.asend_keys` for full documentation.
161+
162+
#### Pane.acapture_pane()
163+
164+
Capture pane output asynchronously, enabling concurrent monitoring.
165+
166+
```python
167+
# Capture visible pane
168+
output = await pane.acapture_pane()
169+
170+
# Capture with history (last 10 lines)
171+
output = await pane.acapture_pane(start=-10)
172+
173+
# Capture specific range
174+
output = await pane.acapture_pane(start=0, end=5)
175+
176+
# Capture complete scrollback
177+
output = await pane.acapture_pane(start="-", end="-")
178+
179+
# Concurrent capture from multiple panes
180+
outputs = await asyncio.gather(
181+
pane1.acapture_pane(),
182+
pane2.acapture_pane(),
183+
pane3.acapture_pane(),
184+
)
185+
```
186+
187+
See {meth}`Pane.acapture_pane` for full documentation.
188+
189+
#### Pane.asplit()
190+
191+
Split pane asynchronously, enabling rapid layout creation.
192+
193+
```python
194+
# Default split (below)
195+
new_pane = await pane.asplit()
196+
197+
# Vertical split (right)
198+
from libtmux.pane import PaneDirection
199+
new_pane = await pane.asplit(direction=PaneDirection.Right)
200+
201+
# With custom directory and size
202+
new_pane = await pane.asplit(
203+
start_directory='/tmp',
204+
size="30%"
205+
)
206+
207+
# With shell command (auto-closes)
208+
new_pane = await pane.asplit(shell='echo "done"')
209+
210+
# Concurrent splits for rapid layout
211+
new_panes = await asyncio.gather(
212+
pane.asplit(direction=PaneDirection.Right),
213+
pane.asplit(direction=PaneDirection.Below),
214+
)
215+
```
216+
217+
See {meth}`Pane.asplit` for full documentation.
218+
124219
## Usage Patterns
125220

126221
### Basic Async Pattern

0 commit comments

Comments
 (0)