mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: become aware of new split directions left and up
This commit is contained in:
@ -351,6 +351,8 @@ typedef struct {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
GHOSTTY_SPLIT_DIRECTION_RIGHT,
|
GHOSTTY_SPLIT_DIRECTION_RIGHT,
|
||||||
GHOSTTY_SPLIT_DIRECTION_DOWN,
|
GHOSTTY_SPLIT_DIRECTION_DOWN,
|
||||||
|
GHOSTTY_SPLIT_DIRECTION_LEFT,
|
||||||
|
GHOSTTY_SPLIT_DIRECTION_UP,
|
||||||
} ghostty_action_split_direction_e;
|
} ghostty_action_split_direction_e;
|
||||||
|
|
||||||
// apprt.action.GotoSplit
|
// apprt.action.GotoSplit
|
||||||
|
@ -253,6 +253,15 @@ extension Ghostty {
|
|||||||
bottomRight.parent = self
|
bottomRight.parent = self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move the top left node to the bottom right and vice versa,
|
||||||
|
// preserving the size.
|
||||||
|
func swap() {
|
||||||
|
let topLeft: SplitNode = self.topLeft
|
||||||
|
self.topLeft = bottomRight
|
||||||
|
self.bottomRight = topLeft
|
||||||
|
self.split = 1 - self.split
|
||||||
|
}
|
||||||
|
|
||||||
/// Resize the split by moving the split divider in the given
|
/// Resize the split by moving the split divider in the given
|
||||||
/// direction by the given amount. If this container is not split
|
/// direction by the given amount. If this container is not split
|
||||||
/// in the given direction, navigate up the tree until we find a
|
/// in the given direction, navigate up the tree until we find a
|
||||||
|
@ -220,13 +220,21 @@ extension Ghostty {
|
|||||||
// Determine our desired direction
|
// Determine our desired direction
|
||||||
guard let directionAny = notification.userInfo?["direction"] else { return }
|
guard let directionAny = notification.userInfo?["direction"] else { return }
|
||||||
guard let direction = directionAny as? ghostty_action_split_direction_e else { return }
|
guard let direction = directionAny as? ghostty_action_split_direction_e else { return }
|
||||||
var splitDirection: SplitViewDirection
|
let splitDirection: SplitViewDirection
|
||||||
|
let swap: Bool
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case GHOSTTY_SPLIT_DIRECTION_RIGHT:
|
case GHOSTTY_SPLIT_DIRECTION_RIGHT:
|
||||||
splitDirection = .horizontal
|
splitDirection = .horizontal
|
||||||
|
swap = false
|
||||||
|
case GHOSTTY_SPLIT_DIRECTION_LEFT:
|
||||||
|
splitDirection = .horizontal
|
||||||
|
swap = true
|
||||||
case GHOSTTY_SPLIT_DIRECTION_DOWN:
|
case GHOSTTY_SPLIT_DIRECTION_DOWN:
|
||||||
splitDirection = .vertical
|
splitDirection = .vertical
|
||||||
|
swap = false
|
||||||
|
case GHOSTTY_SPLIT_DIRECTION_UP:
|
||||||
|
splitDirection = .vertical
|
||||||
|
swap = true
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
@ -240,6 +248,12 @@ extension Ghostty {
|
|||||||
|
|
||||||
// See moveFocus comment, we have to run this whenever split changes.
|
// See moveFocus comment, we have to run this whenever split changes.
|
||||||
Ghostty.moveFocus(to: container.bottomRight.preferredFocus(), from: node!.preferredFocus())
|
Ghostty.moveFocus(to: container.bottomRight.preferredFocus(), from: node!.preferredFocus())
|
||||||
|
|
||||||
|
// If we are swapping, swap now. We do this after our focus event
|
||||||
|
// so that focus is in the right place.
|
||||||
|
if swap {
|
||||||
|
container.swap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This handles the event to move the split focus (i.e. previous/next) from a keyboard event.
|
/// This handles the event to move the split focus (i.e. previous/next) from a keyboard event.
|
||||||
|
Reference in New Issue
Block a user