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

shortcut to make the editor invisible #4

Closed
ralf3u opened this issue Feb 23, 2022 · 24 comments
Closed

shortcut to make the editor invisible #4

ralf3u opened this issue Feb 23, 2022 · 24 comments

Comments

@ralf3u
Copy link

ralf3u commented Feb 23, 2022

it could be that sometimes one will see only the content of the preview

possible solution
in Preferences, in Keybindings: toggle editor on/off

@ralf3u
Copy link
Author

ralf3u commented Feb 24, 2022

I forgot to mention yesterday the jumping point, that in the moment where the editor is in off-mode, the sidebar should have the full width of the Geany window. So, maybe this is a better shortcut name: Toggle sidebar full width on/off.
This feature could be specially interesting for webdesign on small screens. I think that this would be a cool feature.

@ralf3u
Copy link
Author

ralf3u commented Mar 18, 2022

@xiota
I recognized that this feature in Geany Preview would be important for me. If it can't be solved within Geany Preview, maybe it can be solved with a lua-script, like the auto-sidebar. Could it be realized in the next months? And a fix of issue number 3 of xiota/geanylua-scripts would be also great. Thank you for an answer in advance.

@ralf3u
Copy link
Author

ralf3u commented Jun 4, 2022

I recognized that the name Toggle sidebar full width on/off is too long for the shortcut, and that's why I would prefer Toggle sidebar full width. One name of a shortcut in Geany is Toggle Sidebar, and it is not called Toggle Sidebar on/off, so Toggle sidebar full width should be enough.

The shortcut Toggle sidebar full width should have also this behavior:
In case the sidebar is disabled and if the shortcut is pressed, then it should enable the sidebar and the sidebar should take the full width in Geany. If the shortcut is pressed again, then sidebar should be disabled again, because it was disabled before the toggle.

Just for information: These would be then my shortcuts for Geany Preview:
F2: Toggle focus between the editor and preview
F3: Toggle Sidebar
F4: Toggle sidebar full width

@xiota
Copy link
Owner

xiota commented Jun 10, 2022

@ralf3u Sorry for not responding sooner... This can be done with a Lua script, similar to hiding the menubar.

I have added toggle-editor to xiota/geanylua-scripts. Some of the files are shared with toggle-menu, so you will have to open them to copy the new lines. Also, events/cleanup.lua from toggle-menu is changed to fix a minor issue.

@ralf3u
Copy link
Author

ralf3u commented Jun 10, 2022

Wow! That's so cool!

1
I think it would be better to solve first the following issue #3, what I already mentioned in my third comment, because when it is fixed it could cause here problems.

2
As mentioned in my last comment, I would not call it "Toggle editor" any more, but "Toggle sidebar full width". The reason: If I press the shortcut "Toggle editor" for the first time, then I see only the preview. But then I get a little bit confused, because then if I think about how to get out of this view, I think about the shortcut "Toggle editor", but if I press it, I expect in my head to see only the editor, but in real it is the editor and the preview.

3
If the vertical line between editor and preview is at about one third at the right side, and then if I press many times the shortcut Toggle editor, sometimes a vertical line appears just for a part of a second at about one third of the window on the left side.

4
In my last comment I wrote:

In case the sidebar is disabled and if the shortcut is pressed, then it should enable the sidebar and the sidebar should take the full width in Geany. If the shortcut is pressed again, then sidebar should be disabled again, because it was disabled before the toggle.

At the moment this is not respected. So, now if I press F3 to let disappear the Sidebar (shortcut "Toggle Sidebar") and then F4 (shortcut "Toggle editor"), there is an empty Geany. I would expect only the preview.

5
The inversion of point 4 does also not work, so if I press first the shortcut "Toggle editor" and then the shortcut "Toggle Sidebar", then there is also an empty Geany. I would expect only the editor.

@xiota xiota transferred this issue from xiota/geany-preview Jun 10, 2022
@xiota
Copy link
Owner

xiota commented Jun 10, 2022

Would a script that resizes the sidebar do what you want? You could set a list of percentages, like 30%, 70%, 100%. Then it would cycle through them. That might avoid the current problems with toggle-editor.

@ralf3u
Copy link
Author

ralf3u commented Jun 11, 2022

3
If the vertical line between editor and preview is at about one third at the right side, and then if I press many times the shortcut Toggle editor, sometimes a vertical line appears just for a part of a second at about one third of the window on the left side.

Would a script that resizes the sidebar do what you want? You could set a list of percentages, like 30%, 70%, 100%. Then it would cycle through them. That might avoid the current problems with toggle-editor.

