Skip to content

feat: add inverted text style#196

Merged
ccbrown merged 2 commits into
ccbrown:mainfrom
officialasishkumar:feat/invert-text-style
Apr 24, 2026
Merged

feat: add inverted text style#196
ccbrown merged 2 commits into
ccbrown:mainfrom
officialasishkumar:feat/invert-text-style

Conversation

@officialasishkumar
Copy link
Copy Markdown
Contributor

What It Does

Adds support for inverted text styling, backed by crossterm's reverse video attribute.

This adds an invert flag to CanvasTextStyle, exposes the same option on Text, and adds an invert() builder method for MixedTextContent. ANSI rendering now emits Attribute::Reverse when inverted text begins and resets when it ends.

Focused tests cover ANSI output, direct canvas cell style access, Text, and MixedText.

Related Issues

Fixes #108

Copy link
Copy Markdown
Owner

@ccbrown ccbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! One comment but otherwise lgtm!

Comment thread packages/iocraft/src/canvas.rs Outdated
if !c.style.invert && text_style.invert {
needs_reset = true;
}
} else if text_style.underline || text_style.italic || text_style.invert {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be any need to add italic to the check here since the state of the italic attribute doesn't impact the rendering of empty cells.

Suggested change
} else if text_style.underline || text_style.italic || text_style.invert {
} else if text_style.underline || text_style.invert {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the unnecessary italic check for empty cells. cargo test -p iocraft passes. Commit: b3feeeb

@ccbrown ccbrown added the enhancement New feature or request label Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.00%. Comparing base (4c8bf90) to head (b3feeeb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/iocraft/src/canvas.rs 96.55% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #196      +/-   ##
==========================================
+ Coverage   87.92%   88.00%   +0.07%     
==========================================
  Files          35       35              
  Lines        5617     5662      +45     
  Branches     5617     5662      +45     
==========================================
+ Hits         4939     4983      +44     
  Misses        569      569              
- Partials      109      110       +1     
Files with missing lines Coverage Δ
packages/iocraft/src/components/mixed_text.rs 93.10% <100.00%> (+0.79%) ⬆️
packages/iocraft/src/components/text.rs 99.64% <100.00%> (+<0.01%) ⬆️
packages/iocraft/src/canvas.rs 95.20% <96.55%> (+0.05%) ⬆️

Impacted file tree graph

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

Copy link
Copy Markdown
Owner

@ccbrown ccbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ccbrown ccbrown merged commit b92b621 into ccbrown:main Apr 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for more terminal attributes

2 participants