Plan implementation for showing cursor beam

Medium
Unlisted
Implement a plan for how to show the current cursor position as a beam |
Sorry, *come up* with that plan: analyze the code, think hard, come up with a plan

Based on the analysis, here's the plan for implementing a cursor beam:

Cursor Beam Implementation Plan

1. Data Model Changes

  • Add Cursor struct with position, color, style (beam width), and visibility flag
  • Add CursorStyle::Beam { width_px } enum for future extensibility
  • Extend Scene to include cursor: Option<Cursor>

2. Shader Pipeline

  • Add new solid_fragment shader that renders solid color without texture sampling
  • Reuse existing text_vertex shader and TextVertexIn structure
  • Create separate solid_pipeline_state in Renderer

3. Rendering Logic

  • Use GridConfig::grid_to_ndc() to calculate cursor position in NDC
  • Generate 4-vertex triangle strip for thin vertical beam at cursor column
  • Beam dimensions: 2-3px width × full cell height
  • Render cursor after text so it appears on top

4. Blinking Mechanism

  • Add Instant-based timer fields to Renderer: cursor_blink_interval, cursor_blink_last_toggle, cursor_blink_on
  • Toggle visibility every ~500ms
  • Reset blink to "on" state on keyboard input

5. Integration

  • Pull cursor position from Terminal::cursor_position() when building Scene
  • Re-enable Terminal::update_max_cols() to sync with GridConfig.cols on resize
  • Pass cursor data through Scene → Renderer → draw call

6. Implementation Order

  1. Add shader function (solid_fragment)
  2. Update Scene structs (Cursor, CursorStyle)
  3. Add Renderer blink timer fields & pipeline setup
  4. Implement cursor quad generation in draw()
  5. Wire Terminal cursor to Scene in app/window code
  6. Test & tune beam width and blink timing

This approach keeps text rendering untouched while adding minimal, clean cursor rendering with ~100 lines of new code.

great!