xiota / geanylua-scripts

GeanyLua scripts to add some minor features to Geany. Hide the menubar. Show multiple long-line column markers.
GNU General Public License v2.0
3 stars 0 forks source link

Shortcuts for Geany Preview #7

Closed ralf3u closed 1 year ago

ralf3u commented 1 year ago

Shortcut names 1: Toggle between only editor and editor/sidebar 2: Toggle between only editor and editor/sidebar; focus stays in the editor 3: Toggle between only sidebar and editor/sidebar 4: Toggle between only editor and only sidebar 5: Exit "Toggle between only editor and only sidebar"

Shortcuts in action 1: if "only editor" is not shown, then (show "only editor" & put editor in focus), else (show editor/sidebar & put sidebar in focus) 2: if "only editor" is not shown, then (show "only editor" & put editor in focus), else (show editor/sidebar & put editor in focus) 3: if "only sidebar" is not shown, then (show "only sidebar" & put sidebar in focus), else (show editor/sidebar & put editor in focus) 4: if the shortcuts 1, 2 and 3 are blocked, then (if "only editor" is shown, then (show "only sidebar" & put sidebar in focus), else (show "only editor" & put editor in focus)); if editor/sidebar is shown, then (block the shortcuts 1, 2 and 3 & show "only editor" & put editor in focus) 5: if the shortcuts 1, 2 and 3 are blocked, then (unblock the shortcuts 1, 2 and 3 & show editor/sidebar & put editor in focus)

Explication Toggling the shortcut 1 or toggling the shortcut 2 is interesting, if one don't want to see the whole result, so if one don't want to see only the sidebar. The shortcut 1 is more for testing functionality change, like shortcuts on the webpage, while the shortcut 2 is more for testing content change. The starting point of shortcut 4 is editor/sidebar, else the shortcut 4 creates too much confusion.

Remark This report is based on the knowledge of https://github.com/xiota/geany-preview/issues/37, https://github.com/xiota/geany-preview/issues/38 and https://github.com/xiota/geany-preview/issues/40. The shortcut 2 exists already https://github.com/xiota/geanylua-scripts/tree/main/toggle-editor as stand-alone-version (,so without state file; the state file is mentioned in https://github.com/xiota/geany-preview/issues/37).

xiota commented 1 year ago

My understanding of what is possible now:

The problem with the above is that both the editor and sidebar can be made not visible at the same time. Also, I know how to change visibility in lua, but cannot change focus. So with that in mind... What about:

ralf3u commented 1 year ago

..., but cannot change focus.

This stands in contradiction to https://github.com/xiota/geany-preview/issues/5#issuecomment-1272538526.

xiota commented 1 year ago

You've opened up a lot of issues with long descriptions. It's easy to misread or lose track of what's going on. I don't know how to change focus in Lua, and if I had previously indicated otherwise, it was because I had forgotten or been mistaken about whether focus (or visibility) was the topic of discussion. You can probably point back to more posts where this or that was said, and it would just make everything even more complicated and easier to misread and lose track of.

