Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pane jumping with ^+⌘+1-9 shortcut. #1359

Closed
wants to merge 6 commits into from

Conversation

chabou
Copy link
Collaborator

@chabou chabou commented Jan 8, 2017

This PR implements #1295

I've chosen to use ^+⌘+1-9 to jump to a pane because ``⌘+1-9` is used to jump to a tab.
Shortcut appears on top left of each term (in margin) from 2 panes in tab.

capture d ecran 2017-01-08 a 16 05 15

Possible improvements:

  • Make shortcut appears only when ^+⌘ keys are down
  • Choose an another shortcut?

@chabou chabou changed the title Pane jumping with ^+⌘+1-9 shortcut. Fix #1295 Pane jumping with ^+⌘+1-9 shortcut. Jan 8, 2017
findChildSessions(termGroups, childUid)
), []);
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Move to lib/utils/term-groups.jsbecause now used in lib/selectors.js too

getTermGroups,
termGroups => getRootGroups_(termGroups).reduce((result, {uid}) =>
Object.assign(result, {[uid]: findChildSessions(termGroups, uid)}), {})
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

digit shortcut for each term are not in the store because it is possible to derive them from the global state. It computes children list for each rootGroup (Tab)

@@ -84,6 +84,7 @@ export default class Terms extends Component {
const props = getTermGroupProps(uid, this.props, {
termGroup,
terms: this.terms,
sortedSessionGroups: this.props.sortedSessionGroups[uid],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extract sorted children which concern this tab

const state = getState();
const rootGroupUid = state.termGroups.activeRootGroup;
const sortedSessionGroups = findChildSessions(state.termGroups.termGroups, rootGroupUid);
const uid = i > sortedSessionGroups.length ? null : (i === 9 ? sortedSessionGroups[sortedSessionGroups.length - 1] : sortedSessionGroups[i - 1]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Find right pane for digit shortcut pressed

@chabou
Copy link
Collaborator Author

chabou commented Jan 12, 2017

Is it better to tranform this PR to a plugin ?

@matheuss
Copy link
Member

@chabou I think it might be better to make it a plugin 🤔 We're trying to If something can be done as a plugin, it should be a plugin instead of a core Hyper feature. Will confirm with @rauchg and get back to you ASAP 🙌

@rauchg
Copy link
Member

rauchg commented Jan 14, 2017

What I'd like to have is a very simple way for plugins to configure new keymappings. This would be trivial to write, in that case. So, when we merge the keymap feature we need to keep in mind that it should be easy for @chabou to extend that config from his plugin to accomplish this.

Thoughts?

@ppot
Copy link
Contributor

ppot commented Jan 17, 2017

@chabou Can you point me to the pane numbering order?

@chabou
Copy link
Collaborator Author

chabou commented Jan 17, 2017

@ppot I made a selector: https://github.com/chabou/hyper/blob/pane_jumping/lib/selectors.js#L16-L20
It use existing findChildSession() function (moved in utils/term-groups.js: https://github.com/chabou/hyper/blob/pane_jumping/lib/utils/term-groups.js#L8-L21) used for next/previous pane calculation. It was the same order than iTerm2: "first child descendent".
I needed to add a special meaning of 9 number which is "the last":
here https://github.com/chabou/hyper/blob/pane_jumping/lib/components/term-group.js#L52
and here https://github.com/chabou/hyper/blob/pane_jumping/lib/actions/ui.js#L209

I don't know yet if your work about Session Restoring (and state refactoring) will impact this.

@ppot
Copy link
Contributor

ppot commented Jan 18, 2017

@chabou I was saying the docs about the order of the pane.
Ou tu preferes en francais?

@chabou
Copy link
Collaborator Author

chabou commented Feb 8, 2017

Made with a plugin : https://github.com/chabou/hyper-pane
Feedback warmly welcome

@chabou chabou closed this Feb 8, 2017
@ppot
Copy link
Contributor

ppot commented Feb 8, 2017

@chabou I will supply pane numing. So you will be able to navigate with pane number!

@chabou
Copy link
Collaborator Author

chabou commented Feb 8, 2017

I will adapt my plugin to use your work ;)

@chabou
Copy link
Collaborator Author

chabou commented Feb 8, 2017

@rauchg my plugin use mousetrap for keybindings inspired by https://github.com/iamstarkov/hyper-panes-iterm2-hotkeys. I think it is a better way to achieve this than hacking hterm like this plugin: https://github.com/gyandeeps/hypernpm

It would be really great if, in next keymap feature, handlers registered by a plugin for a key combination will receive dispatch() function directly.

@chabou chabou deleted the pane_jumping branch March 7, 2017 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants