Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Add commands to move directionally between panes #1484

Merged
merged 10 commits into from
Feb 5, 2014

Conversation

jasonrudolph
Copy link
Contributor

I originally implemented this as a package in https://github.com/atom/house-of-pane/pull/1, but following @nathansobo's suggestion, I'm opening this PR as an attempt to bake that package's functionality directly into atom/atom.


Currently, Atom lets you switch focus to the next or previous pane.

default-commands

When I find myself making the most of split panes (especially on a large display), I often want to be able to quickly move directionally to another pane. I want to tell Atom to move ⬆️, or ⬇️, or ⬅️, or ➡️.

new-commands

Kinda like this:

house-of-pane-demo

This PR is an attempt to provide those commands. As always, I'd appreciate any and all feedback!

- Add keymaps for the new commands. Since the new commands are all about
  moving in a specific direction between panes, use the up, down, left,
  and right keys in the keymaps.
- Change the keymaps for the existing commands (since the new commands
  for moving left and right are now using the old keymaps for moving
  to the previous and next pane respectively). Use "p" instead of "left"
  in the keymap for focusing the *p*revious pane. Use "n" instead of
  "right" in the keymap for focusing the *n*ext pane.
[pane1, pane2, pane3, pane4, pane5, pane6, pane7, pane8, pane9] = []

beforeEach ->
# Set up a grid of 9 panes, in the following arrangement, where the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this comment block! I'll probably copy this idea somewhere in the future.

distance: (pointA, pointB) ->
x = pointB.x - pointA.x
y = pointB.y - pointA.y
Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved to the Point class in Text Buffer.

@probablycorey
Copy link

I tried to shrink the "nearest pane in a certain direction" code a bit. I think it is still understandable, although maybe I should break up nearestPaneInDirection into more functions.

@jasonrudolph
Copy link
Contributor Author

@nathansobo: Thanks for the feedback!

@probablycorey: Thanks for the improvements!

I'm happy to do the work to incorporate all the feedback and get this across the finish line. I can't promise any particular timeline for getting it done, since I'm still just hacking on this stuff occasionally when I have a free evening. So, if you have time to make the desired improvements before I get to it, that's totally cool. Otherwise, I'll chip away at this as time allows.

# Public: Focuses the pane directly to the right of the currently-focused
# pane.
focusPaneOnRight: -> @panes.focusPaneOnRight()

# Public:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments mention the currently-focused pane, but it should say active pane.

@probablycorey
Copy link

@jasonrudolph I'm pretty happy with it now, it is so handy! I can take this over and merge it in after I make a few small changes.

@probablycorey
Copy link

I was thinking about moving this to a package because we already have window:focus-previous-pane and window:focus-next-pane. But it is so helpful I think we should keep it in core and remove window:focus-previous-pane and window:focus-next-pane. They seem less helpful and don't add much functionality.

The only reason for keeping window:focus-next-pane around is that it will cycle through all panes and wrap around to the beginning again. Is this functionality that people use? If so would they prefer a command like window:focus-previously-active-pane.

@nathansobo
Copy link
Contributor

Please don't removed the cycling behavior. I use it pretty heavily in a 2-pane configuration where directionality isn't relevant.

@probablycorey
Copy link

But in the two pane case, isn't it actually "focus-previous-tab"

On Sunday, February 2, 2014, Nathan Sobo notifications@github.com wrote:

Please don't removed the cycling behavior. I use it pretty heavily in a
2-pane configuration where directionality isn't relevant.

Reply to this email directly or view it on GitHubhttps://github.com//pull/1484#issuecomment-33899707
.

@nathansobo
Copy link
Contributor

I bind ctrl-w w to focus next pane and just use that.

probablycorey pushed a commit that referenced this pull request Feb 5, 2014
Add commands to move directionally between panes
@probablycorey probablycorey merged commit e769a8e into master Feb 5, 2014
@probablycorey probablycorey deleted the directional-pane-navigation branch February 6, 2014 18:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants