mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Merge pull request #694 from gpanders/view-menu
macos: add menu items to modify font size
This commit is contained in:
@ -32,7 +32,11 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp
|
|||||||
@IBOutlet private var menuSelectSplitBelow: NSMenuItem?
|
@IBOutlet private var menuSelectSplitBelow: NSMenuItem?
|
||||||
@IBOutlet private var menuSelectSplitLeft: NSMenuItem?
|
@IBOutlet private var menuSelectSplitLeft: NSMenuItem?
|
||||||
@IBOutlet private var menuSelectSplitRight: NSMenuItem?
|
@IBOutlet private var menuSelectSplitRight: NSMenuItem?
|
||||||
|
|
||||||
|
@IBOutlet private var menuIncreaseFontSize: NSMenuItem?
|
||||||
|
@IBOutlet private var menuDecreaseFontSize: NSMenuItem?
|
||||||
|
@IBOutlet private var menuResetFontSize: NSMenuItem?
|
||||||
|
|
||||||
/// The dock menu
|
/// The dock menu
|
||||||
private var dockMenu: NSMenu = NSMenu()
|
private var dockMenu: NSMenu = NSMenu()
|
||||||
|
|
||||||
@ -204,7 +208,11 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp
|
|||||||
syncMenuShortcut(action: "goto_split:bottom", menuItem: self.menuSelectSplitBelow)
|
syncMenuShortcut(action: "goto_split:bottom", menuItem: self.menuSelectSplitBelow)
|
||||||
syncMenuShortcut(action: "goto_split:left", menuItem: self.menuSelectSplitLeft)
|
syncMenuShortcut(action: "goto_split:left", menuItem: self.menuSelectSplitLeft)
|
||||||
syncMenuShortcut(action: "goto_split:right", menuItem: self.menuSelectSplitRight)
|
syncMenuShortcut(action: "goto_split:right", menuItem: self.menuSelectSplitRight)
|
||||||
|
|
||||||
|
syncMenuShortcut(action: "increase_font_size:1", menuItem: self.menuIncreaseFontSize)
|
||||||
|
syncMenuShortcut(action: "decrease_font_size:1", menuItem: self.menuDecreaseFontSize)
|
||||||
|
syncMenuShortcut(action: "reset_font_size", menuItem: self.menuResetFontSize)
|
||||||
|
|
||||||
// Dock menu
|
// Dock menu
|
||||||
reloadDockMenu()
|
reloadDockMenu()
|
||||||
}
|
}
|
||||||
@ -367,4 +375,19 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp
|
|||||||
guard let surface = focusedSurface() else { return }
|
guard let surface = focusedSurface() else { return }
|
||||||
ghostty.toggleFullscreen(surface: surface)
|
ghostty.toggleFullscreen(surface: surface)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func increaseFontSize(_ sender: Any) {
|
||||||
|
guard let surface = focusedSurface() else { return }
|
||||||
|
ghostty.changeFontSize(surface: surface, .increase(1))
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func decreaseFontSize(_ sender: Any) {
|
||||||
|
guard let surface = focusedSurface() else { return }
|
||||||
|
ghostty.changeFontSize(surface: surface, .decrease(1))
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func resetFontSize(_ sender: Any) {
|
||||||
|
guard let surface = focusedSurface() else { return }
|
||||||
|
ghostty.changeFontSize(surface: surface, .reset)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,12 @@ extension Ghostty {
|
|||||||
case loading, error, ready
|
case loading, error, ready
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum FontSizeModification {
|
||||||
|
case increase(Int)
|
||||||
|
case decrease(Int)
|
||||||
|
case reset
|
||||||
|
}
|
||||||
|
|
||||||
struct Info {
|
struct Info {
|
||||||
var mode: ghostty_build_mode_e
|
var mode: ghostty_build_mode_e
|
||||||
var version: String
|
var version: String
|
||||||
@ -269,6 +275,21 @@ extension Ghostty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func changeFontSize(surface: ghostty_surface_t, _ change: FontSizeModification) {
|
||||||
|
let action: String
|
||||||
|
switch change {
|
||||||
|
case .increase(let amount):
|
||||||
|
action = "increase_font_size:\(amount)"
|
||||||
|
case .decrease(let amount):
|
||||||
|
action = "decrease_font_size:\(amount)"
|
||||||
|
case .reset:
|
||||||
|
action = "reset_font_size"
|
||||||
|
}
|
||||||
|
if (!ghostty_surface_binding_action(surface, action, UInt(action.count))) {
|
||||||
|
AppDelegate.logger.warning("action failed action=\(action)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Called when the selected keyboard changes. We have to notify Ghostty so that
|
// Called when the selected keyboard changes. We have to notify Ghostty so that
|
||||||
// it can reload the keyboard mapping for input.
|
// it can reload the keyboard mapping for input.
|
||||||
@objc private func keyboardSelectionDidChange(notification: NSNotification) {
|
@objc private func keyboardSelectionDidChange(notification: NSNotification) {
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
<outlet property="menuClose" destination="DVo-aG-piG" id="R3t-0C-aSU"/>
|
<outlet property="menuClose" destination="DVo-aG-piG" id="R3t-0C-aSU"/>
|
||||||
<outlet property="menuCloseWindow" destination="W5w-UZ-crk" id="6ff-BT-ENV"/>
|
<outlet property="menuCloseWindow" destination="W5w-UZ-crk" id="6ff-BT-ENV"/>
|
||||||
<outlet property="menuCopy" destination="Jqf-pv-Zcu" id="bKd-1C-oy9"/>
|
<outlet property="menuCopy" destination="Jqf-pv-Zcu" id="bKd-1C-oy9"/>
|
||||||
|
<outlet property="menuDecreaseFontSize" destination="kzb-SZ-dOA" id="Y1B-Vh-6Z2"/>
|
||||||
|
<outlet property="menuIncreaseFontSize" destination="CIH-ey-Z6x" id="hkc-9C-80E"/>
|
||||||
<outlet property="menuNewTab" destination="uTG-Vz-hJU" id="eMg-R3-SeS"/>
|
<outlet property="menuNewTab" destination="uTG-Vz-hJU" id="eMg-R3-SeS"/>
|
||||||
<outlet property="menuNewWindow" destination="Was-JA-tGl" id="lK7-3I-CPG"/>
|
<outlet property="menuNewWindow" destination="Was-JA-tGl" id="lK7-3I-CPG"/>
|
||||||
<outlet property="menuNextSplit" destination="bD7-ei-wKU" id="LeT-xw-eh4"/>
|
<outlet property="menuNextSplit" destination="bD7-ei-wKU" id="LeT-xw-eh4"/>
|
||||||
@ -24,6 +26,7 @@
|
|||||||
<outlet property="menuPreviousSplit" destination="Lic-px-1wg" id="Rto-CG-yRe"/>
|
<outlet property="menuPreviousSplit" destination="Lic-px-1wg" id="Rto-CG-yRe"/>
|
||||||
<outlet property="menuQuit" destination="4sb-4s-VLi" id="qYN-S1-6UW"/>
|
<outlet property="menuQuit" destination="4sb-4s-VLi" id="qYN-S1-6UW"/>
|
||||||
<outlet property="menuReloadConfig" destination="KKH-XX-5py" id="Wvp-7J-wqX"/>
|
<outlet property="menuReloadConfig" destination="KKH-XX-5py" id="Wvp-7J-wqX"/>
|
||||||
|
<outlet property="menuResetFontSize" destination="Jah-MY-aLX" id="ger-qM-wrm"/>
|
||||||
<outlet property="menuSelectSplitAbove" destination="0yU-hC-8xF" id="aPc-lS-own"/>
|
<outlet property="menuSelectSplitAbove" destination="0yU-hC-8xF" id="aPc-lS-own"/>
|
||||||
<outlet property="menuSelectSplitBelow" destination="QDz-d9-CBr" id="FsH-Dq-jij"/>
|
<outlet property="menuSelectSplitBelow" destination="QDz-d9-CBr" id="FsH-Dq-jij"/>
|
||||||
<outlet property="menuSelectSplitLeft" destination="cTK-oy-KuV" id="Jpr-5q-dqz"/>
|
<outlet property="menuSelectSplitLeft" destination="cTK-oy-KuV" id="Jpr-5q-dqz"/>
|
||||||
@ -128,6 +131,31 @@
|
|||||||
</items>
|
</items>
|
||||||
</menu>
|
</menu>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
|
<menuItem title="View" id="3L3-2p-Joi" userLabel="View">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
<menu key="submenu" title="View" id="m6z-2H-VW7">
|
||||||
|
<items>
|
||||||
|
<menuItem title="Increase Font Size" id="CIH-ey-Z6x" userLabel="Increase Font Size">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="increaseFontSize:" target="bbz-4X-AYv" id="qbI-YJ-xuW"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
|
<menuItem title="Reset Font Size" id="Jah-MY-aLX">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="resetFontSize:" target="bbz-4X-AYv" id="2qT-E9-Qt1"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
|
<menuItem title="Decrease Font Size" id="kzb-SZ-dOA">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="decreaseFontSize:" target="bbz-4X-AYv" id="rlw-0o-kA2"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
|
</items>
|
||||||
|
</menu>
|
||||||
|
</menuItem>
|
||||||
<menuItem title="Edit" id="ZUG-Nx-Wkj">
|
<menuItem title="Edit" id="ZUG-Nx-Wkj">
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
<menu key="submenu" title="Edit" id="iU4-OB-ccf">
|
<menu key="submenu" title="Edit" id="iU4-OB-ccf">
|
||||||
|
Reference in New Issue
Block a user