Selections end up being drawn in bug colour when used SCI_FORMATRANGE when hideSelection is false. Fix is probably to hide selections and doing that before format range is called works.
I'm reasonably sure that setting all of the selection backgrounds elements to have an alpha of 0 would work for multi-phase drawing, but what about single phase? I just switched to using multi-phase to get alpha values to work -- the colors are always opaque in single-phase. Or, does format range always use multi-phase?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It uses the same phasesDraw as the screen which can be One (0 = single-phase) as in the image. On Win32, printing always uses GDI (Technology::Default) instead of DirectDraw and GDI does not implement alpha for all methods.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I suspect something application-specific, as wscite prints exactly what is expected with print.colour.mode=2. By trial and error, I found that executing SCI_SETSELECTIONLAYER with SC_LAYER_UNDER_TEXTwas necessary to make the (inactive) style of the selected region transparent, but the chief maintainer prefers to hear it from the horse's mouth, and it seems his SF credentials have lapsed.
Here is a potential fix: the problem was that layer 0 drawing is stripping the alpha so uses the colour fully opaque. The patch uses the StyleMain background colour (for layer 0) and fully transparent (for other layers). Since it uses StyleMain, it has to be moved after the PrintOption handling as that may choose a different background colour.
The latest patch appears to let the colour scheme's background show through. OK when it happens to be solid white, but "Vim Dark Blue" obscures the text with its namesake colour:
As before, a preemptive call to SCI_SETSELECTIONLAYER with SC_LAYER_UNDER_TEXT before the range is formatted appears to be an effective workaround. Still no clue why that may be.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I should've mentioned that Notepad++ has only partly adopted the SCI_SETELEMENTCOLOUR APIs, and only in cases where the v4 APIs fail to produce the accustomed result (*1). Of the four element styles that [fc46d7] addressed, the editor only sets one of them explicitly (possibly two, if SCI_SETSELBACK has any influence on Element::SelectionBack):
Grepping the application code for SC_ELEMENT_SELECTION_(SECONDARY_|ADDITIONAL_|)BACK currently returns nothing.
Unfortunately the maintainer still thinks an upstream solution is forthcoming. Maybe some kind of illustrated tutorial on how selection styles work in v5 would help.
Here's a potential fix that adds a selection.visible field to ViewStyle that is set false on the printing ViewStyle. Its meaning is inverted as the selection is normally visible and most uses of hideSelection were negated. Also adds a SCI_GETSELECTIONHIDDEN API for symmetry and testing.
The latest patch seems to resolve the issue with Notepad++. Also tried it with SciTE and noticed one minor quirk. When the system's print dialog launches, the selection style completely disappears from SciTE's edit view until the range format is completed. In N++ it's visible throughout, but I think that can be set down to the latter's continued preference for v4's APIs. The series of patches beginning with [ce4227] assume a graphics device supporting alpha channels, but a glance at N++'s code finds nothing but 24-bit COLORREFs.
There was a similar case addressed with [ce4227]. Possibly reuse that approach.
Related
Commit: [ce4227]
Does that work when single phase drawing is used?
In SciTE the main selection is OK but additional selections are bug colour. Secondary selections on Unix could be an issue.
I'm reasonably sure that setting all of the selection backgrounds elements to have an alpha of 0 would work for multi-phase drawing, but what about single phase? I just switched to using multi-phase to get alpha values to work -- the colors are always opaque in single-phase. Or, does format range always use multi-phase?
It uses the same
phasesDrawas the screen which can beOne(0 = single-phase) as in the image. On Win32, printing always uses GDI (Technology::Default) instead of DirectDraw and GDI does not implement alpha for all methods.Fixed with [fc46d7].
Related
Commit: [fc46d7]
This bug continues to bedevil Notepad++, despite the application of both [ce4227] and [fc46d7]: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/11911
I suspect something application-specific, as
wsciteprints exactly what is expected withprint.colour.mode=2. By trial and error, I found that executingSCI_SETSELECTIONLAYERwithSC_LAYER_UNDER_TEXTwas necessary to make the (inactive) style of the selected region transparent, but the chief maintainer prefers to hear it from the horse's mouth, and it seems his SF credentials have lapsed.Related
Commit: [ce4227]
Commit: [fc46d7]
Last edit: rdipardo 2022-07-13
Here is a potential fix: the problem was that layer 0 drawing is stripping the alpha so uses the colour fully opaque. The patch uses the StyleMain background colour (for layer 0) and fully transparent (for other layers). Since it uses StyleMain, it has to be moved after the PrintOption handling as that may choose a different background colour.
The latest patch appears to let the colour scheme's background show through. OK when it happens to be solid white, but "Vim Dark Blue" obscures the text with its namesake colour:
As before, a preemptive call to
SCI_SETSELECTIONLAYERwithSC_LAYER_UNDER_TEXTbefore the range is formatted appears to be an effective workaround. Still no clue why that may be.This likely needs a different approach like forcing
hideSelectionon duringFormatRangeor moving it toViewStyleso it can be always on forvsPrint.I should've mentioned that Notepad++ has only partly adopted the
SCI_SETELEMENTCOLOURAPIs, and only in cases where the v4 APIs fail to produce the accustomed result (*1). Of the four element styles that [fc46d7] addressed, the editor only sets one of them explicitly (possibly two, ifSCI_SETSELBACKhas any influence onElement::SelectionBack):Grepping the application code for SC_ELEMENT_SELECTION_(SECONDARY_|ADDITIONAL_|)BACK currently returns nothing.
Unfortunately the maintainer still thinks an upstream solution is forthcoming. Maybe some kind of illustrated tutorial on how selection styles work in v5 would help.
(*1) https://github.com/notepad-plus-plus/notepad-plus-plus/commit/b6efff4157dd1176e2763af94555af16a13cbc48
Related
Commit: [fc46d7]
There'll probably be a
hideSelectionchange at some point but other things have higher priority.For now, the app may be able to work around this by hiding the selection before calling
FormatRangethen restoring its preference.Here's a potential fix that adds a
selection.visiblefield toViewStylethat is set false on the printingViewStyle. Its meaning is inverted as the selection is normally visible and most uses ofhideSelectionwere negated. Also adds aSCI_GETSELECTIONHIDDENAPI for symmetry and testing.The latest patch seems to resolve the issue with Notepad++. Also tried it with SciTE and noticed one minor quirk. When the system's print dialog launches, the selection style completely disappears from SciTE's edit view until the range format is completed. In N++ it's visible throughout, but I think that can be set down to the latter's continued preference for v4's APIs. The series of patches beginning with [ce4227] assume a graphics device supporting alpha channels, but a glance at N++'s code finds nothing but 24-bit
COLORREFs.Related
Commit: [ce4227]
Fixed with [ac7c97] and [3a40bb].
Related
Commit: [3a40bb]
Commit: [ac7c97]