Skip to content

Conversation

@tony
Copy link
Member

@tony tony commented Dec 7, 2025

Pane.capture_pane() enhanced (#614)

The {meth}~libtmux.pane.Pane.capture_pane method now supports 5 new parameters
that expose additional tmux capture-pane flags:

Parameter tmux Flag Description
escape_sequences -e Include ANSI escape sequences (colors, attributes)
escape_non_printable -C Escape non-printable chars as octal \xxx
join_wrapped -J Join wrapped lines back together
preserve_trailing -N Preserve trailing spaces at line ends
trim_trailing -T Trim trailing empty positions (tmux 3.4+)

Capturing colored output:

# Capture with ANSI escape sequences preserved
pane.send_keys('printf "\\033[31mRED\\033[0m"', enter=True)
output = pane.capture_pane(escape_sequences=True)
# Output contains: '\x1b[31mRED\x1b[0m'

Joining wrapped lines:

# Long lines that wrap are joined back together
output = pane.capture_pane(join_wrapped=True)

Version compatibility:

The trim_trailing parameter requires tmux 3.4+. If used with an older version,
a warning is issued and the flag is ignored. All other parameters work with
libtmux's minimum supported version (tmux 3.2a).

tony added 2 commits December 7, 2025 14:27
why: Expose more tmux capture-pane capabilities for advanced use cases
like capturing colored output, handling wrapped lines, and controlling
trailing space behavior.

what:
- Add escape_sequences parameter (-e flag) for ANSI escape sequences
- Add escape_non_printable parameter (-C flag) for octal escapes
- Add join_wrapped parameter (-J flag) for joining wrapped lines
- Add preserve_trailing parameter (-N flag) for trailing spaces
- Add trim_trailing parameter (-T flag) with tmux 3.4+ version check
- Issue warning when trim_trailing used with tmux < 3.4
why: Ensure comprehensive coverage of all capture_pane() flag
combinations with parametrized test cases.

what:
- Add CapturePaneCase NamedTuple for test case definitions
- Add 16 parametrized test cases covering all flag variations
- Add backward compatibility test for existing code
- Add start/end parameters test with new flags
- Add trim_trailing warning test for tmux version check
- Use marker-based completion detection for reliability
@tony tony force-pushed the capture-pane-updates branch from 3e43532 to 2b5dd49 Compare December 7, 2025 20:28
@tony tony marked this pull request as ready for review December 7, 2025 20:29
tony added 2 commits December 7, 2025 14:30
why: Document the new capture_pane() parameters for the changelog.

what:
- Add section for Pane.capture_pane() enhanced
- Document all 5 new parameters with flag mappings
- Add code examples for colored output and joined lines
- Note trim_trailing requires tmux 3.4+
why: Provide practical examples for the new capture_pane() parameters
in the pane interaction topic documentation.

what:
- Add section for capturing ANSI escape sequences
- Add section for joining wrapped lines
- Add section for preserving trailing spaces
- Add capture flags summary table
- Add note about trim_trailing tmux 3.4+ requirement
@tony tony force-pushed the capture-pane-updates branch from 2b5dd49 to 279b6d4 Compare December 7, 2025 20:30
@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.68%. Comparing base (bd13b1e) to head (279b6d4).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #614      +/-   ##
==========================================
+ Coverage   45.34%   45.68%   +0.34%     
==========================================
  Files          22       22              
  Lines        2236     2250      +14     
  Branches      354      360       +6     
==========================================
+ Hits         1014     1028      +14     
  Misses       1079     1079              
  Partials      143      143              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony
Copy link
Member Author

tony commented Dec 7, 2025

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@tony tony merged commit 7fca580 into master Dec 7, 2025
14 checks passed
@tony tony deleted the capture-pane-updates branch December 7, 2025 20:42
@tony tony changed the title Capture pane updates feat(Pane[capture_pane]) Support new capture-pane flags Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants