aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblasty <blasty@local>2026-07-23 22:12:29 +0200
committerblasty <blasty@local>2026-07-23 22:12:29 +0200
commit1e0c3ebc1179dcc64da1a77c4eeff12917dd66ae (patch)
treebae29c8f465a95791139c203a9d06e502d98011b
parentfix: follow/double-click a label lands on the label, not the function entry (diff)
downloadida-tui-1e0c3ebc1179dcc64da1a77c4eeff12917dd66ae.tar.gz
ida-tui-1e0c3ebc1179dcc64da1a77c4eeff12917dd66ae.tar.xz
ida-tui-1e0c3ebc1179dcc64da1a77c4eeff12917dd66ae.zip
listing: keep a few lines of context above a jump target
Jumping (goto/follow/xref/open) parked the target's first line on the very top row of the viewport, which is cramped. Now a fresh navigation scrolls so the target sits _JUMP_CONTEXT (4) lines down, leaving surrounding context above it; the cursor still lands on the target's first instruction. Only applies when the scroll is being derived (NavEntry.scroll_y == -1). Back/ forward restores carry their own saved scroll_y, so they still return to the exact previous viewport. Verified: jumps to sub_3720/sub_2060/main land the cursor on the entry with a 4-line margin above; scroll_restore/disasm_nav/follow_xrefs/mouse/search/ listing_view/continuous_view/func_banners 51/0.
-rw-r--r--idatui/app.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/idatui/app.py b/idatui/app.py
index abe50fb..bce8fe8 100644
--- a/idatui/app.py
+++ b/idatui/app.py
@@ -59,6 +59,7 @@ _S_FUNCHDR = Style(color="#d7a021", bold=True) # 'name proc'/'endp' headers
_LST_INDENT = " " # one depth level: function names sit at level 0, code at 1
_OP_LIMIT = 8 # opcode bytes shown in the 'limited' column mode
+_JUMP_CONTEXT = 4 # lines of context kept above a jump target (cursor stays on it)
# Tokens that look like identifiers but aren't renamable symbols (so 'n' on them
# in the listing names the address instead of trying to rename the token).
@@ -3685,6 +3686,11 @@ class IdaTui(App):
lm = self.program.listing(entry.ea)
sy = entry.scroll_y if entry.scroll_y >= 0 else None
if lm is not None:
+ if sy is None:
+ # Fresh jump (not a back/forward restore, which carries its own
+ # scroll): keep a few lines of context above the target instead
+ # of parking it on the very top row. Cursor stays on the target.
+ sy = max(entry.cursor - _JUMP_CONTEXT, 0)
self.query_one(ListingView).load(
lm, entry.name, cursor=entry.cursor,
cursor_x=entry.cursor_x, scroll_y=sy)