mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
core: slide terminal keybinding action
This commit is contained in:
@ -49,6 +49,7 @@ class AppDelegate: NSObject,
|
||||
@IBOutlet private var menuIncreaseFontSize: NSMenuItem?
|
||||
@IBOutlet private var menuDecreaseFontSize: NSMenuItem?
|
||||
@IBOutlet private var menuResetFontSize: NSMenuItem?
|
||||
@IBOutlet private var menuSlideTerminal: NSMenuItem?
|
||||
@IBOutlet private var menuTerminalInspector: NSMenuItem?
|
||||
|
||||
@IBOutlet private var menuEqualizeSplits: NSMenuItem?
|
||||
@ -73,6 +74,9 @@ class AppDelegate: NSObject,
|
||||
/// Manages our terminal windows.
|
||||
let terminalManager: TerminalManager
|
||||
|
||||
/// Our slide terminal. This starts out uninitialized and only initializes if used.
|
||||
private var slideController: SlideTerminalController? = nil
|
||||
|
||||
/// Manages updates
|
||||
let updaterController: SPUStandardUpdaterController
|
||||
let updaterDelegate: UpdaterDelegate = UpdaterDelegate()
|
||||
@ -156,8 +160,6 @@ class AppDelegate: NSObject,
|
||||
center.delegate = self
|
||||
}
|
||||
|
||||
var foo: SlideTerminalController? = nil
|
||||
|
||||
func applicationDidBecomeActive(_ notification: Notification) {
|
||||
guard !applicationHasBecomeActive else { return }
|
||||
applicationHasBecomeActive = true
|
||||
@ -167,11 +169,8 @@ class AppDelegate: NSObject,
|
||||
// - if we're opening a URL since `application(_:openFile:)` is called before this.
|
||||
// - if we're restoring from persisted state
|
||||
if terminalManager.windows.count == 0 {
|
||||
//terminalManager.newWindow()
|
||||
terminalManager.newWindow()
|
||||
}
|
||||
|
||||
foo = SlideTerminalController(ghostty, baseConfig: nil)
|
||||
foo?.showWindow(self)
|
||||
}
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
@ -315,6 +314,7 @@ class AppDelegate: NSObject,
|
||||
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)
|
||||
syncMenuShortcut(action: "toggle_slide_terminal", menuItem: self.menuSlideTerminal)
|
||||
syncMenuShortcut(action: "inspector:toggle", menuItem: self.menuTerminalInspector)
|
||||
|
||||
syncMenuShortcut(action: "toggle_secure_input", menuItem: self.menuSecureInput)
|
||||
@ -550,4 +550,13 @@ class AppDelegate: NSObject,
|
||||
@IBAction func toggleSecureInput(_ sender: Any) {
|
||||
setSecureInput(.toggle)
|
||||
}
|
||||
|
||||
@IBAction func toggleSlideTerminal(_ sender: Any) {
|
||||
if slideController == nil {
|
||||
slideController = SlideTerminalController(ghostty, baseConfig: nil)
|
||||
}
|
||||
|
||||
guard let slideController = self.slideController else { return }
|
||||
slideController.slideToggle()
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
<outlet property="menuSelectSplitLeft" destination="cTK-oy-KuV" id="Jpr-5q-dqz"/>
|
||||
<outlet property="menuSelectSplitRight" destination="upj-mc-L7X" id="nLY-o1-lky"/>
|
||||
<outlet property="menuServices" destination="aQe-vS-j8Q" id="uWQ-Wo-T1L"/>
|
||||
<outlet property="menuSlideTerminal" destination="kvF-d2-JsP" id="cQU-Qt-r5k"/>
|
||||
<outlet property="menuSplitDown" destination="UDZ-4y-6xL" id="fgZ-Wb-8OR"/>
|
||||
<outlet property="menuSplitRight" destination="VUR-Ld-nLx" id="RxO-Zw-ovb"/>
|
||||
<outlet property="menuTerminalInspector" destination="QwP-M5-fvh" id="wJi-Dh-S9f"/>
|
||||
@ -216,6 +217,13 @@
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="L3L-I8-sqk"/>
|
||||
<menuItem title="Slide Terminal" id="kvF-d2-JsP">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleSlideTerminal:" target="bbz-4X-AYv" id="9h9-Ge-jgG"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="bC9-n9-RbJ"/>
|
||||
<menuItem title="Terminal Inspector" id="QwP-M5-fvh">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
|
@ -85,6 +85,15 @@ class SlideTerminalController: NSWindowController, NSWindowDelegate, TerminalVie
|
||||
|
||||
// MARK: Slide Methods
|
||||
|
||||
func slideToggle() {
|
||||
guard let window = self.window else { return }
|
||||
if (window.alphaValue > 0) {
|
||||
slideOut()
|
||||
} else {
|
||||
slideIn()
|
||||
}
|
||||
}
|
||||
|
||||
func slideIn() {
|
||||
guard let window = self.window else { return }
|
||||
slideWindowIn(window: window, from: position)
|
||||
|
@ -3856,6 +3856,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
||||
.toggle,
|
||||
),
|
||||
|
||||
.toggle_slide_terminal => {
|
||||
if (@hasDecl(apprt.Surface, "toggleSlideTerminal")) {
|
||||
self.rt_surface.toggleSlideTerminal();
|
||||
} else log.warn("runtime doesn't implement toggleSlideTerminal", .{});
|
||||
},
|
||||
|
||||
.select_all => {
|
||||
const sel = self.io.terminal.screen.selectAll();
|
||||
if (sel) |s| {
|
||||
|
@ -363,6 +363,17 @@ pub const Action = union(enum) {
|
||||
/// This only works on macOS, since this is a system API on macOS.
|
||||
toggle_secure_input: void,
|
||||
|
||||
/// Toggle the "slide" terminal. The slide terminal is a terminal that
|
||||
/// slides in from some screen edge, usually the top. This is useful for
|
||||
/// quick access to a terminal without having to open a new window or tab.
|
||||
///
|
||||
/// The slide terminal is a singleton; only one instance can exist at a
|
||||
/// time.
|
||||
///
|
||||
/// See the various configurations for the slide terminal in the
|
||||
/// configuration file to customize its behavior.
|
||||
toggle_slide_terminal: void,
|
||||
|
||||
/// Quit ghostty.
|
||||
quit: void,
|
||||
|
||||
@ -382,6 +393,10 @@ pub const Action = union(enum) {
|
||||
///
|
||||
crash: CrashThread,
|
||||
|
||||
pub const SlideTerminalPosition = enum {
|
||||
top,
|
||||
};
|
||||
|
||||
pub const CrashThread = enum {
|
||||
main,
|
||||
io,
|
||||
|
Reference in New Issue
Block a user