While changing focus among components is possible to an extent in C/C++, the exact component you want to have focused is often missed (eg, issues you've opened where various navigation steps don't do what's expected). Arbitrary focus changes beyond what's already done (change focus between editor and preview) are outside the scope of the Preview plugin. The plugin is intended to preview markup, not replace the web browser.

If you can provide a clear, brief description of a few shortcuts for changing focus, I can think about adding them to the xi-tweaks or tweaks-ui plugins.


A problem with the proposed shortcuts is the names don't reflect the proposed actions. The first one is named "Toggle between only editor and editor/sidebar". What is toggled? Visibility? Focus? Something else? Consider the existing shortcut in Preview, "Toggle focus between editor and preview". From the name, it's clear that focus is being toggled.

Now looking at the proposed action:

if "only editor" is not shown, then (show "only editor" & put editor in focus), else (show editor/sidebar & put sidebar in focus)

The description is long and confusing. Is it any different from "Toggle focus between editor and sidebar" ?

The second, I would call just "Focus the editor".

The third, "Toggle sidebar visibility".

The fourth, maybe "Alternate between editor-only and sidebar-only views".

The fifth, maybe "Restore editor and sidebar views".

Considering that I don't know how to change focus with Lua, that leaves: "Toggle sidebar visibility" (already possible with built-in shortcut), "Alternate between editor-only and sidebar-only views", and "Restore editor and sidebar views". I've proposed to combine the latter two into a single shortcut that switches among views: editor-only, editor+sidebar, sidebar-only.

ralf3u commented 1 year ago

The first one is named "Toggle between only editor and editor/sidebar". What is toggled? Visibility? Focus? Something else?

Yes, you are right, the names are not clear. So, here the new names: Shortcut names 1: Toggle visibility/focus between editor-only and editor/sidebar 2: Toggle visibility between editor-only and editor/sidebar; editor stays in focus 3: Toggle visibility/focus between sidebar-only and editor/sidebar 4: Toggle visibility/focus between editor-only and sidebar-only 5: Exit "Toggle visibility/focus between editor-only and sidebar-only"

to 5: I prefer exit than restore

The description is long and confusing.

Sorry, I wrote the description in that way how I would program it in JavaScript.

So, I will try a new description for 1: editor/preview is visible; sometimes I don't want to be disturbed by the preview while coding, so I press shortcut 1; now only the editor is visible and the editor is in focus, so I can code without preview; then I want to test the functionality of the webpage, so I press again the shortcut 1; now editor/preview is visible and preview is in focus

Is it OK like this, so I would continue to describe the shortcuts 2, 3, 4 and 5 in that style?

I've proposed to combine the latter two into a single shortcut that switches among views: editor-only, editor+sidebar, sidebar-only.

Well, at the moment I'm not so interested in that shortcut.

Toggle editor visibility with a lua script. Toggle sidebar visibility with built-in geany shortcut. The problem with the above is that both the editor and sidebar can be made not visible at the same time.

Yes, that was the reason to create an own shortcut for the sidebar and to add a state file, what is mentioned in the report, to check first if the other shortcut is active or not. If it is active, then I think it needs first to be disabled.

xiota commented 1 year ago

I wrote the description in that way how I would program it in JavaScript.

Which is easier to understand?

Not only that, but the sort method I described is the least efficient. And there is a slight bug in the description that I didn't notice while writing it. People aren't computers. Explaining stuff like they are just makes it confusing.

editor/preview is visible; I don't want to be disturbed by the preview while coding, so I press shortcut 1; now only the editor is visible and the editor is in focus, so I can code without preview; then I want to test the functionality of the webpage, so I press again the shortcut 1; now editor/preview is visible and preview is in focus

That is better. But since I can't change focus with Lua, let's limit to visibility of components for now.

1: Toggle visibility between editor-only and editor+sidebar
2: ...
3: Toggle visibility between sidebar-only and editor+sidebar
4: Toggle visibility between editor-only and sidebar-only
5: Show both editor and sidebar

The names of 1, 3, 4 are self-explanatory. 2 is omitted because it is a variation of 1 with only focus changes.

5 could use some explanation. You use the word "exit", but that would mean you have to "enter" some sort of mode to use 1-4. I don't see why that should be the case. Introducing a mode is unnecessary and would probably complicate implementation.

I've proposed to combine the latter two into a single shortcut that switches among views: editor-only, editor+sidebar, sidebar-only.

Well, at the moment I'm not so interested in that shortcut.

I think a single shortcut to switch among all three views would be the most useful because it effectively provides the functionality of multiple shortcuts with reduced cognitive load.

that was the reason to create an own shortcut for the sidebar and to add a state file, what is mentioned in the report, to check first if the other shortcut is active or not. If it is active, then I think it needs first to be disabled.

Don't worry about the state file. That's an implementation detail that needs to be reworked.

xiota commented 1 year ago

I've added a set of scripts, switch-views. They don't do exactly what's described above, but you should try them before making them more complicated. Also updated the toggle-editor and auto-sidebar scripts so that they all use the same functions as the switch-views scripts.

ralf3u commented 1 year ago

1: Toggle visibility between editor-only and editor+sidebar 2: ... 3: Toggle visibility between sidebar-only and editor+sidebar 4: Toggle visibility between editor-only and sidebar-only 5: Show both editor and sidebar

Two things that I would change:

5 could use some explanation. You use the word "exit", but that would mean you have to "enter" some sort of mode to use 1-4.

Exit is only for leaving 4. I think it's better to have a clear separation of the shortcuts, else it creates confusion . So, let's say I press the shortcut 4 multiple times for many hours. I can imagine that after that, if I want to see editor/sidebar again, I have difficulties to find a way how to get out of this loop. The word "Exit" would be a good help in my head for leaving this loop.

I think a single shortcut to switch among all three views would be the most useful because it effectively provides the functionality of multiple shortcuts with reduced cognitive load.

Well, I think that a clear separation of shortcuts from shortcut 1 to shortcut 5 would be the most useful, even if the cognitive load will increase.

They don't do exactly what's described above, but you should try them before making them more complicated.

I will try them tomorrow and I will give you feedback.

xiota commented 1 year ago

I will try them tomorrow and I will give you feedback.

Thanks. It will be easier to modify something concrete. I just pushed an update. The shortcuts now are:

They can be renamed by making symlinks and editing hotkeys.cfg.

While coding the above, I just saw some Lua functions that might focus the editor (but not the sidebar). However, I want to finalize the visibility portion before trying to change focus.

instead of editor+sidebar, I would use of editor/sidebar

The problem is the name of the Lua shortcuts are based on the file name. Linux uses / as path separator, so it can't be used in the file name.

I can imagine that after that, if I want to see editor/sidebar again, I have difficulties to find a way how to get out of this loop.

The way to "exit" the loop is to use a different shortcut. Suppose you're using a shortcut that alternates views between editor-only and sidebar-only. Now you stop at sidebar-only and want to show both editor and sidebar. You can toggle editor visibility. Then both will be visible.

ralf3u commented 1 year ago

Just for documentation: The shortcuts are located in

https://github.com/xiota/geanylua-scripts/tree/main/switch-views and in https://github.com/xiota/geanylua-scripts/tree/main/toggle-editor

Before testing: Is there a reason why toggle-editor is not part of switch-views?

The way to "exit" the loop is to use a different shortcut. Suppose you're using a shortcut that alternates views between editor-only and sidebar-only. Now you stop at sidebar-only and want to show both editor and sidebar. You can toggle editor visibility. Then both will be visible.

Yes, that's right. That was also an option for me when developing the shortcuts in my head.

On the webpage https://github.com/xiota/geanylua-scripts/tree/main/switch-views, there is: switch-views-(editor-→-editor+sidebar-→-sidebar).lua I would not call it like this, because in the address bar of Firefox the + is not shown: switch-views-(editor-→-editor%2Bsidebar-→-sidebar).lua

Instead of a plus, one could use a hyphen.

xiota commented 1 year ago

Is there a reason why toggle-editor is not part of switch-views?

toggle-editor is included with switch-view. There's no need to use the separate toggle-editor. That folder exists because it was written first.

auto-sidebar is not included with switch-views, but they can be installed together. You would have to manually combine some of the event files.

in the address bar of Firefox the + is not shown

This is for Geany/Lua. Why does Firefox matter?

Instead of a plus, one could use a hyphen.

Hyphens are converted to spaces in the shortcut name.

ralf3u commented 1 year ago

toggle-editor is included with switch-view. There's no need to use the separate toggle-editor. That folder exists because it was written first.

The new toggle-editor is from the documents different than the toggle-editor that you offered some weeks ago. Can the old toggle-editor still be used? What is the difference between the old and the new toggle-editor?

This is for Geany/Lua. Why does Firefox matter?

It could be that other users do it like me: They let appear the code in RAW. Then they copy the code from the browser and paste the code in the editor. Then they save the document by giving a name. For the name they copy a part of the name of the URL to paste it in the save-dialog. Now if someone is not so careful, the person will not recognize that it is not the right name. If you think that a hyphen is not good, an alternative for the +-symbol could be: _and_.

I just tried all shortcuts. All shortcuts don't work. The message for the first shortcut:

geany_preview_error

For the other shortcuts it is nearly the same message. Only the names of the documents are different.

Just for information: Then I deleted all files from geanylua in order to paste toggle-editor. What works is toggle-editor from https://github.com/xiota/geanylua-scripts/tree/main/.

xiota commented 1 year ago

They let appear the code in RAW. Then they copy the code from the browser and paste the code in the editor. ... I just tried all shortcuts. All shortcuts don't work.

The shortcuts use symlinks. You can either recreate them with whatever name you want or install using the following steps:

ralf3u commented 1 year ago
cp ~/Downloads/geanylua-scripts-main.tar.gz /tmp
tar xz /tmp/main.tar.gz`.

First command did work, but not the second command, even not with this command: tar xz /tmp/geanylua-scripts-main.tar.gz I used right-click and Extract Here.

I copied the files into geanylua, but no shortcuts appear for Lua Scripts. In geanylua there are the folders auto-sidebar, column-markers and so on.

The shortcuts use symlinks. You can either recreate them with whatever name you want or ...

I have no idea what symlinks are. Could you please give an example how to recreate them?

xiota commented 1 year ago

Sorry, wrote the command wrong. Should be:

cd /tmp
tar xf geanylua-scripts-main.tar.gz

Copy the files from inside the switch-views folder into ~/.config/geany/plugins/geanylua/.

Symlinks are references to the real files. This way the keybinding can be renamed without affecting the actual script. They're created with the command:

ln -s [source] [link]

You can see which files are symlinks with ls -l. They will show [link] -> [source]. For example:

total 28
drwxr-sr-x 2 root root   41 2023-02-27 09:24:05  events
-rw-rw---- 1 root root  187 2023-02-27 17:11:46  hotkeys.cfg
lrwxrwxrwx 1 root root   23 2023-02-27 17:12:15  show-both-editor-and-sidebar.lua -> show-editor-sidebar.lua
-rw-rw---- 1 root root  139 2023-02-27 09:11:59  show-editor-sidebar.lua
lrwxrwxrwx 1 root root   18 2023-02-27 17:09:43 'switch-views-(editor-→-editor+sidebar-→-sidebar).lua' -> switch-views-3.lua
lrwxrwxrwx 1 root root   18 2023-02-27 17:09:43 'switch-views-(editor-↔-sidebar).lua' -> switch-views-2.lua
-rw-rw---- 1 root root  396 2023-02-27 17:05:57  switch-views-2.lua
-rw-rw---- 1 root root  377 2023-02-27 09:24:00  switch-views-3.lua
lrwxrwxrwx 1 root root   17 2023-02-27 17:09:44  toggle-editor-visibility.lua -> toggle-editor.lua
-rw-rw---- 1 root root  389 2023-02-27 09:23:59  toggle-editor.lua
-rw-rw---- 1 root root 2030 2023-02-27 10:04:43  toggle-functions.lua
lrwxrwxrwx 1 root root   18 2023-02-27 17:09:44  toggle-sidebar-visibility.lua -> toggle-sidebar.lua
-rw-rw---- 1 root root  396 2023-02-27 09:23:57  toggle-sidebar.lua
ralf3u commented 1 year ago

Oh, that's really really cool!!!!!

I like specially switch-views-(editor-↔-sidebar).lua. It's so smooth!! It feels better than I expected! The shortcuts are a big release for me, because now I could use Geany Preview also on small displays. I still don't see a use for me in the shortcut switch-views-(editor-→-editor+sidebar-→-sidebar).lua, but maybe somebody else will like it. I think that it is better to have more options than less options.

As far as the shortcuts concerned, I couldn't find bugs, so it's perfect.

Issues with the scroll-bar within the sidebar I can see on three shortcuts the scroll-bar in the sidebar for a part of a second. 1 toggle-editor-visibility.lua If editor and sidebar are both visible, and if I press the shortcut, then there is the scroll-bar in the sidebar for a part of a second. I can see it every second press. I can see it also when holding the press. 2 switch-views-(editor-↔-sidebar).lua If editor and sidebar are both visible, and if I press the shortcut, then I can see only in the second press the scroll-bar in the sidebar for a part of a second. So that means that then if I hold the press, then the scroll-bar in the sidebar is not visible. 3 switch-views-(editor-→-editor+sidebar-→-sidebar).lua If editor and sidebar are both visible, and if I press the shortcut, then I can see the scroll-bar in the sidebar for a part of a second. I can see it every third press. I can see it also when holding the press.

Focus If the focus-part would work, then this would be just amazing. Because the focus-part does not work, there are a lot of issues. Here are two of them: 1 If editor and sidebar are both visible, and if I press the shortcut switch-views-(editor-↔-sidebar).lua, then the tab-title is in focus, what means that, if I press the left-arrow-key, then the content of the Preview-tab will not be visible any more, but the content of the tab what is on the left side of the Preview-tab. 2 If editor and sidebar are both visible, and if I press 3x the shortcut switch-views-(editor-↔-sidebar).lua, and then, if I press the down-arrow-key on the keyboard, and then if I press the left-arrow-key on the keyboard, then in the editor the tab on the left side will be in focus.

Based on the number of documents and code, I can imagine that you worked a lot for the realization of the shortcuts. Thank you so much for the shortcuts.

xiota commented 1 year ago

I can see ... the scroll-bar in the sidebar for a part of a second.

This is out of my control.

Focus

There is potential to focus the editor, but not the sidebar.

If editor and sidebar are both visible, and if I press the shortcut switch-views-(editor-left_right_arrow-sidebar).lua, then the tab-title is in focus, what means that, if I press the left-arrow-key, then the content of the Preview-tab will not be visible any more, but the content of the tab what is on the left side of the Preview-tab.

Are you making the editor invisible? Then the focus goes to the sidebar tabs? As far as I can tell, this may not be fixable.

If editor and sidebar are both visible, and if I press 3x the shortcut switch-views-(editor-left_right_arrow-sidebar).lua, and then, if I press the down-arrow-key on the keyboard, and then if I press the left-arrow-key on the keyboard, then in the editor the tab on the left side will be in focus.

This might be fixable by focusing the editor. I plan to test this weekend.

Thank you so much for the shortcuts.

You're welcome.

xiota commented 1 year ago

I just did some testing.

ralf3u commented 1 year ago

There's somewhere a bug. I deleted all files in geanylua. Now if a HTML-document is in focus and if I let appear the sidebar through the menu bar (View), then the editor is not there any more. Only the sidebar is visible. Normally editor and sidebar should be visible side by side. I think it has maybe to do something with this: I deleted the swich-views-files at the wrong moment (maybe Geany was open, but I don't think so), when only the sidebar was visible. What do you think?

ralf3u commented 1 year ago

I just pasted all switch-files in geanylua. All Geanylua shortcuts work, but not correctly. Maybe it has to do with my last comment and with the created file toggle_sidebar-hidden?

ralf3u commented 1 year ago

I can't see any more editor and sidebar side by side, even if the geanylua-file is empty, even after a restart of the computer, even after activating the sidebar.

xiota commented 1 year ago

Maybe check events/init.lua ?

Are you using the lua toggle-sidebar and not the built-in toggle sidebar?

Are you copy/pasting from the webpage or copying the files from the tar.gz? Make sure you use the tar.gz, not the zip because zip may not support symlinks. If the problem is the symlinks, I may change it to not use symlinks.

ralf3u commented 1 year ago

Are you using the lua toggle-sidebar and not the built-in toggle sidebar?

In the Preferences of Geany in Keybindings there is no shortcut for Toggle Sidebar.

Are you copy/pasting from the webpage or copying the files from the tar.gz? Make sure you use the tar.gz, not the zip because zip may not support symlinks. If the problem is the symlinks, I may change it to not use symlinks.

I did this:

cp ~/Downloads/geanylua-scripts-main.tar.gz /tmp
cd /tmp
tar xf geanylua-scripts-main.tar.gz

Maybe check events/init.lua ?


-- load and initialize toggle_editor and toggle_sidebar scripts
local lua_path = geany.appinfo().scriptdir..geany.dirsep

--[[ options: restore - startup with the last editor state hide - startup with editor hidden *show - startup with editor visible toggle - startup with the editor toggled from the last editor state --]]

editor_start = "show" sidebar_start = "show"

toggle_editor = loadfile(lua_path.."toggle-editor.lua") toggle_editor()

toggle_sidebar = loadfile(lua_path.."toggle-sidebar.lua") toggle_sidebar()



I deleted all files from the geanylua-file to test the old auto-sidebar. Also with the old auto-sidebar I can't see any more editor and sidebar side by side.
xiota commented 1 year ago

In the Preferences of Geany in Keybindings there is no shortcut for Toggle Sidebar.

Preferences / Keybindings / Lua Script / Toggle sidebar visibility

I did this...

Then to complete installation, open /tmp/geanylua-scripts-main in your file manager and copy the desired files into ~/.config/geany/plugins/geanylua.

I can't see any more editor and sidebar side by side

Editor state should be restored on Geany restart.

Toolbar needs to be toggled on from Geany perspective. Menubar / View / Show Sidebar.

ralf3u commented 1 year ago

Preferences / Keybindings / Lua Script / Toggle sidebar visibility

Yes, there is a shortcut. It is F4. If I toggle F4, then editor is shown or sidebar is shown, but not both at the same time. If I press the shortcut "Show both editor and sidebar", then there is only the sidebar, no matter how often I press the shortcut.

Then to complete installation, open /tmp/geanylua-scripts-main in your file manager and copy the desired files into ~/.config/geany/plugins/geanylua.

Yes, this is what I did.

Menubar / View / Show Sidebar.

Yes, this is what I did.

ralf3u commented 1 year ago

Maybe this could help to find a solution: If I deactivate the plugin Geany Preview in the Plugin Manager, and then, if I activate the Show Sidebar in View in the menu-bar, then the editor disappears.

ralf3u commented 1 year ago

What I did today: I tested the switch-views, then deleted the files, then I tested the old auto-sidebar, then I deleted the files, then I wanted to test again the switch-views by pasting the files. And then the bug was there.

Just for information: I will continue tomorrow. There is no hurry to fix this problem the next days.

ralf3u commented 1 year ago

I'm so sorry. The line (between editor and sidebar) was completely at the left, nearly invisible. I have no idea how this happened. So, everything is fine. Again: I'm so sorry. Thank you for your help.

ralf3u commented 1 year ago

Unable to replicate your focus issues. When I press left/right/down, keyboard focus moves into the editing area. The editor tabs do not change.

I can not reproduce 1. I don't know why. But I can reproduce 2 in that way:

If editor and sidebar are both visible at the same time, then I click in the middle of the content area of the editor, and if I press 3x the shortcut Switch views (editor-sidebar) then, if I press the down-arrow-key on the keyboard, and then if I press the left-arrow-key on the keyboard, then in the editor the tab on the left side will be in focus.

xiota commented 1 year ago

The line (between editor and sidebar) was completely at the left, nearly invisible. I have no idea how this happened. So, everything is fine. Again: I'm so sorry. Thank you for your help.

I was thinking about suggesting you check for that. Glad you found it. I think Geany has some bugs related to sizing the panels when the window is resized/maximized. I think there's already a bug report, but it's unlikely to be fixed any time soon because the interaction between the components is complicated and it's hard to change anything without breaking something else.

But I can reproduce 2 in that way...

The problem seems to be related to message window visibility. I have the message window visible. When I hide it, I am able to replicate your issue. Since I cannot change focus with Lua, a workaround would be to show the message window (menubar / View / Show Message Window) and resize it so that it's hidden.

ralf3u commented 1 year ago

I think Geany has some bugs related to sizing the panels when the window is resized/maximized.

Aaahh ...! Yes, resize! That explains why the line between editor and sidebar disappeared. I was wondering because I didn't change the width of the editor. I could reproduce the issue: only-editor-view, then window 50% (width that starts on the left side), close Geany, delete all switch-files in geanylua, reopen Geany, maximize Geany, close Geany, paste again the switch-files in geanylua, reopen Geany

I think there's already a bug report, ...

For documentation reasons, do you have the issue number of the bug?

If editor and sidebar are both visible at the same time, then I click in the middle of the content area of the editor, and if I press 3x the shortcut Switch views (editor-sidebar) then, if I press the down-arrow-key on the keyboard, and then if I press the left-arrow-key on the keyboard, then in the editor the tab on the left side will be in focus.

The problem seems to be related to message window visibility. I have the message window visible. When I hide it, I am able to replicate your issue. Since I cannot change focus with Lua, a workaround would be to show the message window (menu-bar / View / Show Message Window) and resize it so that it's hidden.

Well, at the moment this issue is not so important for me. I handle the problem like this: after switching: I press 1x the arrow-right-key, so that the cursor is visible in the editor.

To the focus problem 1 mentioned in https://github.com/xiota/geanylua-scripts/issues/7#issuecomment-1451950479:

If editor and sidebar are both visible, and if I press the shortcut switch-views-(editor-left_right_arrow-sidebar).lua, then the tab-title is in focus, what means that, if I press the left-arrow-key, then the content of the Preview-tab will not be visible any more, but the content of the tab what is on the left side of the Preview-tab.

Sorry, I recognized that I did some mistakes, so here is the correction: If editor and sidebar are both visible, and if I click in the middle of the editor, and if I press 1x the shortcut Toggle editor visibility, then if I press 1x first the bottom-arrow-key and then 1x the left-arrow-key, then the content of the Preview-tab will not be visible any more, but the content of the tab what is on the left side of the Preview-tab. To avoid the issue, I press 2x the bottom-arrow-key, so that the content of the Preview-tab is in focus. So, in total I handle the focus problem like this: For only-editor: If the cursor is not visible, I press 1x the arrow-right-key. For only-sidebar: If I want to put the content of the Preview-tab in focus I press 2x the bottom-arrow-key.

I can see ... the scroll-bar in the sidebar for a part of a second.

This is out of my control.

The scroll-bar that is visible for a part of the second is more on the left side, although my scroll-bar of the editor is more on the right side when editor and sidebar are both visible (I use the editor on the left side, while the sidebar is on the right side). That's strange. From the color of the scroll-bar and the length of the inside of the scroll-bar it looks like it is the same scroll-bar like the scroll-bar of the sidebar that is located completely on the right side of the window. That's also strange. Is that OK if I open a new issue at Geany, or you want to open it?

Just for documentation: I tested the shortcuts with an HTML-document and with a Fountain-document.

Before closing this issue I would like to test the shortcuts with the new auto-sidebar what I will do in the next days. I will leave a feedback here.

xiota commented 1 year ago

I think Geany has some bugs related to sizing the panels when the window is resized/maximized. I think there's already a bug report...

For documentation reasons, do you have the issue number of the bug?

No, but searching Geany issues for "resize" shows multiple related results.

... here is the correction...

Okay. I am able to replicate that. Unfortunately, focus issues are out of my control with Lua.

... scroll-bar that is visible for a part of the second...

The problem is probably related to the timing of screen updates and hiding widgets along with the speed of your computer. It's just a graphical glitch, and I don't think there is anything that can be done about it. This script hides things in ways that Geany wasn't necessarily designed to handle. This should not be reported to Geany unless it can be replicated using only built-in Geany functions.

I would like to test the shortcuts with the new auto-sidebar... I will leave a feedback here.

Will look forward to it.

xiota commented 1 year ago

@ralf3u Please don't link Geany issues here or vice versa because some Geany devs have expressed irritation in the past. It's fine if you can refer to them without GitHub creating the link.

If you read the comments at the issue you had linked, you'll see that elextr had stated, "Even if it did set the notebook tab GTK does not say it grabs focus, so the Geanylua doc... is wrong anyway."

ralf3u commented 1 year ago

The lua functions that I thought might change widget focus don't seem to work. I'm going to open a bug report at geany/geany-plugins.

Please don't link Geany issues here or vice versa because some Geany devs have expressed irritation in the past. It's fine if you can refer to them without GitHub creating the link.

OK. So, for reasons of documentation I mention the issue number of the bug report at geany/geany-plugins: 1229.

If you read the comments at the issue you had linked, you'll see that elextr had stated, "Even if it did set the notebook tab GTK does not say it grabs focus, so the Geanylua doc... is wrong anyway."

Sorry, but I don't understand anything of what is written in the whole issue. So, is the report just for the focus in the editor or is the report also for the focus in the sidebar? And is there a conclusion, like even if the GeanyLua would work correctly, it could have no effect on the focus?

xiota commented 1 year ago

I don't understand anything of what is written in the whole issue.

The report is that geany.activate doesn't work. geany.activate calls some C code that switches tab. The documentation for geany.activate says it also changes focus. But GTK documentation of the underlying C function doesn't mention focus. So changing focus is a possible, but not guaranteed, side effect.

... even if the GeanyLua would work correctly, it could have no effect on the focus?

Even if the function works, it could have no effect on focus, or it could have an undesirable effect on focus. I've fixed the issue and opened a PR geany/geany-plugins/1234. I haven't tested, but suspect focus will not do what you want.

ralf3u commented 1 year ago

I've fixed the issue and opened a PR geany/geany-plugins/1234. I haven't tested, but suspect focus will not do what you want.

Thank you so much for your work and for the attempt to fix the focus problem.

ralf3u commented 1 year ago

Correct me if I'm wrong. In the preferences of Geany, in the Action Focus, there are two shortcuts: Switch to Editor, and Swich to Sidebar. They work absolutely perfect. In both shortcuts the content-area of the tab is in focus. So, what about to copy and paste them formula in Geanylua for all shortcuts?

xiota commented 1 year ago

Thanks for pointing those out. I just noticed Lua has access to those functions. The commands are (writing here for future reference):

geany.keycmd("FOCUS_EDITOR")
geany.keycmd("FOCUS_SIDEBAR")

I'll look at them more closely later.

ralf3u commented 1 year ago

I'll look at them more closely later.

Would it be possible to solve at the same time #8?

ralf3u commented 1 year ago

My suggestions for the names and the orders of the shortcuts:

I would not mention visibility and I would not mention focus, except in one case, else it makes everything complicated. I would not write the exit-shortcut in the middle of the list, but at the end of the list, because it is a kind of Reset for all shortcuts.

My perfect list would be:

Switch editor ↔ editor+sidebar Switch editor ↔ editor+sidebar; focus in editor Switch sidebar ↔ editor+sidebar Switch editor ↔ sidebar Switch editor → editor+sidebar → sidebar Show editor+sidebar

Update: I recognized that Switch editor ↔ editor+sidebar; focus stays in the editor is too long in the Preferences-window; that is why I changed it to Switch editor ↔ editor+sidebar; focus in editor

xiota commented 1 year ago

... scroll-bar that is visible for a part of the second...

Are you still using an Ubuntu variant? Which version? I just built a version of geany-plugins where GeanyLua plugin has some bug fixes and uses LuaJIT instead of Lua 5.1. LuaJIT is supposed to perform better than Lua 5.1. Since you've mentioned that your computer is slow, I was wondering if you would try if to see if you notice any performance difference. I would also like to know if there is any effect on the sidebar glitch.

The plugins are on the PPA, available for 22.04, 22.10, 23.04. After the rebuilt plugins are installed, Geany would have to be restarted. If the plugin is not active after restart, it may need to be reloaded in the Plugin Manager, and Geany restarted a second time.

https://github.com/xiota/geanylua-scripts/issues/8

Okay.

My perfect list would be ...

I'll reorganize / rename the files later, maybe when I look at the focus issues.

ralf3u commented 1 year ago

Are you still using an Ubuntu variant? Which version?

Lubuntu 22.04.1, on an other computer it is Lubuntu 22.10.

Since you've mentioned that your computer is slow ...

One computer is now fast (intel i3 11th generation 16GB RAM; Intel UHD Graphics; Lubuntu 22.04.1). I saw the sidebar glitch on the fast computer.

The plugins are on the PPA, available for 22.04, 22.10, 23.04.

I just do sudo apt update and then sudo apt dist-upgrade. Is that correct?

ralf3u commented 1 year ago

I just do sudo apt update and then sudo apt dist-upgrade.

Then I restarted Geany. The sidebar glitch is still there. No difference. On the slow computer I could install an other system for testing the sidebar glitch on an other system, if you want. Just tell me which kind of system.

xiota commented 1 year ago

The sidebar glitch is still there. No difference.

I didn't expect there would be any difference. Just wanted to try.

Don't worry about the graphical glitch anymore. I think there's nothing reasonable that can be done about it. Would probably require refactoring the GTK toolkit so that components can all be hidden/shown and blitted to the screen within a single frame.

On the slow computer...

Do Lua scripts seem any faster in general on the slow computer? Or no difference?

ralf3u commented 1 year ago

I would not call it sidebar-glitch, but the-scrollbar-of-the-sidebar-glitch. On the slow computer it is also there, without difference.

Today I looked closely at the shortcut Switch sidebar ↔ editor+sidebar. Then I understood what is happening: Let's assume that the sidebar is on the right side, with a width of 30%. In the moment where I press the button, the sidebar is moving completely to the left side of the Geany-window, what means that the scrollbar of the sidebar is not any more completely on the right side of the Geany-window, but 30% from the left side of the Geany-window. That is also happening not only with the scrollbar of the sidebar, but also with the content of the tab of the sidebar, so for example also the text is moving from the right side to the left side. Then the scrollbar disappears and then the content of the tab will be stretched to the right border of the Geany window. That is also why sometimes I can not only see the scrollbar for a part of a second but also text at the left bottom for a part of a second before the text will be stretched to the right side.

I made some tests with the corresponding shortcut in the Geany-built-shortcut Toggle Sidebar. There I can't see the-scrollbar-of-the-sidebar-glitch, even not when I hold the shortcut. The question is: Why does the issue exists in the Geanylua-shortcut but not in the Geany-built-shortcut, although both should do exactly the same?

Could you please tell me what exactly is happening, when the Geanylua-shortcut is pressed in slow motion, so step by step, so I can understand every single step? Maybe I could have some ideas to solve the issue.

If in the sidebar there is no scrollbar, because the text is short, then the issue does not exist. Till now we are talking about the computers I use, but do you see also the-scrollbar-of-the-sidebar-glitch on your computer?

xiota commented 1 year ago

Are you able to make a video and temporarily post it on youtube or somewhere, so I can see what is happening?

ralf3u commented 1 year ago

Sorry, in my last comment I noticed the wrong shortcut name. It is not the shortcut Switch editor ↔ editor+sidebar. It is the shortcut Switch sidebar ↔ editor+sidebar. I just did the correction in the comment.

Are you able to make a video and temporarily post it on youtube or somewhere, so I can see what is happening?

Today I will try to find a way.

ralf3u commented 1 year ago

I just made a test with the old toggle-editor version from last year. The scrollbar-of-the-sidebar-glitch is also there. It was mentioned for the first time in https://github.com/xiota/geanylua-scripts/issues/4#issuecomment-1152776068 in point 3.

xiota commented 1 year ago

From the video, looks similar to what I imagined. Doesn't happen on my computer. Are any other plugins active besides Preview and GeanyLua/switch-views? Do you see the same thing with the built-in toggle sidebar?

ralf3u commented 1 year ago

Are any other plugins active besides Preview and GeanyLua/switch-views?

No.

>Do you see the same thing with the built-in toggle sidebar?

No.

xiota commented 1 year ago

I just updated switch views. Files are reorganized, so please clear out the plugins/geanylua folder. Then redownload and unzip the new files.