Skip to content

Phase B.5c followup — lift find_replace into quadraui::{tui,gtk} (primitive migration) #271

Description

@JDonaghy

Goal

Lift the find/replace overlay rasterisers — TUI (src/tui_main/quadraui_tui.rs::draw_find_replace, ~280 lines) and GTK (src/gtk/draw.rs::draw_find_replace_popup, ~300 lines) — into quadraui::{tui,gtk}::*, mirroring B5c.5 / #266.

Split out from #266 because it is materially bigger than rich_text_popup / completions: it requires designing a new quadraui::primitives::find_replace (the other two were straight ports against existing primitives + theme fields).

Why bigger than the other lifts in #266

The find/replace rasterisers consume vimcode-private engine types:

  • core::engine::FindReplaceClickTarget (enum, ~14 variants — Chevron, FindInput(usize), ToggleCase, PrevMatch, Close, ReplaceCurrent, …)
  • core::engine::FrHitRegion (struct: col, row, width in cells)
  • core::engine::FR_PANEL_WIDTH
  • core::engine::compute_find_replace_hit_regions(panel_w, show_replace, match_info) -> (Vec<(FrHitRegion, FindReplaceClickTarget)>, u16)
  • render::FindReplacePanel (the ScreenLayout field — query / replacement / focus / cursor / sel_anchor / match_info / hit_regions / etc.)
  • crate::icons::FIND_REPLACE and crate::icons::FIND_REPLACE_ALL (Nerd Font glyph constants)

The two other lifts in #266 (rich_text_popup, completions) consumed only existing quadraui::* primitives + theme fields. find_replace requires inventing a new primitive in quadraui first, then migrating engine + render + both backends to use it.

Scope

  1. New quadraui::primitives::find_replace with:
    • pub enum FindReplaceClickTarget (lifted verbatim from engine).
    • pub struct FrHitRegion (lifted verbatim).
    • pub const FR_PANEL_WIDTH: u16.
    • pub fn compute_hit_regions(panel_w, show_replace, match_info) -> (Vec<(FrHitRegion, FindReplaceClickTarget)>, u16).
    • pub struct FindReplacePanel { /* the data the rasteriser reads */ }.
  2. Engine adoption:
    • core::engine::* re-exports the lifted enum/struct so existing call sites keep working unchanged, OR the engine imports them back from quadraui (preferred).
    • compute_find_replace_hit_regions either becomes a thin wrapper around the quadraui function, or is replaced at call sites.
  3. Render adoption:
    • render::FindReplacePanel → either becomes an alias for quadraui::FindReplacePanel or the engine builds a quadraui::FindReplacePanel directly into ScreenLayout.
  4. Icon constants: the two crate::icons::FIND_REPLACE* glyphs need a backend-agnostic representation. Options:
    • Pass them in via the FindReplacePanel data (e.g. replace_one_glyph: char, replace_all_glyph: char). Lets the app choose Nerd Font vs ASCII fallback.
    • Keep them in vimcode and add backend-specific glyph fields.
  5. Lifted rasterisers:
    • quadraui::tui::draw_find_replace(buf, area, panel, theme, editor_left) — port of the TUI shim body.
    • quadraui::gtk::draw_find_replace(cr, layout, panel, theme, line_height, char_width, editor_left) — port of the GTK draw.rs body.
  6. Both backend shims then collapse to thin delegators.

Why defer rather than do this in #266

#266 says "mostly mechanical" lifts. The other two (rich_text_popup + completions) genuinely were. find_replace ends up reshaping engine and render adoption, which is one stage of work in itself, and would have made #266's PR materially harder to review.

Pickup files

  • src/core/engine/mod.rs lines 1060-1210 (FindReplaceClickTarget, FrHitRegion, FR_PANEL_WIDTH, compute_find_replace_hit_regions).
  • src/render.rs line 3410+ (FindReplacePanel, the re-export at line 3406).
  • src/tui_main/quadraui_tui.rs::draw_find_replace (the body the lift will copy).
  • src/gtk/draw.rs::draw_find_replace_popup (same).
  • src/core/engine/execute.rs::handle_find_replace_click and similar — engine-side dispatchers that consume the enum.
  • src/icons.rsFIND_REPLACE / FIND_REPLACE_ALL.

Surfaced during

#266 — only the rich_text_popup + completions lifts shipped under #266.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions