Skip to content

Kaitai IDE: live .ksy compilation, editor pane, and hex<->tree sync - #12

Draft
xusheng6 wants to merge 3 commits into
masterfrom
kaitai-ide-live-compile
Draft

xusheng6 wants to merge 3 commits into
masterfrom
kaitai-ide-live-compile

Conversation

@xusheng6

Copy link
Copy Markdown
Member

Turns the Kaitai view into a small IDE for .ksy formats.

  • Live compilation — a .ksy editor pane compiles the source and reparses the current file in place, so format development is iterative instead of round-tripping through disk and a plugin reload.
  • Load / Save — the editor binds to a .ksy path; Save writes back to it, Load pulls a format in from disk.
  • Editor lock — the editor is read-only by default and toggled explicitly, so a built-in format isn't edited by accident.
  • Active-format indicators — shows which format is driving the tree (built-in, file, or editor) and whether the editor text matches what was last compiled.
  • Hex <-> tree sync — selecting in the hex editor highlights the covering tree node and vice versa, with corrected selection offsets and tree value/offset display.
  • construct_view now reports success, so a format that compiles but parses nothing is surfaced instead of silently leaving the previous tree in place.

🤖 Generated with Claude Code

xusheng6 and others added 3 commits June 25, 2026 22:20
- onTreeSelect passed (start, end - start) to setSelectionOffsets, which
  expects absolute (start, end); selecting a field highlighted the wrong
  bytes. Pass (start, end) to match navigate().
- Render empty value/offset cells as blank instead of the literal 'None'.
- Show offsets as compact 0x-prefixed hex instead of zero-padded 8 digits,
  and sort the start/end columns numerically (KaitaiTreeWidgetItem) so
  dropping the padding doesn't break ordering.
- Guard onTreeSelect against blank offset cells (ValueError on int()).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a Kaitai-IDE-style workflow: edit a .ksy in a new editor pane, compile
it on the fly, and reparse the current file with the result.

kshelpers:
- compile_ksy(): write source to a temp dir and invoke kaitai-struct-compiler
  with --debug (needed for the start/end offsets the tree-builder relies on).
- find_compiler()/login_shell_path(): resolve the compiler via the login
  shell's PATH, since GUI apps don't inherit it.
- load_ksy_class(): (re)load a freshly compiled module so edits take effect.
- parse_io_view_with_class(): parse with an explicit class, bypassing magic
  inference.

view:
- third splitter pane with a .ksy editor, Compile & Parse button, status line.
- construct_view() accepts a ks_class and records (start, end, item) intervals.
- hex->tree sync: clicking a byte selects the smallest containing field via
  navigate()/setCurrentOffset(), with a _syncing guard against feedback loops.

test/: a small demo format, generator, and sample binary for exercising the
live-compile path end to end.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The editor pane now tracks which format is driving the tree (built-in,
file, or editor) and whether the editor text matches what was last
compiled. Adds Load/Save buttons bound to a .ksy path, a lock toggle
that keeps the editor read-only by default, and makes construct_view
report success so a compile that parses nothing is surfaced instead of
silently leaving the old tree.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@xusheng6
xusheng6 marked this pull request as draft July 28, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant