Intel Hex not higlighting



  • I have NPP 7.8.7 on my laptop and opening an Intel Hex file shows nice colour highlighting. Open the same file on my desktop running the same version - no highlighting ??
    Uninstalled NPP and installed 7.8.9 64 bit - still no highlighting.
    Intel Hex is listed on the Language list.
    Other languages have highlighting. Global colour overwrite is not checked.

    What am I missing?

    On a related question - NPP obviously knows how to calculate the checksum on the end of each line of the Intel Hex file, because it flags it in red when the checksum is wrong (on laptop). Question - is there a way to get NPP to insert (or show) the correct checksum after some of the data has been modified?

    Sample data:

    :10001C001FEF1093063F08951EE0109300040895FF
    :10002C00FBDF109104041460109304041091040479
    :10003C0012601093040410E008EC7CD110910404BD
    :10004C001D7F1093040410E008EC74D114E110939C
    :10005C000E3F10E8212A78941091063F112309F4E1
    :10006C00BCC010E01093063F10E010930A3F10E064
    :10007C001093093FE7E0FFE32497FB83EA8319E041
    

    TIA
    DG



  • @David-Griffiths said in Intel Hex not higlighting:

    It works for me on 7.8.9 as well.
    5e2e1587-7a91-4943-bb8e-b04647cc4e51-image.png

    Could it be that you are using a theme on your desktop which is different
    from the one on the laptop?

    is there a way to get NPP to insert (or show) the correct checksum after some of the data has been modified?

    I guess yes, one could use the Pythonscript plugin and either replaces the wrong value with the correct one or shows an annotation with the correct value.



  • @David-Griffiths

    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?



  • @Alan-Kilborn

    It does? Without a plugin doing it?

    Yes.

    6a071885-a9e4-4650-8e4d-9df8c8f348f0-image.png



  • @Ekopalypse

    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://www.keil.com/support/docs/1584/

    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 , so 9C


    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 !

    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?



  • @Alan-Kilborn

    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 :-)



  • @David-Griffiths

    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.


Log in to reply