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

Feature "Highlight current line" partially broken #5270

Open
engelhro opened this issue Aug 7, 2024 · 14 comments
Open

Feature "Highlight current line" partially broken #5270

engelhro opened this issue Aug 7, 2024 · 14 comments

Comments

@engelhro
Copy link

engelhro commented Aug 7, 2024

Since some time the settings to highlight the current line (Appearance → Customize schemes…Common BaseHighlight Current Line) are not fully respected anymore. I tried with both a pure text file as well as a Markdown file.

  • The frame settings ("foreground color" and "size" attributes) are considered, changing them shows the desired effect.
  • The other settings ("background color" and "font" attributes, probably also "alpha") are not considered, changing them shows no visual effect.

I know this has worked in the past, at least setting a background color for the current line. This might be broken for some time, I just consciously noticed it some days ago.

I tested with the most recent (I guess) beta 6.24.713.1 rc3 (ff261d0f).

Can someone confirm my observation and the possible bug? Or did I misinterpret some of the convoluted relationships between the various scheme settings and their hierarchy?

@hpwamr
Copy link
Collaborator

hpwamr commented Aug 7, 2024

Hello @engelhro ,

Notepad3_6 24 713 1_x64_Modify

Readme_Notepad3_6 24 713 1_x64_Modify

You're right, the Foreground setting is not taken into account?

It seems to be a very old bug? 🤔

I hope @RaiKoHoff can find some time to take a look at your finding? 😏

@craigo-
Copy link

craigo- commented Aug 7, 2024

I do wonder whether this is is related to #4618 and the earlier #4522 comment (subsequently moved to the current #4581) - the overarching theme being that Common Base is no longer the root scheme..?

@RaiKoHoff
Copy link
Collaborator

The change happens with Scintilla v5.0.3 (see. https://www.scintilla.org/ScintillaHistory.html), when the older Caret-Line-API was discouraged.
The very restricted/limited input format for setting (fore:, back: size:, alpha, ...) is not always perfect for some feature, so we have to make a compromise:
The new Caret-Line-API uses a coloring only of the background layer, so foreground parameter would be useless.
So we decided to (mis)use the foreground parameter for coloring of alternate line highlighting (current line as outline frame), means, foreground color is for "current line as outline frame", background color is for "current lines background layer".
The alpha parameter is for translucency (alpha-mix with line's background color) in both cases.
The size parameter is only for frame pixel thickness of "current line as outline frame" mode.

An enhancement could be to use "alpha" for background (full highlight) color and alpha2 for foreground (outline frame) color translucency.

@hpwamr
Copy link
Collaborator

hpwamr commented Aug 25, 2024

Hello @engelhro ,

Feel free to test the "BETA/RC PortableApps", version "Notepad3Portable_6.24.825.1_rc3.paf" or newer, see the 1st list in issue #1129.

"Notepad3Portable BETA/RC PortableApps" version can be used with or without ".7z" extension.

Also, feel free to test the "BETA/RC Setup", version "Notepad3_6.24.825.1_rc3_Setup" or newer, see the 2nd list in issue #1129.

Comments and suggestions are welcome... 😃

@engelhro
Copy link
Author

I'm sorry, but that was a little bit too technical, I couldn't follow:

The change happens with Scintilla v5.0.3 (see. https://www.scintilla.org/ScintillaHistory.html), when the older Caret-Line-API was discouraged. The very restricted/limited input format for setting (fore:, back: size:, alpha, ...) is not always perfect for some feature, so we have to make a compromise:

Okay. So far, so good.

The new Caret-Line-API uses a coloring only of the background layer, so foreground parameter would be useless.

What does "background layer" mean in this context?

So we decided to (mis)use the foreground parameter for coloring of alternate line highlighting (current line as outline frame)

I see. That is what I described and where I could influence the layout of the outline frame with the existing parameters.

But what is "alternate" line highlighting? Are there two (or more) ways of highlighting?

means, foreground color is for "current line as outline frame", background color is for "current lines background layer".

Yes, okay, that's what I already assumed. But for some reason the background color does not take effect at all. I'm again confused by the "background layer" term.

The alpha parameter is for translucency (alpha-mix with line's background color) in both cases. The size parameter is only for frame pixel thickness of "current line as outline frame" mode.

Understood, and perfectly fine.

An enhancement could be to use "alpha" for background (full highlight) color and alpha2 for foreground (outline frame) color translucency.

This seems to have been implemented with the new beta, and while it's nice to have two alpha values now, I'm not sure what to make out of this? The first influences the transparency of the outline frame, as before, perfect.

But the second one seems irrelevant, because independent of its value (0%, 50%, or 100%) there simply continues to be no background color. What transparency is adjusted here?

So, to summarize my questions:

  • Is there a way (with the Scintilla API update) to get the background color back (ideally with alpha) at all?
  • If yes, then how? There either is still a bug in NP3 – or I fail to understand how to set the background color and use the parameters correctly.

@engelhro
Copy link
Author

engelhro commented Aug 27, 2024

Hello @engelhro ,

Feel free to test the "BETA/RC PortableApps", version "Notepad3Portable_6.24.825.1_rc3.paf" or newer, see the 1st list in issue #1129.

[...]

Comments and suggestions are welcome... 😃

I've tested the new version, but it doesn't solve my problem (see other comment above):

While there a two distinct alpha values now, with one affecting the outline frame, and the other presumably the (nonexistent) background color, I'm still not able to achieve the effect of a colored "current line". The background color setting doesn't show any effect, independent of the transparency value.

@RaiKoHoff
Copy link
Collaborator

Upcoming PR #5289 will change the behavior:
If foreground color is set (and alpha > 0), a foreground layer is activated - that means, if alpha is 255 (opaque) the text is not readable (opaque overlay) anymore. To get old behaviour, only define background color only (back:#RRGGBB;) with suitable alpha2 value.

Attention: this is a breaking change for users, who have changed their HighlightCurrentLine foreground and/or alpha value settings: they have to delete their foreground color and set alpha2 value instad of alpha.

No possibility to use .ini-File versioning here, since that are style configs, which are not versioned.

@hpwamr
Copy link
Collaborator

hpwamr commented Aug 28, 2024

Hello @engelhro ,

Feel free to test the "BETA/RC PortableApps", version "Notepad3Portable_6.24.828.1_rc3.paf" or newer, see the 1st list in issue #1129.

"Notepad3Portable BETA/RC PortableApps" version can be used with or without ".7z" extension.

Also, feel free to test the "BETA/RC Setup", version "Notepad3_6.24.828.1_rc3_Setup" or newer, see the 2nd list in issue #1129.

Comments and suggestions are welcome... 😃

@engelhro
Copy link
Author

engelhro commented Aug 30, 2024

Tested the new beta (6.24.828.1_rc3), but unfortunately this all doesn't help:

I can now influence the frame color with both back or fore color (with the respective alpha or alpha2 value). But I still can't achieve a highlight of the current by a change of its background color.

Concrete questions:

  • I'm still confused by the "background layer" vs. "foreground layer" terminology – what does that even mean? Are these two layers overlayed/stacked, with the "foreground layer" winning (being in front)?
  • It's not clear (at least to me) from the discussion above: can we get background color back for the current line or not? Was this ultimately broken by Scintilla or can we achieve the previous look? Currently the back setting also just influences the frame color (like the fore parameter), but not the actual background color… 😢
  • What does the "the text is not readable (opaque overlay) anymore" snippet for the foreground layer above mean? I haven't been able to produce such an effect, even while playing with different combinations between fore, back, alpha and alpha2

And, slightly independent:

  • The scale of alpha and alpha2 is actually between 0 and 255? The default value of 50 always let me (instinctively, but probably incorrectly) assume that it stood for "50%" and the range reaches from 0 to 100. 😲
  • I also find a high value for alpha meaning "low transparency" / "high opaqueness" and vice versa confusing. For me "alpha" is mentally defined as transparency, and I will always associate a high alpha with little visibility of the foreground/background color (in this case the frame), and a low alpha with a strong effect. In NP3 is realized the other way round.

@engelhro
Copy link
Author

One more question to @hpwamr: with which NP3 version have you created your screenshot above, in the second posting? Was it a quite current one (maybe the one of the Readme you have open in the screenshot)?

In that case the issue is even more mysterious, because this then seems to show the exact opposite of what I observe: you only have a background color (mine is always white!), but no frame color (which I on the other hand can see and change, now with either the fore or back setting)!

Something weird is going on here 😕

@hpwamr
Copy link
Collaborator

hpwamr commented Aug 30, 2024

Hello @engelhro ,
I've created the screenshot from "Notepad3 (x64) 6.24.713.1 rc3" but after changing the "Foreground" and "Background" color settings.
This is not strange because I had "misinterpreted" how the "Foreground" and "Background" changes are displayed. 🤔

And in this above screenshot, my setting in: "View" --> "Highlight current line" was --> "Background color". 😏

2024-08-30_163844

@hpwamr
Copy link
Collaborator

hpwamr commented Aug 30, 2024

  • I'm still confused by the "background layer" vs. "foreground layer" terminology – what does that even mean? Are these two layers overlayed/stacked, with the "foreground layer" winning (being in front)?

Hello @engelhro ,
I had some "Offline" discussions with @RaiKoHoff about "how the "Foreground" and "Background" changes are displayed". 🤔

Here a summary:

Change color of text is not possible with Scintilla's "Highlight Current Line" Feature. You can only set mode: of, standard or outline frame, a color and translucency.
And the order of the painting layer: either over text (foreground) or under text (background). if both are defined, foreground wins.
If the foreground is chosen, and opaque (alpha=255) is set, the text is covered completely. With the translucency set, the text seems to be shining through a colored glass.
If only background is chosen, the text is over this layer, the text color is not influenced. If translucency of background (alpha2) is set, the edit-area's background-color "shines through" the LineHighlight layer, like a colored glas on a white/dark paper, where letters are written on top of the glass. (foreground mode: The letters are written on the paper, and colored glas is put on the paper and the letters.

Layer Model:

Image 2024-08-28

  • dark-blue -> editor-background-layer
  • orange -> CurLnHiLit background-layer
  • bright-blue -> text-layer
  • green -> CurLnHiLit foreground-layer

You can only have one of the CurLnHiLit layers (foreground wins if defined).

@engelhro
Copy link
Author

Ah, I finally see and understand! 😃 Your picture was very helpful while I already had assumed such a mechanism.

But I was simply not aware of the menu option to toggle the current line highlighting between "Background Color" and "Outline Frame" 🤦! I must have changed that somewhen in the past, inadvertently, and this contributed to the confusion I felt – I wanted the background colored, and always just got the frame…

This also explains Rainer statements of "alternate" highlighting etc. which I didn't understand above…

Now I can reproduce what I see in my setup, what you have in yours, which effect is controlled by which setting, and how I can switch back to the desired background color highlight instead of the frame 👍.


But:

After getting my head around this, I now don't understand why we use the foreground layer here at all (possibly obscuring the text) and introduced a second alpha setting here? When both effects (exclusively background color or outline frame, and never both at the same time) can be achieved by the background layer alone, then why consider fore at all, and why have two separate alpha values?

As I understood the text color cannot be changed due to the Scintilla limitation anyway (which is fine for me, never needed that as additional way to highlight the current line).

Then one color (back), one alpha value (alpha), the frame thickness (size) and the menu option which highlight style to use should be sufficient? Just drop alpha2 and fore for that configuration part and everything should be fine and easier to comprehend?

@hpwamr
Copy link
Collaborator

hpwamr commented Aug 30, 2024

After getting my head around this, I now don't understand why we use the foreground layer here at all (possibly obscuring the text)

I continue my "Offline" discussion with @RaiKoHoff on the use of "alpha2" and its negative effects... 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants