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

Shortcuts for Geany Preview #7

Closed
ralf3u opened this issue Feb 26, 2023 · 112 comments
Closed

Shortcuts for Geany Preview #7

ralf3u opened this issue Feb 26, 2023 · 112 comments

Comments

@ralf3u
Copy link

ralf3u commented Feb 26, 2023

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 xiota/geany-preview#37, xiota/geany-preview#38 and xiota/geany-preview#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 xiota/geany-preview#37).

@xiota
Copy link
Owner

xiota commented Feb 26, 2023

My understanding of what is possible now:

  • 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. Also, I know how to change visibility in lua, but cannot change focus. So with that in mind... What about:

  • If only editor is visible (no visible sidebar) and toggle editor key is pressed, then ... do nothing? (Hide editor only when sidebar is visible.)
  • If only sidebar is visible (no visible editor) and toggle sidebar key is pressed, then ... do nothing? (Hide sidebar only when editor is visible.)
  • New shortcut that changes views. Some possibilities:
    • Editor only -> Editor + Sidebar -> Sidebar only -> Editor + Sidebar -> Editor only -> ...
    • Editor only -> Editor + Sidebar -> Sidebar only -> Editor only -> ...

@ralf3u
Copy link
Author

ralf3u commented Feb 27, 2023

..., but cannot change focus.

This stands in contradiction to xiota/geany-tab-style#6.

@xiota
Copy link
Owner

xiota commented Feb 27, 2023

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
Copy link
Author

ralf3u commented Feb 27, 2023

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
Copy link
Owner

xiota commented Feb 27, 2023

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

Which is easier to understand?

  • Compare the first item in the list with the next. If they are not in alphabetical order, swap them. Then compare the next two items in the list. Swap them if they are not in alphabetical order. Continue through the rest of the list in a similar fashion. Now repeat the process starting from the second item in the list. Then again for the third. And so on until the entire process has been completed for every item in the list.
  • Sort the list in alphabetical order.

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
Copy link
Owner

xiota commented Feb 27, 2023

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
Copy link
Author

ralf3u commented Feb 27, 2023

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:

  • 1 & 3: instead of editor+sidebar, I would use of editor/sidebar because it's compact; the slash reminds me of the line between the editor and the sidebar
  • 5: instead of Show both editor and sidebar, I would prefer Exit "Toggle visibility between editor-only and sidebar-only"

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
Copy link
Owner

xiota commented Feb 28, 2023

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:

  • Toggle editor visibility (effectively toggles between editor+sidebar and sidebar-only)
  • Toggle sidebar visibility (effectively toggles between editor+sidebar and editor-only)
  • Show both editor and sidebar
  • Switch views (editor → editor+sidebar → sidebar)
  • Switch views (editor ↔ sidebar)

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
Copy link
Author

ralf3u commented Feb 28, 2023

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
Copy link
Owner

xiota commented Feb 28, 2023

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
Copy link
Author

ralf3u commented Mar 1, 2023

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
Copy link
Owner

xiota commented Mar 1, 2023

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
Copy link
Author

ralf3u commented Mar 1, 2023

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
Copy link
Owner

xiota commented Mar 1, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Owner

xiota commented Mar 2, 2023

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
Copy link
Owner

xiota commented Mar 2, 2023

I just did some testing.

  • 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.
  • 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.

@ralf3u
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Owner

xiota commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Owner

xiota commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 2, 2023

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
Copy link
Owner

xiota commented Mar 2, 2023

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
Copy link
Author

ralf3u commented Mar 3, 2023

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 #7 (comment):

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
Copy link
Owner

xiota commented May 1, 2023

./geany -c ../config

  • ./geany – Run geany from the file located in the current directory. Otherwise, the copy of geany installed in the PATH (most likely /usr/bin/geany) would be run.
  • -c ../config – Use custom config file located at ../config; The purpose is to test with a new config without modifying an existing config.

Run geany --help to see more options.

@ralf3u
Copy link
Author

ralf3u commented May 1, 2023

If I open Geany from the home-file, then it is 1.39. If I open it from /usr/bin/geany then it is 1.38. Yesterday I just installed the nightly tarball of Geany and nothing else.
So, is this normal that I have two different versions although I downloaded only one file?

I tested the scintilla-bug in 1.38 that I downloaded yesterday and the issue is not there any more although the issue was in 1.38.
How can it be? Do you have an explication?

