Skip to content

TUI: Unify sidebar panel key translation into a shared helper #475

Description

@JDonaghy

Tier: Ready now (no quadraui gap)

Summary

src/tui_main/mod.rs:2106–2249 has three near-identical KeyCode → engine-string translation blocks — one each for the Extensions sidebar, Settings panel, and Debug sidebar — before dispatching into the engine. Each block re-maps Esc → "Escape", Enter → "Return", BackSpace, Tab, arrow keys, etc. A shared helper would let the per-panel sites collapse to a single function call plus the panel-specific dispatch.

What exists

  • translate_key() (src/tui_main/mod.rs:3240, ~100 lines) — the general crossterm → engine key translator used by the editor path. The sidebar paths bypass it and rebuild the same map inline.
  • Each engine panel-key API already takes a &str keyname (or (keyname, Option<char>)) — they're already shaped to receive translator output.

What to do

  1. Extract the common KeyCode → keyname mapping into a helper (e.g. tui_key_to_engine_name(code) -> Option<String>). It can live in src/tui_main/mod.rs since it's TUI-specific input adaption, OR be promoted to src/render.rs if the same shape is useful for other surfaces.
  2. Replace the three inline match blocks (Extensions ~30 lines, Settings ~14 lines, Debug ~10 lines) with calls to the helper.
  3. Verify each panel still dispatches correctly via its existing engine method (dispatch_ext_sidebar_key_unified, handle_settings_key, handle_dap_sidebar_key).

Files

  • src/tui_main/mod.rs — ~80 lines removed across the three sidebar blocks (lines 2106–2249).

Dependencies

None. No quadraui gap.

Notes

Part of the TUI convergence backlog (#474). Sister issue to GTK's handle_key_press consolidation (#448). Small standalone refactor — good first issue in the backlog.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestuiUI/rendering

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions