Skip to content

Ctrl-Tab to switch between files [imported] #195

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

Closed
cmaglie opened this issue Nov 15, 2012 · 11 comments
Closed

Ctrl-Tab to switch between files [imported] #195

cmaglie opened this issue Nov 15, 2012 · 11 comments
Labels
Component: IDE user interface The Arduino IDE's user interface feature request A request to make an enhancement (not a bug fix)

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 195 moved from a Google Code project.
Added by 2010-01-30T13:46:10.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Enhancement, Priority-Medium

Original description

What change would like to see?
Pressing Ctrl-Tab advances to the next tab.
Pressing Ctrl-Shift-Tab switches to the previous tab.

Why?
The Ctrl-Tab behavior is so often implemented in applications that I, and
possibly many other developers, are very used to this.
Some applications allow you to just navigate through the tabs in a defined
order (like Firefox, Chrome and Internet Explorer).
Some even remember the order of tabs you've accessed and allow you to
switch between them in the accesses order (like Visual Studio, TextPad,
UltraEdit). Like Alt-Tab does in Windows, and probably on other OSes too.

Would this cause any incompatibilities with previous versions? If so, how
can these be mitigated?
The only 'incompatibility' I can come up with is that people will not be
able to insert tabs while pressing Ctrl anymore. Though I think it's
unlikely anyone would do that.

An example of method 1:

  • 3 tabs: "MainSketch", "Library.cpp", "Library.h"
  • Currently in MainSketch
  • Press (and release) Ctrl-Tab and switch to Library.cpp
  • Press (and release) Ctrl-Tab again and switch to Library.h
  • Press (and release) Ctrl-Tab again and switch to MainSketch

An exmaple of method 2:

  • 3 tabs: "MainSketch", "Library.cpp", "Library.h"
  • Currently in MainSketch
  • Press (and release) Ctrl-Tab and switch to Library.cpp
  • Press (and release) Ctrl-Tab again and switch to MainSketch
  • Press (and release) Ctrl-Tab again and switch to Library.cpp
  • Press (and hold) Ctrl, then Tab twice, and release both to switch to
    Library.h
@ffissore ffissore added the New label Feb 27, 2014
@ffissore ffissore self-assigned this May 27, 2015
@ffissore ffissore added Component: IDE user interface The Arduino IDE's user interface feature request A request to make an enhancement (not a bug fix) labels May 27, 2015
@cmaglie
Copy link
Member Author

cmaglie commented May 27, 2015

CTRL-TAB is working with the latest build, but not CTRL-SHIFT-TAB to go back on the previous tab.

@Scalpel78
Copy link

It would be useful if CTRL-TAB switched between the files you last used, and not EVERY file. I want to be able to quickly jump between two files, not step through all files in the project.

matthijskooijman added a commit to matthijskooijman/Arduino that referenced this issue Dec 9, 2015
Previously, the keybinding for Ctrl-Tab didn't check the status of the
Shift key, so it would also trigger when pressing Ctrl-Shift-Tab. This
resulted in switching tabs forward *and* back, making it look like the
switch back was not working.

Closes: arduino#195
matthijskooijman added a commit to matthijskooijman/Arduino that referenced this issue Dec 9, 2015
Previously, the keybinding for Ctrl-Tab didn't check the status of the
Shift key, so it would also trigger when pressing Ctrl-Shift-Tab. This
resulted in switching tabs forward *and* back, making it look like the
switch back was not working.

Closes: arduino#195
matthijskooijman added a commit to matthijskooijman/Arduino that referenced this issue Dec 11, 2015
Previously, EditorListener handled these keys, by registering a handler
in the text area. This meant that they would only work while the text
area was focused. By registering the keys as WHEN_IN_FOCUSED_WINDOW
bindings, they can always be handled, and EditorHeader seems like a more
appropriate place.

Note that this does not currently work (so this commit breaks these
keys), since these keys are also handled in a few different places as
well, preventing these newly added keybindings to take effect. This will
be fixed in the next commit.

One additional change is that previously, these keybindings did not work
when the text area was readonly. This was probably a remnant from when
EditorListener took care of a lot of other editing keybindings, but
this does not make much sense anymore now.

Finally, with the old bindings, ctrl-shift-tab did not (seem to) work.
What happened is that the binding for ctrl-tab did not check the shift
state, so both bindings would fire on ctrl-shift-tab, switching forward
and back again, making it seem the keys did not work. The Swing
keybinding mechanism that is now used for these bindings checks the
complete keystroke, including all modifier keys, so this problem is
fixed by this change.

References arduino#195
matthijskooijman added a commit to matthijskooijman/Arduino that referenced this issue Dec 11, 2015
In the previous commit, these bindings were moved to EditorTab and
registered in a cleaner way, but this move also allows more components
to hijack these keystrokes and prevent them from reaching EditorTab.

This commit makes the keybindings work again, by preventing other
components from handling the keys. In particular:
 - JSplitPane had a binding to switch between its two panes, which is
   now removed after creating the JSplitPane.
 - The default focus traversal manager in Swing uses these keys to
   traverse focus (in addition to the the normal tab and shift-tab
   keys). By removing these keys from the set of "focus traversal keys"
   defined for the window, this should be prevented when the focus is on
   any component inside the window.
 - JTextPane didn't respond to the previous modification of the
   window-default focus traversal keys, since it defines its own set (to
   only contain ctrl-tab and ctrl-shift-tab, but not tab and shift-tab,
   for undocumented reasons). To fix this, focus traversal is simply
   disabled on the JTextPane, since this wasn't really being used
   anyway.

There was some code in SketchTextArea that tried to modify the focus
traversal keys for just the text area, which is now removed. This code
wasn't really useful, since focus traversal is disabled for the text
area already. Also, the code contained a bug where it would not actually
set the new set of keys for the backward focus traversal.

Closes arduino#195
matthijskooijman added a commit to matthijskooijman/Arduino that referenced this issue Dec 11, 2015
Previously, EditorListener handled these keys, by registering a handler
in the text area. This meant that they would only work while the text
area was focused. By registering the keys as WHEN_IN_FOCUSED_WINDOW
bindings, they can always be handled, and EditorHeader seems like a more
appropriate place.

Note that this does not currently work (so this commit breaks these
keys), since these keys are also handled in a few different places as
well, preventing these newly added keybindings to take effect. This will
be fixed in the next commit.

One additional change is that previously, these keybindings did not work
when the text area was readonly. This was probably a remnant from when
EditorListener took care of a lot of other editing keybindings, but
this does not make much sense anymore now.

Finally, with the old bindings, ctrl-shift-tab did not (seem to) work.
What happened is that the binding for ctrl-tab did not check the shift
state, so both bindings would fire on ctrl-shift-tab, switching forward
and back again, making it seem the keys did not work. The Swing
keybinding mechanism that is now used for these bindings checks the
complete keystroke, including all modifier keys, so this problem is
fixed by this change.

References arduino#195
@lmihalkovic
Copy link

I missed some of the details of this proposal:

  • switching only on RELEASE while repainting the tabs to or something else to show which is the tentative target)
  • finding a way to have a sub-group targetting only a subset of all the files (anyone knowing a app modeling this for inspiration? - xcode has something like that with menus, but i have to chk if there are shortcuts for it, or to see when files come out of that list)

@matthijskooijman
Copy link
Collaborator

@lmihalkovic, I think those are two separate feature requeste, perhaps you should file them as such?

@lmihalkovic
Copy link

