Skip to content

fix(examples): reset cursor on ctrl+c in counter example#198

Merged
ccbrown merged 1 commit into
ccbrown:mainfrom
mvanhorn:osc/197-cursor-reset-counter-example
Apr 26, 2026
Merged

fix(examples): reset cursor on ctrl+c in counter example#198
ccbrown merged 1 commit into
ccbrown:mainfrom
mvanhorn:osc/197-cursor-reset-counter-example

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

What It Does

Adds the maintainer's option-1 fix from #197 to examples/counter.rs: a single hooks.use_terminal_events(|_| {}) call (with a comment explaining why) that puts the terminal in raw mode so ctrl+c is delivered as a key event instead of a SIGINT. With raw mode active, the existing ignore_ctrl_c path in packages/iocraft/src/element.rs:514 exits the render loop cleanly and runs drop handlers, which restores the cursor. Every other interactive example already does this (use_input.rs:15, weather.rs:222, fullscreen.rs:19, scrolling.rs:14, form.rs:58, calculator.rs:261); the counter example was the outlier.

This is intentionally the smallest possible change. The library itself is untouched and no new dependencies are added, matching the maintainer's note that iocraft should not set a global signal handler. If you'd rather close this in favor of a documentation-only approach (the second half of your suggestion), this PR can be discarded without churn.

Related Issues

Closes #197

This contribution was developed with AI assistance (Codex).

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.00%. Comparing base (b92b621) to head (7d7eacd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #198   +/-   ##
=======================================
  Coverage   88.00%   88.00%           
=======================================
  Files          35       35           
  Lines        5662     5662           
  Branches     5662     5662           
=======================================
  Hits         4983     4983           
  Misses        569      569           
  Partials      110      110           

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 3a91645 into ccbrown:main Apr 26, 2026
5 checks passed
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Thanks @ccbrown for the merge and for laying out option 1 so clearly in #197 - dropping that one-liner into counter.rs ended up being the cleanest fix for the cursor restore.

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.

Cursor state not reliably reset

2 participants