Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

editor.markerDefinePixmap (XPM icons)?

Help
2011-05-07
2013-01-25
  • Jari Pennanen
    Jari Pennanen
    2011-05-07

    Hi!

    I'm wondering how to use this editor.markerDefinePixmap, specifically the XPM images.

    Following does not work, I don't get the blarg icon to sidebar, instead I get white circle:

    # See wikipedia http://en.wikipedia.org/wiki/X_PixMap#Comparison_with_other_formats
    blarg = [
        "16 7 2 1",
        "* c #000000",
        ". c #ffffff",
        "**..*...........",
        "*.*.*...........",
        "**..*..**.**..**",
        "*.*.*.*.*.*..*.*",
        "**..*..**.*...**",
        "...............*",
        ".............**."
    ]
    USER_MARKER = 2
    addSymbol = USER_MARKER + 1
    delSymbol = USER_MARKER + 2
    def testmarkers():
        # All symbols on 1 margin
        editor.setMarginMaskN(1,-1)
        
        # Create pixmap type marker
        # TODO: How do I do this? "\0".join doesn't seem to work!
        editor.markerDefinePixmap(addSymbol, "\0".join(blarg)) 
        editor.markerDeleteAll(-1)
        editor.markerAdd(5, addSymbol)
        console.write("Added symbol!\n")
        
    testmarkers()
    

    If I change USER_MARKER value it seems to always give me white circle too, quiet odd.

     
  • ed.markerDefinePixmap(24, '''/* XPM */
    static char * test_xpm = {
    "32 16 2 1",
    " c None",
    ". c #F08000", // color used for dithering
    ". . . . . . . . . . . . . . . . ",
    "                                ",
    If you take a look at this script from the Script Showcase, you'll how Scintilla expects it.  It expects it as a C struct, so like this:

    editor.markerDefinePixmap(24, '''/* XPM */
    static char * test_xpm[] = {
    "16 7 2 1",
        "* c #000000",
        ". c #ffffff",
        "**..*...........",
        "*.*.*...........",
        "**..*..**.**..**",
        "*.*.*.*.*.*..*.*",
        "**..*..**.*...**",
        "...............*",
        ".............**." };
    \0''')
    

    I've just tried it, and it shows up ok.  You might need to extend the width of the margin though.

    Cheers,
    Dave.