Open BdR76 opened 1 year ago
afaik the error is not due to Compare Plugin v2
Actually, the whole problem seems to be that comparePlus wipes out the caret line's alpha channel when switching back to the normal view:
The call to SCI_SETELEMENTCOLOUR
only masks the lowest 24 bits of the color value, effectively setting the top 8 "alpha" bits to 0
(transparent). The caret line would disappear, except that this call sends SC_LAYER_BASE
to SCI_GETCARETLINELAYER
, which tells Scintilla to "[d]raw the selection background opaquely on the base layer".
With CSVLint installed alongside, comparePlus detects the caret line color as 0x66000000
, or rbga(0, 0, 0, 0.4)
(translucent gray). But what it sends to Scintilla is actually 0x66000000 & 0xFFFFFF
, or 0x0
(solid black).
Later, when setting up the compare view, the alpha channel gets put back into the top 8 bits:
The SCI_SETELEMENT*
family of APIs are new to Scintilla 5, so there's definitely no .NET implementation. It could be a problem that CSVLint uses the officially deprecated SCI_SETCARETLINEBACK
API[^1] :
A few options to consider:
Adopt the new element style APIs and set the alpha channel the officially supported way; comparePlus already does, reducing the chances of adverse interactions. Only problem is the .NET template needs new infrastructure;
Keep using the old APIs (until Scintilla removes them, at least), but respond to alpha changes and revert the style as needed. It doesn't look like Scintilla provides a notification for changes to the caret line, but you could hook one of Npp's notifications instead; or,
Report the issue to comparePlus, since any plugin that sets the caret line style would be affected. Below is a quick idea of what a third-party fix might look like.
_Note. The alpha value is hard-coded here because it looks better in CVLint's case — the SC_LAYER_UNDER_TEXT
flag tends to darken everything by blending the active selection and caret line styles together._
diff --git a/src/NppHelpers.cpp b/src/NppHelpers.cpp
index c8f468b..e46035c 100644
--- a/src/NppHelpers.cpp
+++ b/src/NppHelpers.cpp
@@ -374,11 +374,12 @@ void setNormalView(int view)
CallScintilla(view, SCI_SETMARGINSENSITIVEN, MARGIN_NUM, false);
const intptr_t caretLineColor = CallScintilla(view, SCI_GETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, 0);
+ const intptr_t caretLineColorAlpha = (caretLineColor & 0xFFFFFF) | (0x28 << 24);
if (caretLineColor)
- CallScintilla(view, SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, caretLineColor & 0xFFFFFF);
+ CallScintilla(view, SCI_SETELEMENTCOLOUR, SC_ELEMENT_CARET_LINE_BACK, caretLineColorAlpha);
- CallScintilla(view, SCI_SETCARETLINELAYER, SC_LAYER_BASE, 0);
+ CallScintilla(view, SCI_SETCARETLINELAYER, SC_LAYER_UNDER_TEXT, 0);
CallScintilla(view, SCI_SETELEMENTCOLOUR, SC_ELEMENT_HIDDEN_LINE, hiddenLinesColor[view]);
}
[^1]: The former APIs support 24-bit BGR colors only, hence their deprecation in favour of the element style APIs.
I'm inclined to try updating this plugin to the new element style APIs and see if that solves the problem with ComparePlus. I'll work on a PR today.
The
SCI_SETELEMENT*
family of APIs are new to Scintilla 5, so there's definitely no .NET implementation.
Actually they are! See ScintillaGateway.cs.
Unfortunately, it's not as straightforward a fix as I had hoped. Calling editor.SetElementColour(Element.CARET_LINE_BACK, new ColourAlpha(24 << 24));
just results in the caret line being really dark.
The more I think about this, the more I wonder if maybe the easiest "solution" (really patch I suppose) is just to change the default for the Transparent cursor
setting.
As @carlos-esteves pointed out in issue #73 -> When the cursor line is all black after using the Compare plugin, you can open the CSV Lint settings form and then close it to reset the black cursor line back to transparent.
I don't have the time to work on the CSV Lint plug-in at the moment, so this is at least a workaround for now (albeit clunky)
When the cursor line is set to transparant, it turns completely black after using another plugin making the text at the cursor and selected line unreadable. User has to restart Notepad++ to make it transparant again.
1) Install both
CSV Lint
and theCompare Plugin v2
2) In CSV Lint settings, setTransparent cursor = true
3) Create two empty filesNew 1
andNew 2
4) Paste some text for example "1,2,3" in both files 5) Set one or both toLanguage > CSVLint
6) Compare files CTRL + ALT + C 6) Clear Compare result with CTRL + ALT + XAfter the last step the Notepad++ cursor line will be all black, see screenshots below. afaik the error is not due to Compare Plugin v2 but that's just an easy way to trigger this,