Thanks to Geany-Preview (https://github.com/xiota/geany-preview), one can code within Geany on one side the code in the editor and see in the same window on the other side, in the sidebar, a preview of the code. Geany gives the possibility to switch with a shortcut to the editor and Geany gives the possibility to switch with a shortcut to the sidebar, but with different shortcuts (https://www.geany.org/manual/current/index.html#focus-keybindings). Better would be to use always one shortcut to toggle editor/sidebar.
Since the focus can be switched from any pane the focus commands all have an explicit destination since they can be activated in any pane.
To illustrate, if the same keybinding toggles sidebar to editor, which does it switch to if focus is in the message window when it is activated, sidebar or editor?
@elextr Sorry, but it could be that I don't understand what you mean. So I try to describe the functionality of an imaginary shortcut "toggle editor/sidebar":
By pressing an imaginary shortcut "toggle editor/sidebar", the focus should switch to the place that is not in focus, when the focus is at the moment editor or sidebar. That means: - if the editor is in focus, and then if the user press the imaginary shortcut "toggle editor/sidebar", then the sidebar should be in focus - if the sidebar is in focus, and then if the user press the imaginary shortcut "toggle editor/sidebar", then the editor should be in focus
Now if the focus is not on the editor and not on the sidebar, then by pressing an imaginary shortcut "toggle editor/sidebar", Geany should put the focus on the editor.
Please leave a message if I didn't answer your question.
But what should it switch to if the message window is in focus when the shortcut is activated?
@elextr
But what should it switch to if the message window is in focus when the shortcut is activated?
to the editor
If you program in HTML, you switch between the editor and the preview sometimes easily over 100 times a day. What I want to say with that is not only how much sense only one shortcut would make, but also the urgency of such a shortcut. Maybe this remark could have an impact on the development timeline of this issue.
Well, I guess an _additional_ keybinding that is context sensitive and switches between sidebar and editor can be added. It doesn't make any sense to remove any of the existing "goto XXX" bindings since they work anywhere, making one of them context sensitive doesn't make sense.
@elextr I'm willing to add toggle shortcuts directly to the preview plugin if you feel they're not appropriate for the main program. (However, this does seem like something that could be generally useful.) I can also try adding this to the main program if there isn't anything else going on that it needs to wait for (like prepping for a 1.38 release?).
Geany keybindings are global, they almost all work in all panes (but some fudges for Terminal IIRC). So context dependent keybindings like toggle focus don't really fit with it, especially when its related to a pane added by a plugin thats not always present.
I'm willing to add toggle shortcuts directly to the preview plugin
So yes adding the "toggle editor/preview focus" keybinding to the preview plugin that needs it is a better idea.
Geany and Geany-plugins are currently in string freeze, and so its unlikely anything will be added before release, since I expect adding a keybinding in the plugin will add a string to its UI.
Just out of interest, why do you need to shift focus to an output only preview, doesn't it update automagically?
@elextr
... especially when its related to a pane added by a plugin thats not always present... why do you need to shift focus to an output only preview, doesn't it update automagically?
The preview pane does update itself, but if the changed area is out of view, the user would have to scroll manually, since I don't know how to locate the position of changes in the preview pane. Normally, I would use my touchpad to scroll, but I suppose some people might prefer to change focus and use the keyboard.
My understanding of the way a toggle like this would function is that it would apply to the sidebar as a whole. So it would be more useful for the Symbols, Documents, and Tree Browser tabs than for the Preview pane. Toggles are also nice because they reduce the number of shortcuts I have to remember.
Another way a shortcut could work is to just move in sequence among whichever of the editor, sidebar, and message window are visible.
Geany and Geany-plugins are currently in string freeze, and so its unlikely anything will be added before release, since I expect adding a keybinding in the plugin will add a string to its UI.
Could that be why a [PR I opened to fix a bug in the Markdown plugin](https://github.com/geany/geany-plugins/pull/1111) has received zero responses? It doesn't change any user-facing strings, but does use strings to store some javascript.
Ok, focus for scrolling the preview makes sense.
Changing users shortcut muscle memory by making "goto" shortcuts toggle instead will get you much hate :grin:, especially from those of us who also **hate** modal UIs. But _adding additional_ toggle keybindings might be more acceptable.
Toggling to the sidebar makes less sense (to me), I usually want to go to a specific tab, not the generic sidebar, eg go to symbol list or document list.
String freeze is for translated strings to give the translators time to catch up with any new or changed strings before release. Javascript strings are not translated so are unaffected by string freeze.
Responses for maintained plugins come from plugin maintainers, Geany hasn't heard from the markdown maintainer for a while, maybe he is busy, did you ping him? (github names are in the MAINTAINERS file for at least some maintainers).
Changing users shortcut muscle memory... But adding additional toggle keybindings might be more acceptable.
Since the title of the issue does say "add", it was probably ralf3u's intention that this would be an additional shortcut. That is how I would have implemented anyway.
I was thinking the lua plugin could be used for something like this, but I didn't see any functions for checking visibility and grabbing focus in the docs.
I usually want to go to a specific tab...
That's true. I normally use the mouse.
Responses for maintained plugins come from plugin maintainers, Geany hasn't heard from the markdown maintainer for a while, maybe he is busy, did you ping him?
I pinged codebrainz in the issue last week. I'm not in a hurry and figured he might be busy. Since I fixed the issue for the preview plugin, I thought I might as well send the fix on to the markdown plugin.
I was thinking the lua plugin could be used for something like this
Since there are existing focus keybindings for editor, sidebar, etc, they could be used [via this function](https://www.geany.org/manual/reference/keybindings_8h.html#a9b9034dde2091a8d...) by a plugin that can call C. Not sure if thats available in Lua though.
@elextr Thank you. I'll add a plugin specific shortcut to the preview plugin and wait for after the 1.38 release to think about submitting more general changes to either geany or geany-plugins.
@elextr @xiota
Just out of interest, why do you need to shift focus to an output only preview, doesn't it update automagically?
The preview pane does update itself, but if the changed area is out of view, the user would have to scroll manually, since I don't know how to locate the position of changes in the preview pane. Normally, I would use my touchpad to scroll, but I suppose some people might prefer to change focus and use the keyboard.
Switching to the preview pane is also useful for animations that are fired by different shortcuts.
ralf3u left a comment (geany/geany#2914)
I just tested the two Geany-shortcuts (located in Preferences, Keybindings, Action `Focus`) `Switch to Editor` and `Switch to Sidebar` with the Preview-tab in the sidebar (see https://github.com/xiota/geany-preview). Both shortcuts work perfect. So, the shortcut `Toggle focus between editor and sidebar` (see title of this issue) makes still sense for me. If someone will program the shortcut, I would like to mention one important thing: For the shortcut `Toggle focus between editor and sidebar` one can not put the code of the shortcut `Switch to Editor` and the shortcut `Switch to Sidebar` together without change, because of the message window and VTE. Something like this should be added to the code: IF message window or VTE have focus, THEN do nothing.
ralf3u left a comment (geany/geany#2914)
The last sentence of the last comment is:
IF message window or VTE have focus, THEN do nothing.
I forgot to mention the reason. The reason is that the shortcut should do EXACTLY what the name of the shortcut is saying, and nothing else: `Toggle focus between editor and sidebar`
github-comments@lists.geany.org