From c5499b4e69c969e1c8dcc0f98f7df023c8b8407f Mon Sep 17 00:00:00 2001 From: blasty Date: Thu, 9 Jul 2026 20:56:08 +0200 Subject: comments: ';' sets a comment on the current line (disasm + pseudocode) Bind ';' (NavMixin, so both code views) to a comment prompt for the line under the cursor. Resolve the line's address (_cursor_ea in disasm, the /*0xEA*/ marker in pseudocode), prefill any existing comment (parsed from the rendered '//' text), and apply via the set_comments tool; an empty value clears it. After setting, reuse the name-generation invalidation (bump_names) so Hex-Rays is force_recompiled lazily and the pseudocode/disasm refresh in place at the saved position -- the new '// comment' shows on the line. Marks the IDB dirty (Ctrl+S). Pilot checks for the pseudocode round-trip. full suite 63/63. --- idatui/domain.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'idatui/domain.py') diff --git a/idatui/domain.py b/idatui/domain.py index 55a95d5..4902a64 100644 --- a/idatui/domain.py +++ b/idatui/domain.py @@ -508,6 +508,13 @@ class Program: raise KeyError(f"cannot resolve {target!r}") return _as_int(fn["addr"]) + # -- comments ---------------------------------------------------------- # + def set_comment(self, ea: int, text: str): + """Set (empty text clears) the comment at ``ea``; affects both the disasm + and decompiler views. Returns the raw payload so the caller can surface a + soft per-item error. The caller must invalidate/recompile to see it.""" + return self.client.call("set_comments", items=[{"addr": hex(ea), "comment": text}]) + # -- invalidation (after edits) --------------------------------------- # def invalidate(self, ea: int) -> None: """Drop caches for a function after a rename/comment/patch/etc.""" -- cgit v1.3.1-sl0p