Skip to content

Adding commands+shortcuts for keyboard nav of tabs in dock panel.#1647

Merged
blink1073 merged 5 commits into
jupyterlab:masterfrom
ellisonbg:dock-panel-shortcuts
Feb 9, 2017
Merged

Adding commands+shortcuts for keyboard nav of tabs in dock panel.#1647
blink1073 merged 5 commits into
jupyterlab:masterfrom
ellisonbg:dock-panel-shortcuts

Conversation

@ellisonbg

Copy link
Copy Markdown
Contributor

Fixes #1637

This works, but I have a few questions:

  • Have got the logic right for these methods on ApplicationShell?
  • What keyboard shortcuts to use (currently accel left+right)?
  • Right now the terminal swallows these keyboard shortcuts, how do I make the terminal ignore them.

@ellisonbg

Copy link
Copy Markdown
Contributor Author

@sccolbert for review

Another question: right now I don't do anything if a user tries to select the next tab and they are at the end of the active panel. Is there a reasonable way of iterating through the panels in the dock panel?

@ellisonbg

Copy link
Copy Markdown
Contributor Author

I think I see the logic for going between bars in the dockPanel.tabBars() to switch between panels. Another question though.

I have the TabBar instance that contains the active widget/tab. I want to find the next or previous TabBar from the dockPanel.tabBars() iterator. What is the best way of doing that with arrays or sequences in phosphor?

@blink1073

Copy link
Copy Markdown
Contributor

We usually call toArray if were are going to do any indexing on an iterator.
See phosphorjs/phosphor#185 for how we are going to handle capturing keydown events before input areas get them.

@ellisonbg ellisonbg force-pushed the dock-panel-shortcuts branch from 7ee4a1d to 69abd61 Compare February 9, 2017 17:22
@ellisonbg

Copy link
Copy Markdown
Contributor Author

Woohoo!! I have fun with this one. It is all working. This makes it really easy to navigate the entire dock panel using Accel ArrowLeft and Accel ArrowRight. It will cycle through tabs in each panel and also through panels, including periodic boundary conditions. Should be ready to go!

@blink1073

Copy link
Copy Markdown
Contributor

Squeaked it in for 0.16! I'll test/review this now.

Comment thread src/application/shell.ts Outdated
private _previousTabBar(): TabBar {
let current = this._currentTabBar();
if (current) {
let bars = toArray<TabBar>(this._dockPanel.tabBars());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the <TabBar> type is not needed. toArray will automatically infer the generic type based on the argument.

Comment thread src/application/shell.ts Outdated
private _nextTabBar(): TabBar {
let current = this._currentTabBar();
if (current) {
let bars = toArray<TabBar>(this._dockPanel.tabBars());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

Comment thread src/shortcuts/plugin.ts
},
{
command: ApplicationCommandIDs.activatePreviousTab,
selector: 'body',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do these shortcuts not conflict with anything else in the app?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not that I know of...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seconded.

@sccolbert

Copy link
Copy Markdown
Contributor

Made a few comments. Looks reasonable.

Comment thread src/application/shell.ts Outdated
if (current) {
let ci = current.currentIndex;
if (ci !== -1) {
if (ci < (current.titles.length-1)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

spaces around the binary operator

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While we're being nit-picky, you don't need the extra parens either. The - operator has a higher precedence than logical operators: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will remove the extra parens. Can you clarify what you mean about the spaces around the binary operator?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

current.titles.length-1 -> current.titles.length - 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nevermind, I understand...

Comment thread src/application/shell.ts Outdated
if (ci < (current.titles.length-1)) {
current.currentIndex += 1;
current.currentTitle.owner.activate();
} else if (ci === (current.titles.length-1)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

idem

Comment thread src/application/shell.ts Outdated
let prevBar = this._previousTabBar();
if (prevBar) {
let len = prevBar.titles.length;
prevBar.currentIndex = len-1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

idem

Comment thread src/application/shell.ts Outdated
let ci = bars.indexOf(current);
let prevBar: TabBar = null;
if (ci > 0) {
prevBar = bars[ci-1];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

idem (and two lines down)

Comment thread src/application/shell.ts Outdated
let len = bars.length;
let ci = bars.indexOf(current);
let nextBar: TabBar = null;
if (ci < (len-1)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

more idems

@blink1073

Copy link
Copy Markdown
Contributor

This is really elegant, well done!

@ellisonbg

Copy link
Copy Markdown
Contributor Author

K, should be good, thanks for the review!

@blink1073 blink1073 merged commit 750a5cc into jupyterlab:master Feb 9, 2017
@blink1073

Copy link
Copy Markdown
Contributor

🎉

@ellisonbg ellisonbg deleted the dock-panel-shortcuts branch June 14, 2017 04:13
@lock lock Bot added the status:resolved-locked Closed inactive issues are locked after a while. Please open a new issue for related discussion. label Aug 10, 2019
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement pkg:application status:resolved-locked Closed inactive issues are locked after a while. Please open a new issue for related discussion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Keyboard Shortcut to navigate to next tab / previous tab

3 participants