Skip to content

[Phase 7D] Widget hit-test registry: src/hitbox.sh #31

@fissible

Description

@fissible

What

Build src/hitbox.sh — a widget bounding-box registry for mouse routing.

API:

  • shellframe_widget_register name top left width height — registers a widget's bounding box by name. Coordinates are 1-based terminal rows/columns.
  • shellframe_widget_at row col — returns the name of the widget whose bounding box contains (row, col), or empty string if none. Last-registered wins on overlap.
  • shellframe_widget_clear — clears all registered widgets (call on full repaint).

Implemented as parallel arrays keyed by registration order; name lookup iterates from last to first so later registrations shadow earlier ones.

Files

  • src/hitbox.sh — new module (register, at, clear, parallel arrays)
  • src/shellframe.sh — source hitbox.sh

Done criteria

  • shellframe_widget_register stores bounding box correctly
  • shellframe_widget_at returns the correct widget name for a point inside a registered box
  • shellframe_widget_at returns empty string for a point outside all boxes
  • Overlap behavior: last-registered wins — documented and tested
  • shellframe_widget_clear fully resets state
  • Unit tests in tests/unit/test-hitbox.sh: single widget, multiple non-overlapping widgets, point outside all, overlap
  • All existing assertions still pass

Effort

M (~half day)

Deps

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions