xiota / geany-preview

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

when sidebar is in focus: visible effect of the tab #5

Closed ralf3u closed 5 months ago

ralf3u commented 2 years ago

It happened to me already many times that I lost the orientation when working with shortcuts in Geany because I didn't know which pane is now in focus: editor or sidebar.

Let's imagine this situation: A document, that is already saved, is longer than the visible area. The current line is on top of the document. With the mouse the user is scrolling down, so that the current line is not any more in the visible area. Now the user is distracted by something. Then the user looks back on the screen. What is in focus? Is it the editor or Preview? There is no hint at all. Now let's imagine the same situation with visible effect of the tab when sidebar is in focus. Now there is a hint: Because the Preview-tab has no visible effect, it means that the editor is in focus.

So, that were my thoughts today: An other background-color for the tab would be good. Or an other font-color. Or what about a kind of star-symbol after the word Preview? A symbol after the word Preview could be interesting but I don't like when there is an addition, because it is not minimalist. What if the font-color is the same font-color like the font-color of the unsaved tab in the editor? Yes, but in Preview there is nothing like "unsaved". So there should be different colors for a clear separation. So, what about if the font-color would be in green? Hey, that sounds good! A kind of soft green color. The green color reminds me of a traffic light when people are crossing the street. A color reminds me of children, because children like to play with colors. Colors reminds me also of a toy to play. Yes, and coding is playing. All those point of views make so much sense. So I have a good feeling for the green color as font-color when the Preview-tab is in focus. But maybe I will not like the effect.

Is there a possibility to change the font-color of the Preview-tab when it is in focus? If so, where can I change the settings?

Nevertheless I think that the idea of a green font-color is a good idea. The Preview-tab would have then, when it is in focus, some kind of smiling, warm and lovely character. Or what about this idea: When Preview-tab is in focus, then the font-color should be green by default, and at the same time giving the users the possibility in a script to change the font-color?

What about #46af41?

46af41: I found this color today by pressing in the color spectrum in Gimp.

I tested the color in the tab of the editor for unsaved tab. I like it.

On one side there is the red color for the unsaved tab in the editor, and on the other side there would be the green color when Preview is in focus or when other tabs of the sidebar are in focus. It would be some kind of nice color game that fits together.

xiota commented 2 years ago

@ralf3u

I lost the orientation when working with shortcuts in Geany because I didn't know which pane is now in focus: editor or sidebar. What is in focus? Is it the editor or Preview? There is no hint at all.

The editor highlights the current line. If no line is highlighted, the editor does not have focus.

You can change the color to make it easier to see. Color scheme files are in ~/.config/geany/colorschemes. Look for the line that says something like current_line=#000;#363f41;true.

Is there a possibility to change the font-color of the Preview-tab when it is in focus? On one side there is the red color for the unsaved tab in the editor, and on the other side there would be the green color when Preview is in focus or when other tabs of the sidebar are in focus. It would be some kind of nice color game that fits together.

I just did some testing, and this is not possible. The problem is I'm not able to connect to any signals to find out when the Preview tab gets and loses focus.

If so, where can I change the settings?

Since you are working with HTML files, maybe there is something you could do with javascript? YouTube stops video playback when the page loses focus. So there must be a way to detect and respond to it.

ralf3u commented 2 years ago

@xiota

The editor highlights the current line. If no line is highlighted, the editor does not have focus.

That is not true. Here is the evidence: Let's imagine this situation: The highlighted line is on top of the document. With the mouse the user is scrolling down, so that the highlighted line is not any more in the visible area. Now the user is distracted by something. Then the user looks back on the screen. What is in focus? Is it the editor or Preview? There is no hint at all.

You write:

The problem is I'm not able to connect to any signals to find out when the Preview tab gets and loses focus.

So, to detect when tab gets and loses focus does exist only for the editor and not for the sidebar?
Thank you for an answer in advance.

xiota commented 2 years ago

The editor highlights the current line. If no line is highlighted, the editor does not have focus.

That is not true... With the mouse the user is scrolling down, so that the highlighted line is not any more in the visible area... There is no hint at all.

Okay.

So, to detect when tab gets and loses focus does exist only for the editor and not for the sidebar?

  1. The editor is a different component. (scintilla)
  2. I can test for focus, but that is not useful if it is not done at the right time.
  3. Something could be blocking the signals for the sidebar.

I'll look at the editor some other time to see if it is doing anything special. But right now, this is most likely not possible.

xiota commented 2 years ago

@ralf3u I found a different signal I can use. It's not specifically for focus, but I can check for focus after receiving it. There are new options in the config file: preview_tab_focus_green, preview_tab_focus_bold. They are disabled by default, so you will have to enable them.

By now you know the routine... reset config, save config, edit config, reload config... etc.

ralf3u commented 2 years ago

@xiota

Yes!! It's nearly perfect.

issue 1 I don't like so much the green color. It seems to be that you took an other green color. In the colorscheme sleepy pastel Lubuntu dark-mode (what is possible with Kvantum) the green color is a little bit too dark for me. Is there a possibility to choose an other green color like the color I mentioned above (#46af41)? I know how to change the color of the tab-title for an unsaved document, but I don't know to change the color of the tab-title of the sidebar.

issue 2 But what about the other tabs of the sidebar, like Documents or Symbols? I mean, this is for me not so important. But it would be good if it would work on all tabs of the sidebar for the reason to deliver a consequent behavior.

Thank you for an answer in advance.

xiota commented 2 years ago

But what about the other tabs of the sidebar, like Documents or Symbols?

I'll take a look. I'm probably going to move this feature to a different plugin.

I don't like so much the green color.

I'll make it customizable later.

ralf3u commented 2 years ago

@xiota

I forgot to mention also the plugin Filemanager (or something like this) that I'm using. It shows all documents of a certain file in a tab in the sidebar. So, also that tab should have the green font-color when it is in focus and if preview_tab_focus_green=true.

remark: I don't see so much the necessity in preview_tab_focus_bold because in the editor the title of the tab that is in focus is also not bold.

xiota commented 2 years ago

@ralf3u I put this feature in a different plugin. Basically it is for miscellaneous stuff that doesn't really belong in the Preview plugin. It will be in the PPA shortly. The package name is geany-plugin-xi-tweaks. You can install with:

sudo apt-get update
sudo apt-get install geany-plugin-xi-tweaks

The new plugin has similar buttons and menu items to edit the config files as the Preview plugin. The color of the tabs can be changed. After you get this working, I will remove the tab highlighting from the Preview plugin.

ralf3u commented 2 years ago

@xiota

Wow!! From the effect level it is marvelous!! It makes fun to tab-browse!! What a feeling!!

issue 1 I don't know if that happened in other versions of Geany Preview and I don't know if it has to do something with this new feature, but now I recognize this: On a very long document, so that I can see in the editor only a part of the document in the visible area, there is this when I go to the last line of the document after some seconds: In the sidebar, in the Preview-tab, there is at the very first line some strange text that is marked, like: "shorcut stays down".

issue 2 open Geany press the shortcut toggle editor/sidebar press again the shortcut toggle editor/sidebar result: the green color stays in the sidebar

issue 3 open Geany condition 1: the editor is on the left side; the sidebar is on the right side condition 2: the Symbols-tab is in the sidebar the first tab click on the Preview-tab close Geany open Geany press the shortcut toggle editor/sidebar in the sidebar: tab-browse with shortcuts to the left, to the first tab of the sidebar, so to the Symbols-tab in the sidebar: continue to tab-browse with shortcuts to the left result: a tab of the editor is in focus expected result: the last tab on the right side of the sidebar should be in focus

remark: behavior that I like: open Geany click in the sidebar on a tab that is not the Preview-tab close Geany open Geany press the shortcut toggle editor/sidebar result: Preview-tab is in focus (that's good!)

xiota commented 2 years ago

press the shortcut toggle editor/sidebar press again the shortcut toggle editor/sidebar result: the green color stays in the sidebar

Should be fixed. New version will be in the PPA when it's done building.

Will address other issues in the other thread.

xiota commented 2 years ago

Implemented in another plugin: https://github.com/xiota/geany-tweaks

ralf3u commented 2 years ago

@xiota

issue 1 I don't know if that happened in other versions of Geany Preview and I don't know if it has to do something with this new feature, but now I recognize this: On a very long document, so that I can see in the editor only a part of the document in the visible area, there is this when I go to the last line of the document after some seconds: In the sidebar, in the Preview-tab, there is at the very first line some strange text that is marked, like: "shorcut stays down".

Today I can't reproduce the issue 1 any more, so it is fixed.

issue 2 open Geany press the shortcut toggle editor/sidebar press again the shortcut toggle editor/sidebar result: the green color stays in the sidebar

Issue 2 is not fixed. Only after the third press it works nearly perfect: It is green when it should not be green, and vice versa.



issue 3 open Geany condition 1: the editor is on the left side; the sidebar is on the right side condition 2: the Symbols-tab is in the sidebar the first tab click on the Preview-tab close Geany open Geany press the shortcut toggle editor/sidebar in the sidebar: tab-browse with shortcuts to the left, to the first tab of the sidebar, so to the Symbols-tab in the sidebar: continue to tab-browse with shortcuts to the left result: a tab of the editor is in focus expected result: the last tab on the right side of the sidebar should be in focus

Issue 3 is not fixed. I'm sure that there is a solution, because if I click with the mouse on the Preview-tab and if I do tab-browsing in the sidebar with shortcuts everything works fine in any direction. I stay always in the sidebar during tab-browsing. But in the described issue 3 it is not the case, because during tab-browsing in the sidebar suddenly I tab-browse in the editor.

xiota commented 2 years ago

It is green when it should not be green, and vice versa.

This feature is difficult to get working right. I'll have to look at it some more later.

ralf3u commented 2 years ago

issue 3 I don't know how to program a software, but maybe those thoughts could help to find a solution. The problem is the shortcut toggle editor/sidebar. So, the shortcut toggle editor/sidebar should do exactly the same like a click on a tab of the sidebar or a click in the content of the sidebar. So, when shortcut toggle editor/sidebar is pressed:

IF the editor is in focus THEN DO exactly the same like a click on a tab of the sidebar or a click in the content of the sidebar

xiota commented 2 years ago

The problem is I need to get signals from the widget to respond to. Without a signal, there's no way to know when something is clicked or has focus or whatever. I'm trying to work around it by responding to multiple signals, but it doesn't work quite right because there are situations when the signals just aren't sent.

I've already tried all documented signals. I could try keeping track of state on my own, but there are so many ways of switching focus that it will easily get out of sync.

I'll look at it some more later today to try something else.

ralf3u commented 2 years ago

@xiota The issue 2 is solved. But issue 3 is not fixed.

xiota commented 2 years ago

I don't know what "issue 3" is. Please describe what happens and the steps to reproduce.

ralf3u commented 2 years ago

I don't know what "issue 3" is. Please describe what happens and the steps to reproduce.

https://github.com/xiota/geany-preview/issues/5#issuecomment-950291812

xiota commented 2 years ago

Thanks. I'll take a look at it. Looks like more problems with signals.

xiota commented 2 years ago

PPA has been updated with another attempt.

ralf3u commented 2 years ago

PPA has been updated with another attempt.

The issue 3 of this webpage is fixed.

issue 4 But now the problem is, that there are some small points around the Preview-tab-title when it is in focus. During tab-browsing in the sidebar, there are some small points around the corresponding focused tab-title. Some days ago there were no points at all. I think that the points are standing for focus. I feel a little bit disturbed by the points.

possible solution The focus should not be on the tab-title but on the content of the tab.

model for a possible solution In the editor there are no points at all around the tab-title when a tab of the editor is in focus.

control after the solution was realized a: There should be no points for all tab-title of the sidebar, when a tab of the sidebar is in focus. b: There should be no points for all tab-title of the sidebar, when switching with shortcut (toggle editor/sidebar) or by clicking on a tab-title of the sidebar.

xiota commented 2 years ago

But now the problem is, that there are some small points around the Preview-tab-title when it is in focus.

I don't know what you are describing. Please show a screenshot.

The focus should not be on the tab-title but on the content of the tab.

I'll add this if it can be done without restructuring any of the existing code. Otherwise, this has been difficult to implement, and I'd prefer to avoid making changes that will break it.

ralf3u commented 2 years ago

I don't know what you are describing. Please show a screenshot.

2021-11-01

There are now small white points around the tab-title Preview.

xiota commented 2 years ago

There are now small white points around the tab-title Preview.

That does not happen on my computer. What theme are you using?

Try adding: border-style: none;

ralf3u commented 2 years ago

What theme are you using?

Still the same theme: My theme Qt-style is kvantum-dark. GTK 2-Theme: Arc-Dark GTK 3-Theme: Arc-Dark my window theme (in openbox): KvGnomeDark in Geany: colorscheme: Sleepy Pastel

Try adding: border-style: none;

Where?

xiota commented 2 years ago

I don't know what package the Arc themes are from, so cannot install them to test.

Try adding: border-style: none;

Where?

To geany.css, inside the #geany-xitweaks-sidebar-tab-focus rule.

ralf3u commented 2 years ago

To geany.css, inside the #geany-xitweaks-sidebar-tab-focus rule.

After restarting Geany it is still there.

Help: Two days ago it was not there, so something was added yesterday.

xiota commented 2 years ago

Two days ago it was not there, so something was added yesterday.

Turn off the plugin to see if it is still there.

I installed a bunch of dark themes. It looks like something that is controlled by the theme. Did you update Ubuntu to 21.10? The theme may have changed.

Go to /usr/share/themes. Find the theme folder. There will be a css file somewhere inside. Look to see how the border is implemented. Then you can try adding a modified version of the rule to geany.css.

Try: border-color: transparent

ralf3u commented 2 years ago

Turn off the plugin to see if it is still there.

I turned off Xi/Tweaks in the list of plugins. Then I restarted Geany. It is still threre.

Did you update Ubuntu to 21.10?

No.

Go to /usr/share/themes. Find the theme folder.

In the folder themes there are 50 folders. Which one should I take? My theme Qt-style is kvantum-dark. GTK 2-Theme: Arc-Dark GTK 3-Theme: Arc-Dark my window theme (in openbox): KvGnomeDark

xiota commented 2 years ago

Geany uses GTK3.

I found the arc themes package... I see the outline now. It is part of the theme when the tab has keyboard focus. I turned off all plugins and removed geany.css, and it is still there.

ralf3u commented 2 years ago

Should I do something?

xiota commented 2 years ago

Should I do something?

I put some css in another message that may help. I will update the PPA momentarily.

ralf3u commented 2 years ago

What works:

Old issue, still not fixed:

Maybe I have a solution: What about this:

Result: The editor is again in focus. What I want to say with that is: In the moment where I click in the content of the Preview-tab, there must be some signal, else afterwards the shortcut would not work correctly. So the solution is: There is the signal to make then the tab-title green.

xiota commented 2 years ago

In the moment where I click in the content of the Preview-tab, there must be some signal, else afterwards the shortcut would not work correctly.

The shortcut doesn't need to use any signal to detect what is in focus. It works on-demand. When you press the keys, the function is called, then it does the checks.

I guess I could have a function constantly running to check what's in focus. It would affect performance and might still have problems.

ralf3u commented 2 years ago

Summary of that issue till now:

What does not work:

What works:


Down below is the code for having the green effect. The code should be added at the end of geany.css that is located in ~/.config/geany/ (if geany.css does not exist there, then first do this: copy /usr/share/geany/geany.css to ~/.config/geany/geany.css):

notebook header tabs > * {
    outline-width: 0;
}

#geany-xitweaks-sidebar-tab-focus {
    font-weight: normal;
    color: #7dcc95;
}
#geany-xitweaks-sidebar-tab-unfocus {
    /* Whatever you want */
}

#geany-xitweaks-sidebar-page-focus {
    border-width: 3px;
    border-style: solid;
    border-color: #2e3436;
}

#geany-xitweaks-sidebar-page-unfocus {
    border-width: 3px;
    border-style: solid;
    border-color: transparent;
    background: #2e3436;
}

#geany-preview-sidebar-page {
    border-width: 3px;
    border-style: solid;
    border-color: transparent;
    background: #2e3436;
}

If it does not work, then those things need to be done:

The reason for the code notebook header tabs > * {outline-width: 0;} is to avoid this behavior: If the shortcut "Toggle focus between the editor and preview" was pressed, then, as long as Geany is not closed, there are white points around the tab-title on a long click on an open tab of the editor or sidebar.

If you change the content of geany.css (that is located in ~/.config/geany/), save the document, and restart Geany to see the changes.

ralf3u commented 2 years ago

I wanted to reopen this issue because it was not completely fixed. But there is no "Reopen issue"-button like in some other closed issues. Is there a way to reopen this issue?

ralf3u commented 2 years ago

Maybe the solution of this issue has a connection with https://github.com/xiota/geany-preview/issues/15.

ralf3u commented 2 years ago

YESSS!!!!!!!

The only thing what does not work in this issue is:

clicking in the sidebar in the content of a tab: the tab-title is not green (old issue, still not fixed)

I noticed that here: https://github.com/xiota/geany-preview/issues/5#issuecomment-969031972 (in that comment there is also a step-by-step description how to get the green effect)

But today I'm sure: There must be a solution for this issue!

Because if (in a html-document with the highlighted line in the editor) I press 1x or 2x the shortcut "Toggle editor" what you developed last week (https://github.com/xiota/geanylua-scripts/issues/4), and then, if I click in the content of the Preview, then the tab-title is green!

Could be maybe interesting for understanding what's going on: Before pressing the shortcut: If I click first in the content of the Preview, then the tab-title will later not become green (what I mean with "later" is, after having pressed the shortcut 1x or 2x, and then after having clicked again in the content of the Preview).

A solution for this issue would be so great.

ralf3u commented 2 years ago

To my last comment: Could you figure out why in one case the tab-title becomes green, but not in the other case, or rather could you catch a signal that fires the green color so that this issue could be solved?

ralf3u commented 2 years ago

Before programing shortcuts for issue number 37, 38 and 40, I think that this issue is more important. It is so close to be perfect. Maybe my comment in https://github.com/xiota/geany-preview/issues/5#issuecomment-1158852295 could help to solve this issue.

xiota commented 2 years ago

I don't currently have the plugin built/installed because I switched distros. Also, this thread is really long touching on multiple related issues. Could you briefly summarize what the current issue is?

ralf3u commented 2 years ago

Could you briefly summarize what the current issue is?

The only thing that does not work for that issue: If I type in the editor, and then if I click in the content of the Preview, then the tab-title will not become green.

I think that there should be a solution because of this behavior: If I type in the editor, and then if I press the shortcut for the lua-script https://github.com/xiota/geanylua-scripts/issues/4, and then, if I click in the content-area of the Preview, then the tab-title becomes green.

xiota commented 2 years ago

... the tab-title will not become green...

That is probably a focus issue. Trying to change focus hasn't worked well. I'm stuck and don't know how to fix it.

ralf3u commented 2 years ago

I'm stuck and don't know how to fix it.

... although it works perfect with the lua-script?

ralf3u commented 2 years ago

Trying to change focus hasn't worked well. I'm stuck and don't know how to fix it.

I just opened https://github.com/geany/geany/issues/3289 to bring a little bit movement to the topic.

ralf3u commented 1 year ago

Maybe GTK4 is different, but in GTK3 almost a year ago, none of the signals worked. When focus was grabbed, often the wrong widget was selected. (https://github.com/geany/geany/issues/3289#issuecomment-1247469392)

So, would that mean that maybe this issue could be fixed with GTK4, like the other issues mentioned in the report of https://github.com/geany/geany/issues/3289#issue-1369859705?

xiota commented 1 year ago

I doubt it's "fixed" in GTK4, but even if it were, Geany still requires GTK3. (GTK4 removes deprecated features that Geany still uses.)

ralf3u commented 1 year ago

I doubt it's "fixed" in GTK4, but even if it were, Geany still requires GTK3. (GTK4 removes deprecated features that Geany still uses.)

That's such a pity. It was my last hope.

ralf3u commented 1 year ago

I doubt it's "fixed" in GTK4, but even if it were, Geany still requires GTK3. (GTK4 removes deprecated features that Geany still uses.)

The only thing I really miss in Geany Preview is the focus feature (#5, #15, #37, #38). It would make Geany Preview so perfect for non-scrolling webpages.

What about the idea to test GTK4 and if there is still an issue, then to report it upstream, so to the GTK folks, like elextr suggested (https://github.com/geany/geany/issues/3289#issuecomment-1247476031), so that maybe one day the focus feature could be solved?

I mean, I can imagine that it is a lot of work, but it's worth.

xiota commented 1 year ago

What about the idea to test GTK4

Geany and plugins would have to be built with GTK4. I think there is a build flag for that. I will look for it.

The only thing I really miss in Geany Preview is the focus feature... I can imagine that it is a lot of work, but it's worth.

I'm inclined not to mess with it, but I'll think about it.