I think that there is a misunderstanding. I just recognized that not all html-documents show a vertical line for a part of a second. It seems to be that some html-documents are shown sometimes with an artifact just for a part of a second, is it the vertical line or something else. Maybe it is because the used computer is slow. Down below is an example of html-code. In the moment where I press the shortcut "Toggle editor", I can see sometimes not only the green color in the middle, but also for a part of a second a green rectangle on the left side, specially when pressing fast many times the shortcut "Toggle editor". Do you see it too?

<!DOCTYPE html>
<html>
<head>
<title>test preview</title>
<style type="text/css">
.content {position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%)}
</style>
<body>
<div class="content" style="width:830px;height:590px;background:green"></div>
</body>
</html>

@xiota
Copy link
Owner

xiota commented Jun 12, 2022

If I hold down the shortcut and let it run as fast as it can, I see green on the left (normally my sidebar is on the right). It's probably a GUI update/refresh that I can't do anything about.

I just looked at the GeanyLua API. Unfortunately, I don't see anything that can be used to resize the sidebar.

@ralf3u
Copy link
Author

ralf3u commented Jun 12, 2022

Unfortunately, I don't see anything that can be used to resize the sidebar.

I didn't ask to resize the sidebar. The vertical line that appears just for a part of a second somewhere else in Geany, appears not in all html-documents, but only in some html-documents. And it seems to be that the GUI update/refresh is the cause that creates some artifacts for a part of a second, like the green color mentioned in your last comment.

To 4 and 5:
Can it be that it is too complicated or not possible to program, because then it would need also to re-code the shortcut "Toggle Sidebar" (specially 5)? Or is it because of the argument that coding crisscross things can cause a lot of problems? Or is it because you don't think that it is useful that shortcuts do crisscross things (what I can understand)?

focus feature
a
If the editor is in focus and if the shortcut "Toggle editor" is pressed, then sidebar has full width, but the content of the Preview-tab is not in focus. Better would be that if the Preview-tab is active, then the content of the Preview-tab should be automatically in focus.
b
When leaving sidebar full width with the shortcut "Toggle editor", the editor is not in focus. Better would be when editor is in focus automatically, because in the most cases before going in sidebar full width, the editor is in focus.

Would it be possible to add the two focus features a and b to the shortcut "Toggle editor"?

@xiota
Copy link
Owner

xiota commented Jun 12, 2022

I didn't ask to resize the sidebar.

I know you didn't ask for that, but doing so would have provided the feature you want (maximizing the sidebar) without the other problems.

the GUI update/refresh is the cause

I think so too. It is from GTK and out of my control. To fix it (in GTK) would probably require low level changes that would cause more problems. Since it's only momentary, it's better to leave it alone.

To 4 and 5:

The toggle scripts could look for the state files of each other's toggle scripts. It makes the code complicated, and it's better not to if it isn't needed.

focus feature

The GeanyLua API is limited, so it might not be possible. I'll check.

@ralf3u
Copy link
Author

ralf3u commented Jun 12, 2022

The GeanyLua API is limited, so it might not be possible. I'll check.

That would be great. Maybe this link xiota/geany-tab-style#5 could help, because also at the beginning of the development of the shortcut "Toggle between the editor and preview", the content of the Preview-tab was not in focus.

@xiota
Copy link
Owner

xiota commented Jun 13, 2022

focus feature

It might work now. Let me know.

To 4 and 5:

auto-sidebar does not create a state file. Geany built-in toggle does not create a state file. I would need to make a toggle-sidebar script that saves a state file to make toggle-editor play nicely with it. I'll look at it later.

@ralf3u
Copy link
Author

ralf3u commented Jun 13, 2022

It might work now. Let me know.

Now when toggling, the tab-title of the Preview is in focus and then the tab-title of the editor is in focus.
The goal was that the content of the Preview is in focus and then the content of the editor is in focus, so in both cases not the tab-title.
Maybe I didn't explain it correctly in my other comment when I meant the editor should be in focus. With that, I was meaning that the highlighted line should appear again in the editor (on that place where it was the last time to continue coding).

In the end the focus of the shortcut "Toggle editor" should work exactly like the focus of the shortcut "Toggle between the editor and preview", in the editor and in the preview.

@xiota
Copy link
Owner

xiota commented Jun 13, 2022

the tab-title of the Preview is in focus and then the tab-title of the editor is in focus

Lua doesn't have any way to focus on the contents of the tab. You can use the down key to move focus inside the tab. Or I can put it back the way before and not bother trying to move focus.

@xiota xiota closed this as completed Jun 13, 2022
@xiota xiota reopened this Jun 13, 2022
@ralf3u
Copy link
Author

ralf3u commented Jun 13, 2022

Lua doesn't have any way to focus on the contents of the tab.

What about to put the shortcut "Toggle editor" in the plugin Preview, like the shortcut "Toggle between the editor and preview"?
Then the focus feature could be realized.

@ralf3u
Copy link
Author

ralf3u commented Jun 13, 2022

The new toggle-editor-lua-scripts have four disadvantages when toggling:

  • when a tab of the editor is in focus, then there are some disturbing dotted white lines around the tab-title of the editor
  • when a tab of the preview is in focus, then there are some disturbing dotted white lines around the tab-title of the preview
  • when editor is not visible: pressing 1x arrow-left/right will jump to the previous/next tab of the sidebar, what is not a common use for tab-browsing
  • when editor is visible: pressing 1x arrow-left/right will jump to the previous/next tab of the editor, what is not a common use for tab-browsing

Those four disadvantages do not occur in the old toggle-editor-lua-scripts.
Would it be possible to delete the new ones an to re-upload the old ones on https://github.com/xiota/geanylua-scripts?

@xiota
Copy link
Owner

xiota commented Jun 13, 2022

I've reverted the change.

I'd rather not put this in the preview plugin. Trying to hiding gui elements and grab focus hasn't worked well in the past (eg, toggle focus between editor and sidebar).

@ralf3u
Copy link
Author

ralf3u commented Jun 14, 2022

Trying to hiding gui elements and grab focus hasn't worked well in the past (eg, toggle focus between editor and sidebar).

I don't understand. The shortcut "Toggle focus between the editor and sidebar" works absolutely perfect. There is not even one thing that does not work. There is no open issue about that.

@xiota
Copy link
Owner

xiota commented Jun 14, 2022

I don't understand. The shortcut "Toggle focus between the editor and sidebar" works absolutely perfect. There is not even one thing that does not work. There is no issue open about that.

Maybe I'm mis-remembering. I thought there were problems with tab navigation or something. Maybe I'm confusing it with something else.

GeanyLua references widgets by their name in the glade file. I don't think it's possible to access GTK widgets that are created at runtime, like the contents of specific tabs. There's another scripting plugin (peasy) that might be able to do it. I haven't tried writing any scripts for it yet.

@ralf3u
Copy link
Author

ralf3u commented Jun 14, 2022

Maybe I'm mis-remembering. I thought there were problems with tab navigation or something.

There was a problem with tab-browsing (xiota/geany-tab-style#6; in the comment it is called "issue 3"). It was fixed (xiota/geany-tab-style#6), then reappeared (xiota/geany-preview#11), and now just disappeared (xiota/geany-preview#11 (comment)). It was only visible when the Symbols-tab was part of the sidebar (xiota/geany-preview#11 (comment)), so it was just a very small issue.

GeanyLua references widgets by their name in the glade file. I don't think it's possible to access GTK widgets that are created at runtime, like the contents of specific tabs. There's another scripting plugin (peasy) that might be able to do it. I haven't tried writing any scripts for it yet.

Tomorrow I would like to open in Geany Preview a new issue about the shortcut "Toggle sidebar". Then the next day I would like to open again an issue, but this time about the shortcut "Toggle editor". If you don't like both reports, just delete them, and copy those parts of text that you think could be interesting, maybe to paste the parts here in this issue.

@ralf3u
Copy link
Author

ralf3u commented Jun 14, 2022

I've reverted the change.

Thank you so much for the shortcut "Toggle editor". It is a significant option, because now there's no need to switch to the browser to see the webpage in big, if one don't want to resize the sidebar with the mouse.

@ralf3u
Copy link
Author

ralf3u commented Mar 27, 2024

It's quite interesting, because in the second comment of this issue I noted:

This feature could be specially interesting for webdesign on small screens. I think that this would be a cool feature.

To that time, I didn't use a small display. I even didn't think to use a small display. But things have changed, and now I'm using a small display. Well, it is not really small, but the width is not so big. So, the shortcut to make the editor invisible is for me very interesting.
Because all focus issues of the plugin Preview are now fixed on your computer, does also this shortcut set the focus correctly on your computer?

The best would be if the shortcut works like this:
Toggle between only-sidebar-view (focus is on the content of the Preview-tab) and only-editor-view (focus is on the content of the editor).

@xiota
Copy link
Owner

xiota commented Mar 28, 2024

With the switch-views scripts, focus goes where I expect. (Geany 2.0, GTK 3.24.41) When only editor is visible, focus goes to editor. When only sidebar is visible, focus goes to contents of sidebar. But if tab is changed by user, focus stays on tabbar, unless xitweaks plugin is loaded with focus highlighting feature enabled. Then focus goes to tab contents (by xitweaks).

I've updated the scripts to attempt to change focus at the same time editor/sidebar visibility is changed. I think before I tried to add some delay to work around some issue, but it never really worked and now no longer needed.

@ralf3u
Copy link
Author

ralf3u commented Mar 28, 2024

When only editor is visible, focus goes to editor. When only sidebar is visible, focus goes to contents of sidebar.

That sounds so great!!
I will test it the next weeks in Lubuntu 24.04 with Geany 2.0.

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

No branches or pull requests

2 participants