@xiota
Copy link
Owner

xiota commented May 1, 2023

If I open Geany from the home-file, then it is 1.39. If I open it from /usr/bin/geany then it is 1.38.

You must have two different versions in different locations. The package manager usually installs to /usr/bin. The other one depends on how you installed. Could be /usr/local/bin/. Might be somewhere else though.

@ralf3u
Copy link
Author

ralf3u commented May 9, 2023

On Lubuntu 23.04 I tried to install Preview on the nightly tarball of Geany with those lines:

sudo add-apt-repository ppa:xiota/geany-plugins
sudo apt-get update
sudo apt-get install geany-plugin-preview

like it is described on https://github.com/xiota/geany-preview.

The result in the terminal for the last line is:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 geany-plugin-preview : Depends: libcmark-gfm0 but it is not installable or
                                 libcmark-gfm0.29.0.gfm.3 but it is not installable
                        Depends: libcmark-gfm-extensions0 but it is not installable or
                                 libcmark-gfm-extensions0.29.0.gfm.3 but it is not installable
E: Unable to correct problems, you have held broken packages.

Did I make something wrong?

@xiota
Copy link
Owner

xiota commented May 9, 2023

According to cmark-gfm, the version in the repository is 0.29.0.gfm.6, but the command you're running is trying to install 0.29.0.gfm.3.

Try updating the repository and upgrading installed packages before installing the plugin:

sudo apt update
sudo apt upgrade

Let me know if that helps or if you still have problems.

@ralf3u
Copy link
Author

ralf3u commented May 9, 2023

Let me know if that helps or if you still have problems.

The answer is:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 geany-plugin-preview : Depends: libcmark-gfm0 but it is not installable or
                                 libcmark-gfm0.29.0.gfm.3 but it is not installable
                        Depends: libcmark-gfm-extensions0 but it is not installable or
                                 libcmark-gfm-extensions0.29.0.gfm.3 but it is not installable
E: Unable to correct problems, you have held broken packages.

@xiota
Copy link
Owner

xiota commented May 9, 2023

I'll double check the PPA. Can you also check files in /etc/apt/sources.list.d to make sure they all refer to lunar?

@ralf3u
Copy link
Author

ralf3u commented May 9, 2023

content of the document xiota-ubuntu-geany-plugins-lunar.list:

deb https://ppa.launchpadcontent.net/xiota/geany-plugins/ubuntu/ lunar main
# deb-src https://ppa.launchpadcontent.net/xiota/geany-plugins/ubuntu/ lunar main

@xiota
Copy link
Owner

xiota commented May 9, 2023

I'm forcing an update of the lunar package on the PPA. As usual, takes some hours to build and update. In case it doesn't work, can you paste the output of apt search libcmark-gfm ?

@ralf3u
Copy link
Author

ralf3u commented May 9, 2023

Does not work either.

...output of apt search libcmark-gfm

Sorting... Done
Full Text Search... Done
libcmark-gfm-dev/lunar 0.29.0.gfm.6-6 amd64
  CommonMark GitHub flavor gfm library dev files

libcmark-gfm-extensions-dev/lunar 0.29.0.gfm.6-6 amd64
  CommonMark GitHub flavor gfm extensions library dev files

libcmark-gfm-extensions0.29.0.gfm.6/lunar 0.29.0.gfm.6-6 amd64
  CommonMark GitHub flavor gfm extension library

libcmark-gfm0.29.0.gfm.6/lunar 0.29.0.gfm.6-6 amd64
  CommonMark GitHub flavor gfm library

libghc-cmark-gfm-dev/lunar 0.2.5+ds1-1build2 amd64
  fast, accurate GitHub Flavored Markdown parser and renderer

libghc-cmark-gfm-doc/lunar,lunar 0.2.5+ds1-1build2 all
  fast, accurate GitHub Flavored Markdown parser and renderer; documentation

libghc-cmark-gfm-prof/lunar 0.2.5+ds1-1build2 amd64
  fast, accurate GitHub Flavored Markdown parser and renderer; profiling libraries

@xiota
Copy link
Owner

xiota commented May 10, 2023

Pushed another update. Let me know if it works after it rebuilds.

@ralf3u
Copy link
Author

ralf3u commented May 10, 2023

Let me know if it works after it rebuilds.

