Fix curses frame display corruption issue#3
Open
morria wants to merge 2 commits into
Open
Conversation
The original curses implementation had height accounting problems where the waterfall would overflow and mangle the display when it hit the bottom of the window. This manifested as: - Top of waterfall getting pushed above the screen - Debug output wrapping incorrectly at the bottom This migration to Textual fixes these issues through: - Proper CSS-based layout system with 'height: 1fr' for waterfall - Automatic height management in WaterfallWidget.render() - Explicit trimming of time_series to available widget height - Better separation of concerns with dedicated widget classes - Improved border accounting (available_height = height - 2) The Textual framework provides better abstractions for TUI layout and automatically handles window resizing, eliminating manual height calculation errors. All original features preserved: - Real-time spectrum graph with sub-character resolution - Scrolling waterfall display - Peak hold mode - Pause/resume - Dynamic sensitivity adjustment - Help overlay - Keyboard shortcuts
When running with piped input (hackrf_sweep | ./spectrum_analyzer.py), there were several issues: 1. Race condition: Data thread started in __init__ before app mounted - Moved thread start to on_mount() method - Prevents call_from_thread() before event loop ready 2. Poor exception handling in data worker thread - Added specific KeyboardInterrupt handler - Added try/except around call_from_thread() - Proper cleanup in finally block - Better logging with exc_info 3. Missing /dev/tty accessibility check - Added check to verify /dev/tty is accessible - Provides clear error message if running non-interactively - Textual auto-detects and uses /dev/tty when stdin is piped 4. Unhandled exceptions in run_spectrum_analyzer - Wrapped app.run() with proper exception handling - Graceful KeyboardInterrupt handling These fixes ensure the app: - Properly handles stdin as data pipe while using /dev/tty for UI - Doesn't crash on Ctrl+C - Exits cleanly when data stream ends - Provides helpful error messages for configuration issues
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.
The original curses implementation had height accounting problems where the waterfall would overflow and mangle the display when it hit the bottom of the window. This manifested as:
This migration to Textual fixes these issues through:
The Textual framework provides better abstractions for TUI layout and automatically handles window resizing, eliminating manual height calculation errors.
All original features preserved: