libghostty: unified action dispatch

First, this commit modifies libghostty to use a single unified action
dispatch system based on a tagged union versus the one-off callback
system that was previously in place. This change simplifies the code on
both the core and consumer sides of the library. Importantly, as we
introduce new actions, we can now maintain ABI compatibility so long as
our union size does not change (something I don't promise yet).

Second, this moves a lot more of the functions call on a surface into
the action system. This affects all apprts and continues the previous
work of introducing a more unified API for optional surface features.
This commit is contained in:
Mitchell Hashimoto
2024-09-26 16:18:11 -07:00
parent 84e0a05027
commit 4ae20212bf
17 changed files with 1451 additions and 948 deletions

View File

@@ -219,13 +219,13 @@ extension Ghostty {
// Determine our desired direction
guard let directionAny = notification.userInfo?["direction"] else { return }
guard let direction = directionAny as? ghostty_split_direction_e else { return }
guard let direction = directionAny as? ghostty_action_split_direction_e else { return }
var splitDirection: SplitViewDirection
switch (direction) {
case GHOSTTY_SPLIT_RIGHT:
case GHOSTTY_SPLIT_DIRECTION_RIGHT:
splitDirection = .horizontal
case GHOSTTY_SPLIT_DOWN:
case GHOSTTY_SPLIT_DIRECTION_DOWN:
splitDirection = .vertical
default: