Intel Hex not higlighting
-
NPP obviously knows how to calculate the checksum on the end of each line of the Intel Hex file
It does? Without a plugin doing it?
-
-
I guess really ambitious lexing! :-)
Hmmm, when I try it with that data the FF is green like you first showed, not red like your second screenshot.
-
@Alan-Kilborn said in Intel Hex not higlighting:
I guess really ambitious lexing!
Lol
It would be nice if the builtin lexers would show code which isn’t efficient :-D -
@Alan-Kilborn Did you change the last digit before the FF from 5 to 6 like Eko did?
-
Hello, @david-griffiths, @ekopalypse, @alan-kilborn and All
You can find a good documentation on the
Intel Hex File Format
from below :https://developer.arm.com/documentation/ka003292/latest
https://en.wikipedia.org/wiki/Intel_HEX
And I deduced that the checksum can be calculated from this formula :
CheckSum = 256 - ( ∑ Byte Values ) MOD 256
Each Byte Value represents the decimal value of the next two hexadecimal codes, minus the last two ones, standing for the checksum
For instance, the fourth line, of your example, is :
vv----- CheckSum :10004C001D7F1093040410E008EC74D114E110939C <--------------------------------------> Data Range
So its checksum is :
= 256 - (10h + 00h + 4Ch + 00h + 1Dh + 7Fh + 10h + 93h + 04h + 04h + 10h + E0h + 08h + ECh + 74h + D1h + 14h + E1h + 10h + 93h) mod 256 = 256 - ( 16 + 0 + 76 + 0 + 29 + 127 + 16 + 147 + 4 + 4 + 16 + 224 + 8 + 236 + 116 + 209 + 20 + 225 + 16 + 147) mod 256 = 256 - 1636 mod 256 = 256 - 100
Thus, the checksum of the fourth line is
156
, so9C
BTW, it’s work pointing out that the background color of the
CHECKSUM
andCHECKSUM_WRONG
styles of theIntel Hex
language are totally transparent (α = 0
) So, for instance, the default red background of a wrong checksum is not visible if this line is the current N++ line with usual very pale blue background color !Best Regards,
guy038
-
@guy038 said in Intel Hex not higlighting:
BTW, it’s work pointing out that the background color of the CHECKSUM and CHECKSUM_WRONG styles of the Intel Hex language are totally transparent ( α = 0 ) So, for instance, the default red background of a wrong checksum is not visible if this line is the current N++ line with usual very pale blue background color !
Interesting. What’s the way around that, if any?
-
@Alan-Kilborn said in Intel Hex not higlighting:
What’s the way around that, if any?
Change the foreground color of CHECKSUM_WRONG to something that contrasts both with its red background color and with your Global Styles > Current Line Background > Background color.
-
@PeterJones said in Intel Hex not higlighting:
Change the foreground color of CHECKSUM_WRONG to something that contrasts both with its red background color and with your Global Styles > Current Line Background > Background color.
Well…yea…but I meant, isn’t there a way to do something to the current-line-background color so that you can just get the red there (or close to it due to blending of colors) for the non-current line case?
-
isn’t there a way to do something to the current-line-background color so that you can just get the red there (or close
I think the problem isn’t that the red has transparency; I think the problem is that the current-line-background has no transparency and is drawn over the red, so the current-line-background is the only visible background. It might be possible if the current-line-transparency could be set to 50% or something of that ilk, but that cannot be done in the GUI.
I tried editing stylers.xml to use either the MSB or LSB as an alpha value for the current line background
<WidgetStyle name="Current line background colour" styleID="0" bgColor="E8E8FF80" colorStyle="1" fontStyle="0" /> or <WidgetStyle name="Current line background colour" styleID="0" bgColor="80E8E8FF" colorStyle="1" fontStyle="0" />
But either was interpreted as invalid color, and current-line-background became black.
So to add transparency to current line background, it would have to be a codebase edit.
-
@PeterJones said in Intel Hex not higlighting:
So to add transparency to current line background, it would have to be a codebase edit.
I did some searching and found THIS as probably related.
-
@guy038 Thanks Guy. I know how to calculate the checksum but so does N++ and I would like it to be automatically calculated for me when I edit a line.
BTW I am still none the wiser as to why my desktop PC only wants to show Intel Hex in monochrome ??
-
@David-Griffiths said in Intel Hex not higlighting:
I know how to calculate the checksum but so does N++ and I would like it to be automatically calculated for me when I edit a line.
This goes beyond the responsibility N++ signs up for. :-)
You could certainly do something for it with a scripting plugin, e.g. Pythonscript. -
@Alan-Kilborn Yes I agree it is more than I expected from N++ but as it does know how to calculate the checksum, it would be a very small step to add a right click or such that inserted the correct value, would it not?
-
@David-Griffiths said in Intel Hex not higlighting:
N++ … does know how to calculate the checksum
Notepad++ code has absolutely no idea how to do this checksum.
It isn’t doing it.
The underlying lexer is doing it, which comes from a separate project, called Scintilla. -
@Alan-Kilborn Thanks for clarifying Alan. My knowledge of the inner workings of N++ needs work :-)
-
Sorry, I was busy with some personal matters.
Here’s a python script that hopefully does what you want. If there is something else you might want to have or it doesn’t do what you want it to be done I would kindly ask to use the github issue tracker in my repo. -
@Ekopalypse Thanks for posting this - sorry I only just noticed it. Better late than never :-)
Where should I save the file and how do invoke the script?
Any ideas why I am not seeing the highlighting on my Win10 PC? -
@David-Griffiths said in Intel Hex not higlighting:
sorry I only just noticed it. Better late than never
Wow, that was a long layoff…
Where should I save the file and how do invoke the script?
There are some basic instructions for this type of scripting HERE. See the PeterJones Jan 19, 2021 4:12pm posting.
-
@Alan-Kilborn Thank you Alan. I have installed the PythonScript plugin and created the script.
When I open a file containing 9 lines of Intel Hex and run the script, precisely nothing happens ??
This is on my desktop which does not show the highlighting of the hex file. I then tried on my laptop, which does the highlighting correctly, and the script works.
So back to the original question, why does my desktop not show the highlighting? Both running NPP v8.1.5