feat: Zed-style cursor rendering implementation#26
Open
Conversation
Two issues fixed: 1. Added mouse event handlers to divider element - on_mouse_move to track drag position - on_mouse_up to end drag Previously events were only on parent, but mouse moves off divider during drag 2. Fixed calculate_new_ratios ratio calculation - Was incorrectly assuming ratios sum to 1.0 (visible_ratio_total = 1.0 - hidden) - Actually ratios are [1.0, 2.0, 1.0] summing to 4.0 - Now correctly sums visible ratios for proper width calculation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The custom cursor rendering was causing layout problems, particularly with TUI applications like Claude Code where the cursor appeared in the wrong position (below the status line) and caused the UI to shift. Changes: - Add display_offset, line_offset, viewport_rows to TerminalContentSnapshot - Improve build_lines_from_content to handle non-zero starting line indices - Disable custom cursor rendering (TODO: implement proper cursor following Zed's terminal_element.rs approach) The terminal content from alacritty already handles cursor visualization through cell attributes, so disabling the custom cursor overlay provides a better user experience until proper cursor rendering is implemented. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Following Zed's terminal_element.rs patterns: - Add DisplayCursor struct with from(cursor_point, display_offset) - Use BTreeMap for line grouping with enumerated screen positions - Add shape_cursor function with viewport bounds checking - Re-enable cursor rendering with proper coordinate transformation The key insight from Zed: cursor.line.0 + display_offset transforms Alacritty's coordinate system (negative scrollback) into screen coordinates (0, 1, 2...). References: zed/crates/terminal_view/src/terminal_element.rs - DisplayCursor: lines 59-79 - shape_cursor: lines 504-528 - Cell enumeration: lines 1117-1124 - Cursor creation: line 1137 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The custom cursor was rendering in the wrong position (below the status bar in TUI apps like Claude Code). Disabling it makes the terminal more usable while we investigate the root cause. Investigation findings: - Coordinate transformation (line.0 + display_offset) appears correct - Content and cursor use same coordinate system - Spacing issue (UI shifted 1 line) exists independently of cursor - Root cause still under investigation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3 tasks
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add backticks around code identifiers in doc comments (doc_markdown) - Make DisplayCursor methods const fn (missing_const_for_fn) - Add #[allow(...)] attributes for intentional casts (cast_possible_truncation, cast_possible_wrap, cast_precision_loss, cast_sign_loss) - Mark shape_cursor as #[allow(dead_code)] for future use - Replace .iter() with reference iteration (explicit_iter_loop) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
terminal_element.rspatternsDisplayCursortransformation:cursor.line.0 + display_offsetfor correct screen coordinatesKey Changes
DisplayCursorstruct withfrom(cursor_point, display_offset)methodshape_cursorfunction with viewport bounds checkingpaint()methodZed Reference Points
zed/crates/terminal_view/src/terminal_element.rs:Test Plan
🤖 Generated with Claude Code