It Works.

Did you try to solve the issue with the auto-sidebar?

@ralf3u
Copy link
Author

ralf3u commented May 16, 2023

Maybe you missed my last message, and that is why I ask again the question:

Did you try to solve the issue with the auto-sidebar?

@xiota
Copy link
Owner

xiota commented May 16, 2023

Sorry, lost track of the message and forgot to respond. The script works fine on my computer.

Think the problem may be the Lua libary that the plugin is using. Pushing an update to the PPA to use a different library.

@ralf3u
Copy link
Author

ralf3u commented May 17, 2023

It works, but when opening Geany, this is the message:

geany_auto-sidebar

This is the download-link that I used today:
https://github.com/xiota/geanylua-scripts/archive/refs/heads/main.zip

In the file geanylua there is only the content of the file auto-sidebar.
There is a kind of similarity to the error-message of last time (see #7 (comment)).
The auto-sidebar that you programed about 1,5 years ago works still perfect, without any error-message.

@ralf3u
Copy link
Author

ralf3u commented May 17, 2023

If I add switch-views to geanylua then this is the error-message:

geany_auto-sidebar_2

Switch Views works, auto-sidebar works, but after every restart of Geany there is the error-message.

@xiota
Copy link
Owner

xiota commented May 17, 2023

The script is trying to access document properties (filetype) before the document has been created. Remove reference to auto-sidebar from init.lua. I will update the scripts.

@ralf3u
Copy link
Author

ralf3u commented May 17, 2023

I will update the scripts.

The scripts work now without an error-message. Thank you so much.

@ralf3u
Copy link
Author

ralf3u commented May 17, 2023

Is there a reason why auto-sidebar does not work any more with fountain-documents?
This is what I added:

  ["Fountain"] = sidebar_restore,

@xiota
Copy link
Owner

xiota commented May 17, 2023

Is this a new install of Geany? You have to add the Fountain filetype. See xiota/geany-tab-style#6. I should probably some of add that info to the docs for the Preview plugin.

@ralf3u
Copy link
Author

ralf3u commented May 17, 2023

Yes! That helped me:
#5 (comment)
Thanks.

@ralf3u
Copy link
Author

ralf3u commented May 18, 2023

#7 (comment):

I have pending pull requests to fix geany.activate and geany.keygrab

For reasons of documentation: The issue-numbers at geany-plugins are 1229, 1234, 1230 and 1236.

Did I understand it right, that if the fixes will be integrated in geany-plugins, then the focus feature should work correctly when using the shortcuts?
The four issues mentioned above are still open. Why the fixes are still not integrated in geany-plugins?

@xiota
Copy link
Owner

xiota commented May 18, 2023

Why the fixes are still not integrated in geany-plugins?

Maybe someday. It's up to the maintainers. Even if the maintainers accepted them, they wouldn't be seen in any distros until the next release, which could be a year or more away.

If you're using the plugins from my PPA, the fixes should already included.

the focus feature

Depends on which "focus feature" you're referring to. Focus (on a specific widget, like the preview pane) is a separate issue. activate allows changing the document tab from a script. I think in some cases, it moves focus to the editor. I don't remember because I haven't looked at it since I fixed it.

I don't recall using keygrab in any of my scripts. I just fixed it because I could.

@ralf3u
Copy link
Author

ralf3u commented May 18, 2023

So, the both fixes don't solve the focus-feature of the preview-pane?

@xiota
Copy link
Owner

xiota commented May 18, 2023

So, the both fixes don't solve the focus-feature of the preview-pane?

activate potentially moves keyboard focus to the editor. It doesn't help with the preview pane focus issues.

@ralf3u
Copy link
Author

ralf3u commented May 18, 2023

What about the idea to fork Geanylua...

Too much work to maintain a fork just for this. Ideally the existing focus function in GeanyLua would be fixed, but I have other PRs with bug fixes pending that I would want to wait for before doing anything else with it.

The last sentence sounds for me as you have an idea how to solve the focus-issue. Am I right?

@xiota
Copy link
Owner

xiota commented May 18, 2023

The last sentence sounds for me as you have an idea how to solve the focus-issue. Am I right?

No. I don't know how to fix it. I feel like it would be difficult, maybe not even possible. So I don't even want to look at it, especially since I have PRs that haven't been merged yet, even though they fix significant bugs.

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