mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: menu bar to split
This commit is contained in:
@ -253,6 +253,7 @@ void ghostty_surface_mouse_pos(ghostty_surface_t, double, double);
|
|||||||
void ghostty_surface_mouse_scroll(ghostty_surface_t, double, double);
|
void ghostty_surface_mouse_scroll(ghostty_surface_t, double, double);
|
||||||
void ghostty_surface_ime_point(ghostty_surface_t, double *, double *);
|
void ghostty_surface_ime_point(ghostty_surface_t, double *, double *);
|
||||||
void ghostty_surface_request_close(ghostty_surface_t);
|
void ghostty_surface_request_close(ghostty_surface_t);
|
||||||
|
void ghostty_surface_split(ghostty_surface_t, ghostty_split_direction_e);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,10 @@ extension Ghostty {
|
|||||||
ghostty_surface_request_close(surface)
|
ghostty_surface_request_close(surface)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func split(surface: ghostty_surface_t, direction: ghostty_split_direction_e) {
|
||||||
|
ghostty_surface_split(surface, direction)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Ghostty Callbacks
|
// MARK: Ghostty Callbacks
|
||||||
|
|
||||||
static func newSplit(_ userdata: UnsafeMutableRawPointer?, direction: ghostty_split_direction_e) {
|
static func newSplit(_ userdata: UnsafeMutableRawPointer?, direction: ghostty_split_direction_e) {
|
||||||
|
@ -31,6 +31,9 @@ struct GhosttyApp: App {
|
|||||||
CommandGroup(after: .newItem) {
|
CommandGroup(after: .newItem) {
|
||||||
Button("New Tab", action: Self.newTab).keyboardShortcut("t", modifiers: [.command])
|
Button("New Tab", action: Self.newTab).keyboardShortcut("t", modifiers: [.command])
|
||||||
Divider()
|
Divider()
|
||||||
|
Button("Split Horizontally", action: splitHorizontally).keyboardShortcut("d", modifiers: [.command])
|
||||||
|
Button("Split Vertically", action: splitVertically).keyboardShortcut("d", modifiers: [.command, .shift])
|
||||||
|
Divider()
|
||||||
Button("Close", action: close).keyboardShortcut("w", modifiers: [.command])
|
Button("Close", action: close).keyboardShortcut("w", modifiers: [.command])
|
||||||
Button("Close Window", action: Self.closeWindow).keyboardShortcut("w", modifiers: [.command, .shift])
|
Button("Close Window", action: Self.closeWindow).keyboardShortcut("w", modifiers: [.command, .shift])
|
||||||
}
|
}
|
||||||
@ -61,6 +64,18 @@ struct GhosttyApp: App {
|
|||||||
guard let surface = surfaceView.surface else { return }
|
guard let surface = surfaceView.surface else { return }
|
||||||
ghostty.requestClose(surface: surface)
|
ghostty.requestClose(surface: surface)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func splitHorizontally() {
|
||||||
|
guard let surfaceView = focusedSurface else { return }
|
||||||
|
guard let surface = surfaceView.surface else { return }
|
||||||
|
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_RIGHT)
|
||||||
|
}
|
||||||
|
|
||||||
|
func splitVertically() {
|
||||||
|
guard let surfaceView = focusedSurface else { return }
|
||||||
|
guard let surface = surfaceView.surface else { return }
|
||||||
|
ghostty.split(surface: surface, direction: GHOSTTY_SPLIT_DOWN)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
@ -476,4 +476,9 @@ pub const CAPI = struct {
|
|||||||
export fn ghostty_surface_request_close(ptr: *Surface) void {
|
export fn ghostty_surface_request_close(ptr: *Surface) void {
|
||||||
ptr.closeSurface() catch {};
|
ptr.closeSurface() catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Request that the surface split in the given direction.
|
||||||
|
export fn ghostty_surface_split(ptr: *Surface, direction: input.SplitDirection) void {
|
||||||
|
ptr.newSplit(direction) catch {};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user