feat: ring terminal bell on blocked edge-scroll#9
Merged
Conversation
Vim-style cue: when j/k, d/u, or f/b/Space/PgUp/PgDn would push the viewport past the top or bottom but it's already pinned, termdown now emits a `\x07` BEL to stderr. The terminal emulator decides what the user sees — Ghostty's default `bell-features` puts a 🔔 in the window title, iTerm2/Terminal.app bounce the dock, audible-bell users get a beep. Explicit jumps (gg/G/]/[) stay silent to match vim's scope. Detection lives in the dispatcher, not in `Viewport`: we capture `viewport.top` before/after `scroll_by` and ring when it didn't move. This keeps `Viewport` free of `App`/`Config`/IO coupling and means the three scroll-action arms share one helper (`perform_scroll`). Off-switch: - `bell = false` in ~/.termdown/config.toml - `--no-bell` CLI flag (also documented in --help) Closes the TODO.md item for top/bottom audio feedback.
- ring_bell now takes &Config instead of &App, documenting the actual dependency and making the helper trivially testable without an App. - Drop the redundant flush() — std::io::Stderr is unbuffered, so the BEL byte hits the fd immediately on write_all. Matches the rest of the codebase (eprintln! never manually flushes). - Use io::stderr().write_all(...) instead of fully-qualified std::io::Write::write_all(...) now that Write is already in scope at the top of the file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
\x07to stderr. The terminal emulator decides the visible effect — Ghostty puts a 🔔 in the window title, iTerm2/Terminal.app bounce the dock, audible-bell users get a beep. Explicit jumps (gg/G/]/[) stay silent to match vim's behavior.Viewport: captureviewport.topbefore/afterscroll_byand ring when it didn't move. KeepsViewportpure (noApp/Config/IO coupling) and lets the three scroll-action arms share oneperform_scrollhelper.bell = falsein~/.termdown/config.tomlor--no-bellon the command line (documented in--help).Test plan
make fmt && make checkclean (73 unit + 9 CLI + 5 snapshot tests, clippy-D warningsclean)cargo run -- --helplists--no-belljpast the bottom → BEL fires; Ghostty shows 🔔 in title bar (its defaultbell-featuresincludestitle).gg/G/]/[at edges stay silent.bell-features/ "Audible bell" setting.🤖 Generated with Claude Code