@matthijskooijman yes, they are distinct features. The first one was part of the original posting (AFAIK it is still not fully implemented), and the second seems to have been added @Scalpel78 more recently (added new entry for it #4350). My intention I was just to direct attention to the fact that the main entry is closed but these smaller details seemed to have fallen through the cracks.

IMHO the first one is a great UX improvement for which you might want to consider reopening this item and finish including it in your recent rework (doing it in my fork).

@lmihalkovic
Copy link

thinking about it further.. it might even be nice for users to support

  • case 1(already in scope of original posting)
    Ctrl-TAB [show visually which fill file will become active next]
    Ctrl-TAB [show visually which fill file will become active next]
    RELEASE --> switch
  • case 2 (extension of previous case)
    Ctrl-TAB [show visually which fill file will become active next]
    Ctrl-TAB [show visually which fill file will become active next]
    ESC --> cancel switching and remain on the current tab

@matthijskooijman
Copy link
Collaborator

@lmihalkovic thanks for opening the new issue. Regarding the "switch on release" thing, I suspect you mean that you will switch when "ctrl" is released, instead of when tab is released? I do not think that the currently used java keybindings mechanism easily supports something like that, so we'd have to switch to processing key events directly. Also, I'm not sure what the advantages of adding this are. If you just switch the tab bar, or perhaps show a tab list popup, why not just switch tabs right away?

Anyway, if you feel that this is an important feature, could you also create a new report for it. Even if it was originally part of this request (which I'm not so sure), it will keep discussion cleaner if there is a separate issue for it.

@lmihalkovic
Copy link

Press (and release) Ctrl-Tab again and switch to Library.cpp
Press (and hold) Ctrl, then Tab twice, and release both to switch to Library.h

My reading of the second line is that as long as the keys are held, no switching is done. which is very convenient if someone has a sketch with a handful of tabs. This is also the way the app switching works on OSX (don't remember how it is on windoze). Just tested: Xcode jumps immadiately between tabs before releasing keys (sluggish feel when you jump 2 tabs away from the current). Safari also jumps immediately but at least it is not sluggish... will still try to the app-switcher way (jump only on release and press ESC to cancel switching away from current tab).

btw: as for the sub-grouping, Xcode has a fixed size list of "recently edited" files in a submenu, and no visible (so far) shortcut to cycle through only them.

Yes, you're correct that CTRL releasing is what dictates when the jump happens. not sure you are correct about the how though (have to test something before I speak stupidly).

@lmihalkovic
Copy link

public class KeyStroke extends AWTKeyStroke {
    public static KeyStroke getKeyStroke(int keyCode, int modifiers,  boolean onKeyRelease) {

the first piece seems to be there... will check the rest later

Anyway, if you feel that this is an important feature, could you also create a new report for it

I will when I see that there is a simple way through.

lmihalkovic pushed a commit to lmihalkovic/Arduino that referenced this issue Dec 31, 2015
Previously, EditorListener handled these keys, by registering a handler
in the text area. This meant that they would only work while the text
area was focused. By registering the keys as WHEN_IN_FOCUSED_WINDOW
bindings, they can always be handled, and EditorHeader seems like a more
appropriate place.

Note that this does not currently work (so this commit breaks these
keys), since these keys are also handled in a few different places as
well, preventing these newly added keybindings to take effect. This will
be fixed in the next commit.

One additional change is that previously, these keybindings did not work
when the text area was readonly. This was probably a remnant from when
EditorListener took care of a lot of other editing keybindings, but
this does not make much sense anymore now.

Finally, with the old bindings, ctrl-shift-tab did not (seem to) work.
What happened is that the binding for ctrl-tab did not check the shift
state, so both bindings would fire on ctrl-shift-tab, switching forward
and back again, making it seem the keys did not work. The Swing
keybinding mechanism that is now used for these bindings checks the
complete keystroke, including all modifier keys, so this problem is
fixed by this change.

References arduino#195
lmihalkovic pushed a commit to lmihalkovic/Arduino that referenced this issue Dec 31, 2015
In the previous commit, these bindings were moved to EditorTab and
registered in a cleaner way, but this move also allows more components
to hijack these keystrokes and prevent them from reaching EditorTab.

This commit makes the keybindings work again, by preventing other
components from handling the keys. In particular:
 - JSplitPane had a binding to switch between its two panes, which is
   now removed after creating the JSplitPane.
 - The default focus traversal manager in Swing uses these keys to
   traverse focus (in addition to the the normal tab and shift-tab
   keys). By removing these keys from the set of "focus traversal keys"
   defined for the window, this should be prevented when the focus is on
   any component inside the window.
 - JTextPane didn't respond to the previous modification of the
   window-default focus traversal keys, since it defines its own set (to
   only contain ctrl-tab and ctrl-shift-tab, but not tab and shift-tab,
   for undocumented reasons). To fix this, focus traversal is simply
   disabled on the JTextPane, since this wasn't really being used
   anyway.

There was some code in SketchTextArea that tried to modify the focus
traversal keys for just the text area, which is now removed. This code
wasn't really useful, since focus traversal is disabled for the text
area already. Also, the code contained a bug where it would not actually
set the new set of keys for the backward focus traversal.

Closes arduino#195
@lmihalkovic
Copy link

turns out it displaying a summary of the file (like the ALT-Tab app switcher) and only jumping when the right file is selected works fine and is somehow convenient: it means one can cycle through the list of files quickly to find the desired file without being delayed by the inertia of actually switching tab. you may want to look into it more closely.

@lmihalkovic
Copy link

example design for switching only when releasing ATL, and showing target file name in the meantime (working code though)

arduino-2016-01-07 at 9 27 35 am

arduino-2016-01-07 at 9 40 50 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE user interface The Arduino IDE's user interface feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Development

No branches or pull requests

5 participants