Skip to content

Use _get_multi for render state queries and add VT log callback#95

Merged
dakra merged 1 commit intomainfrom
get-multi-and-new-features
Apr 13, 2026
Merged

Use _get_multi for render state queries and add VT log callback#95
dakra merged 1 commit intomainfrom
get-multi-and-new-features

Conversation

@dakra
Copy link
Copy Markdown
Owner

@dakra dakra commented Apr 13, 2026

Summary

  • Batch default-color and cursor-style render state queries into ghostty_render_state_get_multi calls (2 keys each), taking advantage of the new batched query API in libghostty
  • Add a log callback that routes libghostty internal log messages through the *ghostel-debug* buffer when ghostel-debug-start is active, via ghostty_sys_set(GHOSTTY_SYS_OPT_LOG, callback)
  • Fix make build to pass -Doptimize=ReleaseFast -Dcpu=baseline so that make all produces a release binary

Notes

Cell-level and row-level _get_multi batching was explored but reverted:

  • FG_COLOR/BG_COLOR return NO_VALUE for default-colored cells, stopping the batch before STYLE is fetched
  • ROW_DATA_CELLS populates a pre-allocated handle rather than writing a new one, requiring &term.row_cells instead of a local variable
  • Benchmarks showed no measurable performance gain from batching (FFI overhead between statically-linked Zig functions is negligible)
  • The render-state-level batches (colors, cursor) are kept as clean groupings of always-succeeding queries

Test plan

  • make all passes (105 native tests, 30 evil tests, lint)
  • Manual test: ghostel-debug-start, verify VT log messages appear in *ghostel-debug*
  • Manual test: verify no performance regression with find or similar rapid-output commands

Batch the default-color and cursor-style render state queries into
ghostty_render_state_get_multi calls (2 keys each) to take advantage
of the new batched query API in libghostty.

Add a log callback that routes libghostty internal log messages
through the *ghostel-debug* buffer when ghostel-debug-start is
active.  The callback is installed via ghostty_sys_set and stashes
the Emacs env during fnWriteInput/fnRedraw so it can safely call
into Elisp.

Also fix `make build` to pass -Doptimize=ReleaseFast -Dcpu=baseline
so that plain `make all` produces a release binary instead of an
unoptimized debug build.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR batches select libghostty render-state queries via the new ghostty_render_state_get_multi API, adds a native-module-installed VT log callback that forwards libghostty internal logs into the *ghostel-debug* buffer, and updates build invocations to consistently produce a release binary.

Changes:

  • Batch render-state queries for default FG/BG colors and cursor visibility/style using ghostty_render_state_get_multi.
  • Add Emacs-native-module functions to enable/disable a libghostty log callback and route messages to ghostel--debug-log-vt.
  • Update make build (and align Elisp compilation invocation formatting) to pass -Doptimize=ReleaseFast -Dcpu=baseline.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/render.zig Switches default color and cursor style/visibility queries to batched render-state lookups.
src/module.zig Adds VT log callback plumbing and exposes ghostel--enable-vt-log / ghostel--disable-vt-log.
src/emacs.zig Adds cached symbol for ghostel--debug-log-vt used by the native callback.
Makefile Ensures make build produces a release-optimized baseline CPU build.
ghostel.el Keeps the Zig build invocation consistent (minor formatting).
ghostel-debug.el Starts/stops VT log routing when debug logging is enabled/disabled and adds ghostel--debug-log-vt.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/module.zig
Comment thread src/module.zig
Comment thread src/module.zig
Comment thread src/render.zig Outdated
@dakra dakra force-pushed the get-multi-and-new-features branch from fb7f331 to a3d043a Compare April 13, 2026 09:04
@dakra dakra merged commit a3d043a into main Apr 13, 2026
16 checks passed
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.

2 participants