vt: use struct literal for handler effects assignment

Assign handler.effects as a struct literal instead of setting fields
individually. This lets the compiler catch missing fields if new
effects are added to the Effects struct.

Also sort the callback function typedefs in vt/terminal.h
alphabetically (Bell, ColorScheme, DeviceAttributes, Enquiry, Size,
TitleChanged, WritePty, Xtversion).
This commit is contained in:
Mitchell Hashimoto
2026-03-24 11:35:20 -07:00
parent b8fcb57923
commit bbfe1c2787
2 changed files with 79 additions and 77 deletions

View File

@@ -253,14 +253,16 @@ fn new_(
// Setup our stream with trampolines always installed so that
// setting C callbacks at any time takes effect immediately.
var handler: Stream.Handler = t.vtHandler();
handler.effects.write_pty = &Effects.writePtyTrampoline;
handler.effects.bell = &Effects.bellTrampoline;
handler.effects.color_scheme = &Effects.colorSchemeTrampoline;
handler.effects.device_attributes = &Effects.deviceAttributesTrampoline;
handler.effects.enquiry = &Effects.enquiryTrampoline;
handler.effects.xtversion = &Effects.xtversionTrampoline;
handler.effects.title_changed = &Effects.titleChangedTrampoline;
handler.effects.size = &Effects.sizeTrampoline;
handler.effects = .{
.write_pty = &Effects.writePtyTrampoline,
.bell = &Effects.bellTrampoline,
.color_scheme = &Effects.colorSchemeTrampoline,
.device_attributes = &Effects.deviceAttributesTrampoline,
.enquiry = &Effects.enquiryTrampoline,
.xtversion = &Effects.xtversionTrampoline,
.title_changed = &Effects.titleChangedTrampoline,
.size = &Effects.sizeTrampoline,
};
wrapper.* = .{
.terminal = t,