macos: add menu items to modify font size

Add a new "View" menu to the menu bar with items to increase, decrease,
or reset the font size.
This commit is contained in:
Gregory Anders
2023-10-16 20:17:29 -05:00
parent 56721d9cac
commit f966a5a163
3 changed files with 73 additions and 2 deletions

View File

@@ -11,6 +11,12 @@ extension Ghostty {
case loading, error, ready
}
enum FontSizeModification {
case increase(Int)
case decrease(Int)
case reset
}
struct Info {
var mode: ghostty_build_mode_e
var version: String
@@ -269,6 +275,20 @@ extension Ghostty {
}
}
func changeFontSize(surface: ghostty_surface_t, _ change: FontSizeModification) {
let action = switch change {
case .increase(let amount):
"increase_font_size:\(amount)"
case .decrease(let amount):
"decrease_font_size:\(amount)"
case .reset:
"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
// it can reload the keyboard mapping for input.
@objc private func keyboardSelectionDidChange(notification: NSNotification) {