From a6a1aae9cbd92be269840da9ca62b71d6af827b0 Mon Sep 17 00:00:00 2001 From: blasty Date: Thu, 9 Jul 2026 12:34:32 +0200 Subject: fix decompiler highlighting + cursor jank Highlighting: Textual has NO C/C++ tree-sitter grammar (and the syntax extra wasn't installed), so language='cpp' was a silent no-op. Replace TextArea with a virtualized, Pygments-highlighted ScrollView: - idatui/highlight.py: CLexer -> Rich styles, per-line Segment lists - DecompView: lines highlighted ONCE at load, cached as Strips; O(1) scroll Jank: profiling showed our code is ~3.6ms/move (render_line 0.018ms) -- the cost was terminal repaint volume, since every cursor move refreshed the whole ~43-line viewport. Now: - cursor reactive repaint=False (no implicit full refresh) - region-limited refresh: in-place moves repaint only the 2 changed rows (measured 43 -> 2 render_line calls/move), full refresh only on scroll Applied to both DisasmView and DecompView. pilot suite 15/15 (adds highlighting assertion). --- tests/test_tui.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_tui.py b/tests/test_tui.py index 683f896..0054765 100644 --- a/tests/test_tui.py +++ b/tests/test_tui.py @@ -135,8 +135,14 @@ async def run(db): pc = await wait_until(pilot, lambda: dec.display and dec.loaded_ea is not None, 25) check("tab shows pseudocode", pc and app._active == "decomp", f"active={app._active} disp={dec.display}") - check("pseudocode has real body (not 1KB stub)", len(dec.text) > 1200, - f"len={len(dec.text)}") + check("pseudocode has many lines", dec.total > 20, f"lines={dec.total}") + # Highlighting: at least one styled (colored) segment across the body. + styled = any( + seg.style is not None and seg.style.color is not None + for strip in dec._strips[: min(dec.total, 200)] + for seg in strip + ) + check("pseudocode is syntax-highlighted", styled) await pilot.press("shift+tab") await pilot.pause(0.2) check("shift+tab returns to disassembly", -- cgit v1.3.1-sl0p