rizonesoft / Notepad3

Notepad like text editor based on the Scintilla source code. Notepad3 based on code from Notepad2 and MiniPath on code from metapath. Download Notepad3:
https://www.rizonesoft.com/downloads/notepad3/
Other
4.95k stars 331 forks source link

Feature "Highlight current line" partially broken #5270

Open engelhro opened 1 month ago

engelhro commented 1 month ago

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.

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 commented 1 month ago

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- commented 1 month ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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:

engelhro commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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:

And, slightly independent:

engelhro commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago
  • 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

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

engelhro commented 2 weeks ago

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 commented 2 weeks ago

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