Location navigate plugin + Python editor.markerAdd() colors

  • When i set the colors of a python marker and add a mark, the location navigate plugin will override those colors if i have modified a line. Is there anyway around this?

  • @Anthony-Blinco ,

    Perhaps try to choose a marker ID that Location Navigate doesn’t use. There are only 32 marker numbers (0…31) and 25…31 are used by Scintilla, and 21-24 appear to also be defined by Notepad++. I doubt that Location Navigate uses all of 0…20, so you could keep trying until you found one that LN doesn’t use (or check LN’s source code).

    I checked for which ones were already defined on my setup using the PythonScript console:

    >>> for mn in range(0,32):
    ...     console.write("symbol#{} => {:02x}\n".format(mn, editor.markerSymbolDefined(mn)))

    You could probably do something similar on yours… maybe make sure that LN has marked changed lines before running that, in case it doesn’t add in its markers until it finds changed lines for the first time.

    Good luck.

  • @PeterJones said in Location navigate plugin + Python editor.markerAdd() colors:

    doubt that Location Navigate uses all of 0…20

    IIRC, Location Navigate uses 10 and 11 for saved and changed.


  • I am using 16, i have tried 8 as well and it still apears to override my colors.
    In the end i set Location navigate to use a mark in the margin rather than highlighting the line.
    I would much prefer the highlight though.
    Thanks for the info, very handy as usual

  • On an issue related to this.
    I am leaving markers in the text file to indicate which lines have been marked.
    I use a startup script callback BUFFERACTIVATED to pre-process the file and set the markers , if any.
    Is there a way i can set some flag on a per buffer basis to say that i have already processed this file?

  • @Anthony-Blinco

    There are several ways to accomplish this, my preferred way when I need flags is to use the setProperty and getProperty methods

    >>> help(editor.setProperty)
    Help on method setProperty:
    setProperty(...) method of Npp.Editor instance
        setProperty( (Editor)arg1, (object)key, (object)value) -> None :
            Set up a value that may be used by a lexer for some optional feature.
    >>> help(editor.getProperty)
    Help on method getProperty:
    getProperty(...) method of Npp.Editor instance
        getProperty( (Editor)arg1, (object)key) -> str :
            Retrieve a "property" value previously set with SetProperty.
            Result is NUL-terminated.

    so with something like

    editor.setProperty('initialized', '1')

  • @Ekopalypse go this far, so I’ll add this:

    If you .setProperty(), that property value string gets attached to the active file document.
    If you switch documents and do a .getProperty() for the same property argument, you’ll get an empty string returned.
    If you switch back to the original doc and do a .getProperty() on the property argument, you’ll get your original value returned.

    Maybe obvious, but perhaps worth explicitly stating.

  • @Anthony-Blinco said in Location navigate plugin + Python editor.markerAdd() colors:

    I am using 16, i have tried 8 as well and it still apears to override my colors.

    If you haven’t already, it’s worth giving Markers section of Scintilla docs a read. You define a marker and map it to a type - defined colors for it and then it is applied cumulatively to a line. Marker numbers are just powers of 2 (0-31) to fill in a bitmap to tell which marker values are enabled for each line.

    For example, using Location Navigate and a Notepad++ bookmark all on the same line, the marker value is:

    DEC: 16778240
    BIN: 0000 0001 0000 0000 0000 0100 0000 0000

    After saving, the value is:

    DEC: 16779264
    BIN: 0000 0001 0000 0000 0000 1000 0000 0000


    Notice, the most significant 1 in the marker value doesn’t change - that’s the Notepad++ bookmark marker value 24. The least significant 1 in both numbers does change - that’s LocNav using 10 for a change marker and 11 for a saved marker. In both instances, the actual “marker” number for the line is the “total” of all markers on that line.

    Hope this helps.


  • Thanks for the very detailed responses.
    Properties look like they might do the trick for me.
    I will definitely read the Scintilla docs as i’m sure i haven’t implemented them properly.

Log in to reply