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

update quickhelp on adding and removing shortcuts #5049

Merged
merged 18 commits into from Mar 20, 2014

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented Feb 6, 2014

I've been knee deep in making shortcuts work for vim mode etc, and have more PRs coming to start some discussion about that, but this one seems like a separate small change worth having.

Right now, we have an API for adding and removing shortcuts, but no visual indication in the UI of which shortcuts are actually active (the quick help you see in the notebook is built only once, and reused there-after).

With this change, we just rebuild the quickhelp dialog on keyboard shortcut changes

@ellisonbg
Copy link
Member

We will have to think further about how to work this. The ShortcutManager is a very low level bit of code that needs to not depend directly on Notebook/Cell/QuickHelp, etc. The usual way we handle this is by firing an event that the QuickHelp could watch for in ShortcutManager. Can you give that a try?

@ellisonbg
Copy link
Member

Any plans to address this before 2.0?

@ivanov
Copy link
Member Author

ivanov commented Mar 9, 2014

Ok, I've changed this to use an event, as @ellisonbg suggested. The rebuild.QuickHelp event sets the dirty bit on IPython.quick_help, and if that is set on show, the modal dialog gets rebuilt again.

Ready for review.

@ivanov ivanov added this to the 2.0 milestone Mar 9, 2014
@ivanov
Copy link
Member Author

ivanov commented Mar 10, 2014

Ok, I've prettified the keyboard shotrcuts here, and made them consistent with how we refer to keyboard shorcuts in our docs. For example: Ctrl-m not Ctrl+m. I'm only +0.5 to +0.25 on using dashes to combine shortcuts, it's visually quieter and a little easier to parse the constituents of combo shortcuts. On the other hand, one of our shortcuts contains an -. I just want to make sure we're consistent everywhere.

Here's are screenshots of what the two options look like:
2014-03-10-113245_560x171_scrot
2014-03-10-113213_558x161_scrot

We could also combo constituents if that makes better sense.

@ivanov
Copy link
Member Author

ivanov commented Mar 10, 2014

I realized as soon as I posted this that the enter in press enter to enable needs to be changed, so let me do that as well.

@takluyver
Copy link
Member

I prefer the -, I think.

@ivanov
Copy link
Member Author

ivanov commented Mar 11, 2014

Ok, I've made the code more DRY, so the keyboard shortcut style is made in just one place (instead of four). Is this too loud? 2014-03-11-004900_561x162_scrot

@damianavila
Copy link
Member

Is this too loud?

I don't think so...

@takluyver
Copy link
Member

The red does look a bit too loud to me.

@ellisonbg
Copy link
Member

I agree that the red is a bit too much. Also, we use + for shortcuts
rather than -.

On Tue, Mar 11, 2014 at 10:24 AM, Thomas Kluyver
notifications@github.comwrote:

The red does look a bit too loud to me.

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

Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com

@takluyver
Copy link
Member

@ellisonbg the change to - is part of the change under consideration. Is there a good reason to stick with +? Personally, I think - looks nicer.

@ellisonbg
Copy link
Member

Originally I picked + because I thought it made more sense when there are multiple modifiers. I mostly want consistency, so if there is consensus that Shift-Ctrl-m looks better let's use that everywhere (in the actual shortcuts and in the user visible docs). I still probably prefer + but only weakly (60/40).

@jdfreder
Copy link
Member

Ok, I've made the code more DRY, so the keyboard shortcut style is made in just one place (instead of four). Is this too loud?

I really like the grey box and thin borders around it. It reminds me of GitHub's back-tick inline highlighting. Probably unrelated, but I wish back-ticks in NB markdown styled similarly (I have code in my custom CSS to do that, but I think it would be a good default).

@damianavila
Copy link
Member

I still probably prefer + but only weakly (60/40).

I agree with @ellisonbg here... the + sign has the add meaning on it, and, in fact, you are adding keys when you press them simultaneously... anyway, not a big problem, let's do whatever the consensus says...

@minrk
Copy link
Member

minrk commented Mar 11, 2014

- seems a bit more legible and a bit more common to me. I don't think anybody is confused by what is communicated there.

Of course, my preference would be to use ^⇧⌥⌘ ⏎ symbols with no delimiter, but I think that's not the way we are going.

@ellisonbg
Copy link
Member

  • The style of the keyboard shortcuts in the help dialog and tour should be more subtle. Probably just monospaced text with a border - standard color (not red). Red means warning or error.
  • The Keyboard shortcuts in the tour are now lowercase (enter/esc).

@ellisonbg
Copy link
Member

Do we want to allow - as a separator in actual keyboard shortcuts (sc.replace('-','+'))?

@@ -18,6 +18,10 @@ var IPython = (function (IPython) {
QuickHelp.prototype.show_keyboard_shortcuts = function () {
// toggles display of keyboard shortcut dialog
var that = this;
if ( this.force_rebuild ) {
delete(this.shortcut_dialog);
Copy link
Member

Choose a reason for hiding this comment

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

you verify that this is sufficient to actually delete the DOM element from the page as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm actually not versed enough on front-end stuff to be able to say anything definitive about that. What would be a way to verify this? Is there some DOM view I don't know about?

Copy link
Member

Choose a reason for hiding this comment

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

The thing to do is look at the DOM in the developer tools to make sure there aren't two quick help DOM elements after a rebuild. If there is, you will probably have to add a call to jQuery's remove method to clean up the dialog. But I think our dialog logic may already handle this.

@ellisonbg
Copy link
Member

The User Interface notebook will also have to be updated - it uses the same code to build a list of shortcuts in the output of a cell. Let't wait to do that until #5337 is merged though.

@jdfreder
Copy link
Member

Do we want to allow - as a separator in actual keyboard shortcuts

That would be really awkward with the alt+- combo (alt--). I guess we could have to add an alias for - - minus.

(I didn't mean to close/reopen this issue btw, my finger slipped on my computer's track pad).

@jdfreder jdfreder closed this Mar 13, 2014
@jdfreder jdfreder reopened this Mar 13, 2014
do alliterate, aforementioned color alternative alias is amaranth
@ivanov
Copy link
Member Author

ivanov commented Mar 18, 2014

Ok, I've change the style for <code> to by black, instead of crimson. This doesn't affect anything in our cells, as those were already styled separately, and only applies to <code> tags that are used elsewhere. Now it looks like this:

2014-03-18-105435_547x170_scrot

@minrk
Copy link
Member

minrk commented Mar 19, 2014

This is looking just about ready. I think the last question to resolve is + vs - for delimiters: docs use - as delimiter, while shortcut API uses +.

Should we

  • switch the API to use -, and just be consistent everywhere?
  • let the API support both?
  • use + in quick-help, because the border/background around keys makes most of the +/- argument readability argument moot.
  • just leave it

I would lean toward either switching to - in the API or just leaving it as-is. Supporting both delimiters seems like unnecessary complexity.

Further options in the API that avoid any of the issues that come with using a legitimate shortcut key as a delimiter:

  • use space as a delimiter
  • use two characters as delimiter (e.g. ||)
  • use arrays, rather than parsing strings

@ivanov
Copy link
Member Author

ivanov commented Mar 19, 2014

I'm working on making the API use -.

@ivanov
Copy link
Member Author

ivanov commented Mar 20, 2014

ok, i think the API now expects and uses - as the delimiter. Getting the alt-- and a standalone - keyboard shortcuts was a bit tricky, but I've got it now, Travis willing.

@ivanov
Copy link
Member Author

ivanov commented Mar 20, 2014

Travis is green, and there was much rejoicing!

minrk added a commit that referenced this pull request Mar 20, 2014
update quickhelp on adding and removing shortcuts
@minrk minrk merged commit 90ee037 into ipython:master Mar 20, 2014
@minrk minrk deleted the quickhelp-update branch March 20, 2014 21:35
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
update quickhelp on adding and removing shortcuts
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

6 participants