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

Resuming normal view clears the alpha channel from custom caret line background #356

Closed
rdipardo opened this issue May 18, 2023 · 2 comments

Comments

@rdipardo
Copy link

rdipardo commented May 18, 2023

Steps to Reproduce

  1. Set the caret line background to a translucent color, e.g. 0x28FF009C; for example, by executing this NppExec script:

     SET SCI_SETELEMENTCOLOUR = 2753
     SET SCI_SETCARETLINELAYER = 2765
     SET SC_ELEMENT_CARET_LINE_BACK = 50
     SET SC_LAYER_UNDER_TEXT = 1
     SCI_SENDMSG $(SCI_SETELEMENTCOLOUR) $(SC_ELEMENT_CARET_LINE_BACK) 0x28FF009C
     SCI_SENDMSG $(SCI_SETCARETLINELAYER) $(SC_LAYER_UNDER_TEXT)
    
  2. Before opening the compare view, the caret line background should be translucent:

normal_view_before_compare_8 5 3

  1. Open the compare view; close it again.

  2. The caret line background is now solid:

normal_view_after_compare_npp_8 5 3

Problem code path

The setNormalView function uses a 24-bit BGR color mask that clears the top 8 alpha bits; it also sets the SC_LAYER_BASE flag, which will cancel transparency effects in any case:

const intptr_t caretLineColor = CallScintilla(view, SCI_GETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, 0);
if (caretLineColor)
CallScintilla(view, SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, caretLineColor & 0xFFFFFF);
CallScintilla(view, SCI_SETCARETLINELAYER, SC_LAYER_BASE, 0);

This could be seen as a negative interaction with user scripts and other plugins that customize the caret line background. There's a least one case of a plugin developer thinking that the alpha channel was disappearing because of a bug in his own code.

Version

1.1

@pnedev
Copy link
Owner

pnedev commented May 19, 2023

@rdipardo ,

Thanks for reporting this and for the analysis.
Notepad++ by default sets the caret line background color to 0xFFE8E8 and the layer used is SC_LAYER_BASE.
Because in ComparePlus I'd like to make the diff color background visible when the caret is on its line and also the text should be visible (not blurred by alpha on upper layer) I change the caret line layer to SC_LAYER_UNDER_TEXT and set an alpha to the caret line background color.
After compare is closed I would like to restore the view as Notepad++ has configured it.

Now if some other plugin also changes caret background color it will for sure interfere with ComparePlus.

If for example one plugin changes the color and then other plugin changes it immediately afterwards (on some event - in ComparePlus case it is notification about activation of another doc) then it is very important how the Notepad++ original setting will be restored.
I will do some tests with CSVLint and ComparePlus when I get to this and will see if I can improve the things on my side.

BR

@pnedev
Copy link
Owner

pnedev commented Aug 21, 2023

Hi guys,

That is the best I can do : a374a82
I'm closing this issue now - please write again here if you think there is still something that can be done better.

Thanks.
BR

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

2 participants