Bug 377572 - Need keybinding to collapse/expand folding annotations
Summary: Need keybinding to collapse/expand folding annotations
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Editor (show other bugs)
Version: 0.5   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 2.0 RC2   Edit
Assignee: Lakshmi P Shanmugam CLA
QA Contact:
URL:
Whiteboard:
Keywords: accessibility
Depends on:
Blocks:
 
Reported: 2012-04-24 14:59 EDT by Max Li CLA
Modified: 2012-10-12 15:15 EDT (History)
2 users (show)

See Also:
Silenio_Quarti: review+


Attachments
patch-1 (7.57 KB, patch)
2012-10-01 08:12 EDT, Lakshmi P Shanmugam CLA
no flags Details | Diff
patch-2 (6.25 KB, patch)
2012-10-12 14:53 EDT, Lakshmi P Shanmugam CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Max Li CLA 2012-04-24 14:59:44 EDT
There's currently no way to expand/collapse the folding annotations without using the mouse. There needs to be a way to do this via the keyboard.

Eclipse uses Ctrl+(Numpad{+,-,*,/}) to expand/collapse (all). This might not be a good choice because it does override the font size keybinding in browsers, though you are able to do it anyway with the other +,- keys.
Comment 1 Max Li CLA 2012-04-25 21:37:53 EDT
Here is a first attempt.

Silenio, could you please review?

It's in the bug377572 branch.
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?h=bug377572&id=49dff5ea3795c95d33aff4b467206685907c67ac
Comment 2 Silenio Quarti CLA 2012-04-26 23:02:48 EDT
Code is fine. Here are a few things that could/should be improved:

1) Use view.setRedraw(true)/setRedraw(false) to speed up collapseAll and expandAll. Take a look at demoSetup.js.  When there many folding regions (textView.js for example), it is a big improvement.

2) We need to keep the top index line constant after collapsing or expanding, otherwise the user will be lost. 

3) Put the caret inside of a comment. Ctrl+- to collapse it. Caret is place in the first line after the collapsed comment. I should be able to hit Ctrl++ to expand it again. Works in Eclipse.

4) Ctrl+- and Ctrl++ on IE 9 still zoom in and out. Can we avoid this?
Comment 3 Lakshmi P Shanmugam CLA 2012-10-01 08:12:02 EDT
Created attachment 221713 [details]
patch-1

I was unable to find a way to patch using orion, and unable to find my way to get it work with git hub. So, attached the patch here directly...
Comment 4 Lakshmi P Shanmugam CLA 2012-10-01 08:26:04 EDT
(In reply to comment #2)
Updated the patch to the latest code and made the following changes:

> Code is fine. Here are a few things that could/should be improved:
> 
> 1) Use view.setRedraw(true)/setRedraw(false) to speed up collapseAll and
> expandAll. Take a look at demoSetup.js.  When there many folding regions
> (textView.js for example), it is a big improvement.
> 
done.

> 2) We need to keep the top index line constant after collapsing or
> expanding, otherwise the user will be lost. 
> 
I didn't notice this problem. Expanding/collapsing doesn't change the top index line.

> 3) Put the caret inside of a comment. Ctrl+- to collapse it. Caret is place
> in the first line after the collapsed comment. I should be able to hit
> Ctrl++ to expand it again. Works in Eclipse.
> 
To fix this, the patch moves the caret to first line of the annotation, instead of, to the next line. So, the behavior is same no matter from which line you collapse.

> 4) Ctrl+- and Ctrl++ on IE 9 still zoom in and out. Can we avoid this?
Don't have this setup yet. Will setup IE9 and try it out.

There is a problem with using numpad keys for shortcut, when using the Mac. They aren't available on the mac book and newer mac keyboards. There is no way to emulate it, without using external apps. With eclipse, I guess, this wasn't a problem because we could rebind the keys using the preferences.
I tried to use Ctrl++ and Ctrl+-, but that doesn't seem to work. So, I've temporarily mapped to different keys. Silenio, what do you think we should do here?
Comment 5 Lakshmi P Shanmugam CLA 2012-10-04 08:55:48 EDT
I have pushed the patch to github --> https://github.com/lshanmug/orion.client/commit/4ce0afa16a5cc55383ec0a1f294bb73d9bf68ef0

I tried the patch on IE9 setup and can see the zoom problem. Should we add conditional code for IE9? I think we can use a different keybinding, so that the mac problem is also resolved.
Comment 6 Silenio Quarti CLA 2012-10-11 11:04:04 EDT
- Need to add the NON-NLS tags (there is a plugin to flag those as warnings. Use the Get Plugins navigation link to install it)

- Let's not add the new API in FoldingAnnotation.getStartOffset() at this point (RC2). Just inline the code.

- Even though these are the eclipse key bindings, I think we should not use Ctrl+NUMPAD_PLUS and Ctrl+NUMPAD_MINUS anywhere as they overwrite the user agent Zoom In/Out key bindings. This would fix the IE problem.  Would these work:

Ctrl+NUMPAD_DIVIDE -> collapse
Ctrl+NUMPAD_MULTIPLY -> expand
Ctrl+Shift+NUMPAD_DIVIDE -> collapseAll
Ctrl+Shift+NUMPAD_MULTIPLY -> expandAll

- The key assist panel (Alt+Shift+?) does not show the NLSed names of the actions.   Need to change web/orion/editor/nls/messages.js file as well.

- In order to see problem 2), you have to be scrolled away from the beginning of the file. Open textView.js, Ctrl+End, Ctrl+NUMPAD_DIVIDE.

- Collapse does not work for the copyright comment of textView.js if the caret is in the middle of the comment (not at zero). Need to hit the action twice for it to work.
Comment 7 Lakshmi P Shanmugam CLA 2012-10-11 11:33:25 EDT
(In reply to comment #6)
> 
> - Even though these are the eclipse key bindings, I think we should not use
> Ctrl+NUMPAD_PLUS and Ctrl+NUMPAD_MINUS anywhere as they overwrite the user
> agent Zoom In/Out key bindings. This would fix the IE problem.  Would these
> work:
> 
> Ctrl+NUMPAD_DIVIDE -> collapse
> Ctrl+NUMPAD_MULTIPLY -> expand
> Ctrl+Shift+NUMPAD_DIVIDE -> collapseAll
> Ctrl+Shift+NUMPAD_MULTIPLY -> expandAll
> 
Hi Silenio,
The one problem with using Numpad keys is that we have use a different shortcut keys on mac, since they don't have the numpad keys.
Comment 8 Silenio Quarti CLA 2012-10-11 13:03:41 EDT
(In reply to comment #7)
> (In reply to comment #6)
> > 
> > - Even though these are the eclipse key bindings, I think we should not use
> > Ctrl+NUMPAD_PLUS and Ctrl+NUMPAD_MINUS anywhere as they overwrite the user
> > agent Zoom In/Out key bindings. This would fix the IE problem.  Would these
> > work:
> > 
> > Ctrl+NUMPAD_DIVIDE -> collapse
> > Ctrl+NUMPAD_MULTIPLY -> expand
> > Ctrl+Shift+NUMPAD_DIVIDE -> collapseAll
> > Ctrl+Shift+NUMPAD_MULTIPLY -> expandAll
> > 
> Hi Silenio,
> The one problem with using Numpad keys is that we have use a different
> shortcut keys on mac, since they don't have the numpad keys.

Maybe these everywhere (windows and mac).

Ctrl+Alt+c - collapse
Ctrl+Alt+e - expand
Ctrl+Alt+Shift+c - collapseAll
Ctrl+Alt+Shift+e - expandAll
Comment 9 Lakshmi P Shanmugam CLA 2012-10-12 14:53:17 EDT
Created attachment 222247 [details]
patch-2

Modified patch
Comment 10 Lakshmi P Shanmugam CLA 2012-10-12 15:00:21 EDT
(In reply to comment #6)
Patch fixes all problems in comment #6. Problem 2) from comment #2 is not reproducible with latest code. The top index seems to change only on collapse all and collapse all.

(In reply to comment #8)
> Maybe these everywhere (windows and mac).
> 
> Ctrl+Alt+c - collapse
> Ctrl+Alt+e - expand
> Ctrl+Alt+Shift+c - collapseAll
> Ctrl+Alt+Shift+e - expandAll

Modified the patch to use the above shortcuts on windows and Cmd instead of Ctrl on Mac. (because most of the other shortcuts use Cmd on Mac)
Comment 11 Silenio Quarti CLA 2012-10-12 15:15:04 EDT
Thanks very much Lakshmi. The patch is good. I have pushed it

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=e70490500beb906216a712999759c91b5f2559e4