Skip to content

feat: support SetInputCapture per primitive #13

@cassdeckard

Description

@cassdeckard

Summary

Add support for SetInputCapture on individual primitives via an onInputCapture template expression, so primitives can handle keys before global key bindings. tviewyaml currently only has globalKeyBindings at the application level.

Background

Discovered while planning a tview presentation demo implementation via tviewyaml. The Flex and Grid slides use SetInputCapture on the main primitive to show a modal on first keypress, then advance slide on second keypress.

Demo Usage

Flex and Grid use SetInputCapture for custom keys; tviewyaml only has globalKeyBindings.

Proposed Approach

  • Add onInputCapture (template expression) to Primitive config; expression receives key event info, returns whether to consume event
  • In builder, call primitive.SetInputCapture(...) with a handler that evaluates the template
  • Ordering: primitive capture runs before app-level capture; document interaction with globalKeyBindings

Relevant Files

  • config/types.go – add onInputCapture
  • builder/properties.go or builder/callbacks.go – attach SetInputCapture
  • template/ – key event helpers for template
  • docs/tview-coverage.md – document once implemented

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions