mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-06 11:54:19 +00:00
reintroduce App.create
This commit is contained in:
17
src/App.zig
17
src/App.zig
@@ -76,6 +76,15 @@ first: bool = true,
|
||||
|
||||
pub const CreateError = Allocator.Error || font.SharedGridSet.InitError;
|
||||
|
||||
/// Create a new app instance. This returns a stable pointer to the app
|
||||
/// instance which is required for callbacks.
|
||||
pub fn create(alloc: Allocator) CreateError!*App {
|
||||
var app = try alloc.create(App);
|
||||
errdefer alloc.destroy(app);
|
||||
try app.init(alloc);
|
||||
return app;
|
||||
}
|
||||
|
||||
/// Initialize the main app instance. This creates the main window, sets
|
||||
/// up the renderer state, compiles the shaders, etc. This is the primary
|
||||
/// "startup" logic.
|
||||
@@ -111,6 +120,14 @@ pub fn deinit(self: *App) void {
|
||||
self.font_grid_set.deinit();
|
||||
}
|
||||
|
||||
pub fn destroy(self: *App) void {
|
||||
// Deinitialize the app
|
||||
self.deinit();
|
||||
|
||||
// Free the app memory
|
||||
self.alloc.destroy(self);
|
||||
}
|
||||
|
||||
/// Tick ticks the app loop. This will drain our mailbox and process those
|
||||
/// events. This should be called by the application runtime on every loop
|
||||
/// tick.
|
||||
|
||||
Reference in New Issue
Block a user