Coder Social home page Coder Social logo

Notepad++ v8.4 and beyond (inclusive 8.4.2) CRASHES or doesn't work properly when applying a color on selected text using NppExec. about nppexec HOT 9 CLOSED

jabal1 avatar jabal1 commented on June 24, 2024
Notepad++ v8.4 and beyond (inclusive 8.4.2) CRASHES or doesn't work properly when applying a color on selected text using NppExec.

from nppexec.

Comments (9)

d0vgan avatar d0vgan commented on June 24, 2024

Thank you for this detailed bug report!
Notepad++ uses an updated version of Scintilla starting from Notepad++ 8.4. It also affected the plugins that were not recently updated:
https://community.notepad-plus-plus.org/topic/23079/eventual-bugs-in-plugins-with-notepad-v8-4-x
This may explain why 8.3.3 is still OK.
I tried the same script

sci_sendmsg SCI_SETSELFORE 1 65280

and it everything works for me for both 64-bit and 32-bit Notepad++ 8.4.2.
I noticed you are using a couple of custom plugins: DSpellCheck.dll and NppHorizontalRuler.dll.
Could you try temporary remove both of them and try to reproduce the issue?
If the issue will go away, then you could try to restore one of them to identify which one causes the issue to re-appear.

from nppexec.

rdipardo avatar rdipardo commented on June 24, 2024

The crash is caused by NppHorizontalRuler, assuming it was compiled from this source tree.

It uses the length returned by SCI_GETCURLINE without adding 1, a necessary correction since Scintilla 5.1.5 shortened the return value of that API.

src/HorizontalRuler.cpp:379:    nLineLength = (int)SendMessage(this->scintillaHwnd, SCI_GETCURLINE, 0, 0);
src/HorizontalRuler.cpp:381:    nCaret = (int)SendMessage(this->scintillaHwnd, SCI_GETCURLINE, nLineLength, (LPARAM)curLin);

The developer of NppHorizontalRuler should be notfied with a link to notepad-plus-plus/notepad-plus-plus#11766

from nppexec.

jabal1 avatar jabal1 commented on June 24, 2024

Hello,

@d0vgan

As suggested by @rdipardo on the bug report of notepad++ I tried a recent development build with only the NppExec plugin installed and no other plugin and it still didn't work as expected.

So when you say "everything works for me for both 64-bit and 32-bit Notepad++ 8.4.2" are you sure that you have at the same time the highlighting of selected text in both tabs like in version 8.3.3 ?

image

from nppexec.

d0vgan avatar d0vgan commented on June 24, 2024

Only the active view has the selected text in green: i.e. when the primary view is active, its selected text foreground color is green; when the secondary view is active, its selected text foreground color is green.
I believe that starting from Notepad++ 8.4 there are two different options for the foreground color: one for the active foreground color (when the view is active, the one set by SCI_SETSELFORE) and another one for the inactive foreground color (when the view is inactive).
Looking at the Scintilla documentation, probably SCI_SETELEMENTCOLOUR should be used instead of SCI_SETSELFORE.
https://www.scintilla.org/ScintillaDoc.html
Frankly, I'd appreciate if ScintillaDoc mentioned that explicitly (e.g. if there was a clear statement such as "the SCI_SETSELFORE is obsolete; use SCI_SETELEMENTCOLOUR instead").

from nppexec.

d0vgan avatar d0vgan commented on June 24, 2024

https://sourceforge.net/p/scintilla/bugs/2337/

from nppexec.

jabal1 avatar jabal1 commented on June 24, 2024

Well I tried this in Notepad++ 8.4.2 with NppExec 0.8.2 :

SCI_SENDMSG SCI_SETELEMENTCOLOUR 1 65280

And unfortunately it does not work,

SCI_SETSELFORE 1 65280 works the same way as SCI_SENDMSG 2067 1 65280

But SCI_SETELEMENTCOLOUR does not seem to work at all in the intended way.

from nppexec.

d0vgan avatar d0vgan commented on June 24, 2024

This works:

sci_sendmsg SCI_SETELEMENTCOLOUR SC_ELEMENT_SELECTION_TEXT 65280
sci_sendmsg SCI_SETELEMENTCOLOUR SC_ELEMENT_SELECTION_INACTIVE_TEXT 65280

from nppexec.

rdipardo avatar rdipardo commented on June 24, 2024

This works:

sci_sendmsg SCI_SETELEMENTCOLOUR SC_ELEMENT_SELECTION_TEXT 65280
sci_sendmsg SCI_SETELEMENTCOLOUR SC_ELEMENT_SELECTION_INACTIVE_TEXT 65280

There is one catch — you must turn off DirectWrite:

nppExec-D2D

The new APIs were designed to support alpha channels. The officially correct usage is:

SC_ELEMENT_SELECTION_INACTIVE_TEXT : colouralpha
SC_ELEMENT_SELECTION_INACTIVE_BACK : colouralpha

With colouralpha being specifically a 32-bit value:

Colours are set using the RGBA format (Red, Green, Blue, Alpha). This is similar to colour but with a byte of alpha added. They are combined as: red | (green << 8) | (blue << 16) | (alpha << 24). Fully opaque uses an alpha of 255.

It makes no difference when GDI rendering is active (as per the default), but DirectWrite will read a 24-bit RGB value as having a 0 alpha byte:

An application moving to Direct2D will also obtain the following features:

  • [ . . .]
  • The ability to support Grayscale text rendering. This correctly populates the destination alpha channel according to both the text brush opacity and the antialiasing of the text.

https://docs.microsoft.com/en-us/windows/win32/direct2d/direct2d-and-directwrite#glyph-rendering

from nppexec.

jabal1 avatar jabal1 commented on June 24, 2024

@d0vgan & @rdipardo

Thanks a lot to both of you !

The commands you indicated indeed solved my problem ! 👍

I am quite astonished and pleased by your in-depth knowledge of Scintilla, Notepad++ and its plugins ! 🥇

Thanks again for the support !

from nppexec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.