xiota / geany-preview

Turns Geany into a markdown editor by providing a preview pane in the sidebar to show the formatting of several light-weight languages as they are edited. Supported document types include AsciiDoc, DocBook, Fountain, HTML, LaTeX, Markdown, MediaWiki, reStructuredText, Textile, and Txt2Tags.
GNU General Public License v3.0
15 stars 0 forks source link

add the shortcut "Toggle between editor and sidebar" to the plugin #40

Closed ralf3u closed 1 year ago

ralf3u commented 2 years ago

reasons Because of https://github.com/xiota/geany-preview/issues/20, editing a long HTML-document, the change will not directly appear in the Preview, it could be better that some users want to code in the only-one-view-modes, so only-editor-view or only-sidebar-view. For this situation, two shortcuts would be needed, "Toggle sidebar" https://github.com/xiota/geany-preview/issues/37 and "Toggle editor" https://github.com/xiota/geany-preview/issues/38 (that both don't exist at the moment inside the plugin). But one shortcut would be better. Two other situations where it could be also useful: 1) webpage that has a big width, and 2) because maybe one don't want to be distracted by the Preview while typing.

entering It should start what was in focus just before pressing the shortcut, but only if the only-view is not already active. If the only-view is already active because for example the shortcut "Toggle editor" was pressed just before, then the counterpart should be shown (so, to stay in this example, if in the only-editor-view the shortcut "Toggle between editor and sidebar" is pressed, then after pressing the shortcut, the only-sidebar-view should appear). That means that the state file of the two shortcuts ("Toggle sidebar" and "Toggle editor") need to be checked first, if there are active, and if one of them is active, then the one should be de-activated.

leaving The exit of the loop would be possible with the shortcuts "Toggle editor" or "Toggle sidebar". Example: If the only-sidebar-view is active, and if the shortcut "Toggle editor" is pressed, then "Toggle editor" need to be pressed 2x, to see editor and preview side-by-side. If the only-sidebar-view is active, and if the shortcut "Toggle sidebar" is pressed, then editor and preview will appear side-by-side. For the leaving-scenarios the state file of the two shortcuts "Toggle editor" and "Toggle sidebar" need to be extended, because they need to check first if "Toggle between editor and sidebar" is active. That means that a state file for the shortcut "Toggle between editor and sidebar" should exist.

documentation It should be mentioned in the documentation, for example on https://github.com/xiota/geany-preview/blob/main/docs/CQA.md, that in case the shortcut "Toggle between editor and sidebar" was set, but neither for "Toggle editor" nor for "Toggle sidebar" a shortcut was set, the ways how to leave the only-view is, a) by restarting Geany, or b) that this need to be done first: set a shortcut either for "Toggle sidebar" or for "Toggle editor", and then press 1x or 2x the corresponding shortcut.

overview This would be the possible list of the shortcuts for the navigation between editor and sidebar inside the plugin: Toggle focus between editor and sidebar (the shortcut already exist in the plugin) https://github.com/xiota/geany-preview/issues/4 https://github.com/xiota/geany-preview/issues/34#issuecomment-1162606954 Toggle sidebar https://github.com/xiota/geany-preview/issues/37 Toggle editor https://github.com/xiota/geany-preview/issues/38 Toggle between editor and sidebar (this issue)

development First https://github.com/xiota/geany-preview/issues/37 and https://github.com/xiota/geany-preview/issues/38 need to be solved, then the solutions need to be checked for some weeks, before to start to solve this issue, because it could be that new problems will appear.

xiota commented 2 years ago

Is this to show hide the editor or sidebar, so that only one is visible, similar to the lua script that hides the editor?

ralf3u commented 2 years ago

Is this to show hide the editor or sidebar, so that only one is visible, ...

Yes, that's correct. By pressing the shortcut the view changes to a view, where only one is visible. If the shortcut is pressed again, there will be still only one visible.

xiota commented 2 years ago

I would rather do this as a lua script. There would be several scripts, corresponding with the multiple issues that you opened, that interact with each other.

ralf3u commented 2 years ago

I would rather do this as a lua script. There would be several scripts, corresponding with the multiple issues that you opened, that interact with each other.

OK, but what are the reasons in short not to integrate it in Geany Preview?

ralf3u commented 2 years ago

I would rather do this as a lua script.

In the last lua-script (https://github.com/xiota/geanylua-scripts/issues/4) the focus feature was not solved. In #37 I mentioned this:

Maybe the focus feature could be solved with copy & paste of a part of the code of the shortcut "Toggle focus between the editor and preview", because they have both exactly the same focus feature.

And that was also a reason for me why to integrate the shortcut in Geany Preview, so not as lua-script, because the focus feature is already solved in the shortcut "Toggle focus between the editor and preview".

xiota commented 2 years ago

Focus is problematic. Something in the preview tab ends up in focus, but whether it's exactly what you want is hit and miss. I think you mentioned that elsewhere when you tried to do keyboard navigation.

ralf3u commented 2 years ago

Focus is problematic.

Till now focus is only problematic when the mouse comes into action (see https://github.com/xiota/geany-preview/issues/5#issuecomment-1208227721 and #15). So for shortcuts, focus is not problematic. That is the reason why the shortcut "Toggle focus between editor and preview" works perfect. So, focus should be no problem for #37, #38 and this issue, because it is all about shortcuts.

ralf3u commented 2 years ago

I would rather do this as a lua script. There would be several scripts, corresponding with the multiple issues that you opened, that interact with each other.

Unfortunately at the moment it seems to be that the focus feature can't be solved (https://github.com/xiota/geany-preview/issues/5#issuecomment-1248181705), so now there's only the crisscross feature left that could be realized. Would it be possible to create lua-scripts for #37, #38 and #40?

ralf3u commented 2 years ago

Today I prefer this name as shortcut because it is more clear about what it is: Toggle only editor/only sidebar An alternative would be: Toggle between only editor and only sidebar Maybe the last one is better.

ralf3u commented 2 years ago

focus-feature For reasons of documentation, I would like to mention that, according to https://github.com/xiota/geany-preview/issues/5#issuecomment-1272538526, the focus-feature could be realized in this issue by a kind of copy/paste of the focus-feature of the shortcut "Toggle focus between editor and sidebar":

Not exactly copy/paste, but they're doable.

ralf3u commented 2 years ago

Clear separation Since end of last week I think that it would be better to have a clear separation between #37 & #38, and this issue, else it creates confusion. That means that an additional shortcut for leaving is necessary.

Additional shortcut An additional shortcut next to the shortcut Toggle between only editor and only sidebar would be good with this kind of text: Exit "Toggle between only editor and only sidebar"

No crisscross feature any more a If #37 or #38 is active, then by pressing the shortcut Toggle between only editor and only sidebar, nothing should happen. b If Toggle between only editor and only sidebar is active, and then by pressing the shortcut #37 or #38, nothing should happen.

Conclusion Three state file are still needed.

Entering When the shortcut Toggle between only editor and only sidebar is pressed, then the content-area of the corresponding tab should still stay in focus.

Exit When the shortcut Exit "Toggle between only editor and only sidebar" is pressed, then the content-area of the corresponding tab should still stay in focus.

ralf3u commented 2 years ago

The advantage of the shortcut Exit "Toggle between only editor and only sidebar" is that by pressing it, it leaves right away the mode Toggle between only editor and only sidebar.

ralf3u commented 2 years ago

When the shortcut is active (specially in the only-editor-mode): It would be good if tab-browsing in the editor works correct with auto-sidebar.

ralf3u commented 2 years ago

Would it be possible to program the four shortcuts down below (with the focus feature https://github.com/xiota/geany-preview/issues/40#issuecomment-1274579339) till the end of 2022?

Toggle between only editor and editor/sidebar Toggle between only sidebar and editor/sidebar Toggle between only editor and only sidebar Exit "Toggle between only editor and only sidebar"

xiota commented 1 year ago

This can probably be done with the lua scripts.

ralf3u commented 1 year ago

I have also to rethink about this shortcut.

ralf3u commented 1 year ago

Would it be possible to program the four shortcuts down below (with the focus feature https://github.com/xiota/geany-preview/issues/40#issuecomment-1274579339) till the end of 2022? Toggle between only editor and editor/sidebar Toggle between only sidebar and editor/sidebar Toggle between only editor and only sidebar Exit "Toggle between only editor and only sidebar"

I recognize now that I don't need those shortcuts any more (the current shortcut "Toggle editor" is enough for me). Nevertheless I will open new issues for the shortcuts mentioned above on geanylua-scripts during the next days.

xiota commented 1 year ago

Please open only one issue for all four (or however many you decide you'd like) on the lua scripts github. Please keep the description brief. You can also link back to the issues here. Thank you.

BTW: PPA has been updated with a new version. You can read the commit log for a brief description of the changes.