From 140ac9388492e3ab4be1826eb9f028b559b61a99 Mon Sep 17 00:00:00 2001
From: Bryan Lee <38807139+liby@users.noreply.github.com>
Date: Fri, 3 Jan 2025 09:15:29 +0800
Subject: [PATCH] Add `close_tab` keybinding action for macOS
Implement `close_tab` keybinding action to close the current tab and all splits within that tab.
---
macos/Sources/App/macOS/AppDelegate.swift | 2 +
macos/Sources/App/macOS/MainMenu.xib | 7 ++
.../Terminal/TerminalController.swift | 99 +++++++++++++------
macos/Sources/Ghostty/Ghostty.App.swift | 24 +++++
macos/Sources/Ghostty/Package.swift | 3 +
src/Surface.zig | 1 +
src/input/Binding.zig | 9 +-
7 files changed, 112 insertions(+), 33 deletions(-)
diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift
index 2fe835303..a102beb91 100644
--- a/macos/Sources/App/macOS/AppDelegate.swift
+++ b/macos/Sources/App/macOS/AppDelegate.swift
@@ -30,6 +30,7 @@ class AppDelegate: NSObject,
@IBOutlet private var menuSplitRight: NSMenuItem?
@IBOutlet private var menuSplitDown: NSMenuItem?
@IBOutlet private var menuClose: NSMenuItem?
+ @IBOutlet private var menuCloseTab: NSMenuItem?
@IBOutlet private var menuCloseWindow: NSMenuItem?
@IBOutlet private var menuCloseAllWindows: NSMenuItem?
@@ -347,6 +348,7 @@ class AppDelegate: NSObject,
syncMenuShortcut(config, action: "new_window", menuItem: self.menuNewWindow)
syncMenuShortcut(config, action: "new_tab", menuItem: self.menuNewTab)
syncMenuShortcut(config, action: "close_surface", menuItem: self.menuClose)
+ syncMenuShortcut(config, action: "close_tab", menuItem: self.menuCloseTab)
syncMenuShortcut(config, action: "close_window", menuItem: self.menuCloseWindow)
syncMenuShortcut(config, action: "close_all_windows", menuItem: self.menuCloseAllWindows)
syncMenuShortcut(config, action: "new_split:right", menuItem: self.menuSplitRight)
diff --git a/macos/Sources/App/macOS/MainMenu.xib b/macos/Sources/App/macOS/MainMenu.xib
index 0a197fe65..4a01d5c62 100644
--- a/macos/Sources/App/macOS/MainMenu.xib
+++ b/macos/Sources/App/macOS/MainMenu.xib
@@ -17,6 +17,7 @@
+
@@ -155,6 +156,12 @@
+