Go bindings for libghostty-vt. pkg.go.dev/go.mitchellh.com/libghostty

terminal: derive syncEffects and hasEffects from one table #32

Open robmorgan.id.au
targeting main
Open opened by and assigned to robmorgan.id.au
targeting main

syncEffects and hasEffects each listed all fifteen effect handlers by hand. If a future effect were added to syncEffects but forgotten in hasEffects, and it were the only handler registered, the trampoline would be installed with no userdata and the first callback would abort the process inside a C-invoked function rather than fail to compile.

I've replace both lists with effectBindings, a table of (option, active, set) entries that both functions iterate. A new test reflects over the Terminal struct and checks that every on* handler field corresponds to exactly one table entry, so leaving a field out of the table fails the suite. The per-effect C shims are unchanged; cgo cannot take the address of a static C function from Go, so each still needs one.

Why it matters. The failure mode of the old duplication wasn't a compile error. If a new effect went into syncEffects, but not hasEffects, and it was the only handler registered, the trampoline would be installed with null userdata and the first callback would abort the process from inside C. I'm hoping this approach makes that impossible.

This pull request has no versions submitted yet.