Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Change bookmark display

2011-05-06
2013-01-25
  • As noted in Notepad++ idea 113 https://sourceforge.net/apps/ideatorrent/notepad-plus/ideatorrent/idea/113/, bookmarks do not correctly antialias on dark background.  Here is a script which implements the four proposed solutions in the idea, but not exactly as proposed for solutions #1 and #2 (because of current Scintilla limitation). Simply set "solution" to the solution you like (or only copy that part of the code).  You can paste that code at end of "startup.py" and configure PythonScript initialisation ATSTARTUP.  For solution #2, bookmark margin can be disabled to save some space, and for solution #4 all margins can be disabled to save even more space.

    # Idea #113 https://sourceforge.net/apps/ideatorrent/notepad-plus/ideatorrent/idea/113/
    # Choose the solution: (solutions 1 and 2 are not complete because of Scintilla limitations) 
    solution = 2
    for ed in [editor1, editor2]:
        ed.setMarginMaskN(0, ed.getMarginMaskN(0) & ~0x1000000) # do not draw marker in line number margin (default)
        ed.setMarginMaskN(1, ed.getMarginMaskN(1) | 0x1000000)  # draw marker in second margin (default)
    
        if solution==4: # solution #4 Highlight the complete textline
            ed.markerDefine(24, MARKERSYMBOL.BACKGROUND), # mark whole line background using back color and alpha
            ed.markerSetBack(24, (255,170,0)) # line highlight color
            ed.markerSetAlpha(24, 80) # 256 to set line background color instead of using alpha blending
        elif solution==3: # solution #3 "good-old"...
            ed.markerDefine(24, MARKERSYMBOL.CIRCLE), # use a colored symbol (possible symbols are CIRCLE, ROUNDRECT, ARROW, SMALLRECT, SHORTARROW, ...  see MARKERSYMBOL in PythonScript documentation) with fore color contour and back color fill.
            ed.markerSetFore(24, (255,0,0)) # contour of symbol
            ed.markerSetBack(24, (255,255,0)) # filling
    
        elif solution==2: # incomplete solution #2, first verion (Scintilla draws line number under markers, not over)
            ed.markerDefine(24, MARKERSYMBOL.LEFTRECT), # LEFTRECT or FULLRECT using back color.  With current Scintilla FULLRECT is not a good idea for line number margin, but can be used in other margins
            ed.markerSetBack(24, (255,170,0)) # rect color
            ed.setMarginMaskN(0, ed.getMarginMaskN(0) | 0x1000000) # draw marks in line number margin
            if ed.getMarginWidthN(1)>0:
                ed.setMarginWidthN(1, 4) # reduce width of second margin (could also be set to 0, or "Display bookmark" unchecked in Settings/Preferences.../Editing)
        elif solution==2.1: # incomplete solution #2, second version  (Scintilla does not support aphablending of marker nor drawing line numbers over markers)
            # redefine mark pixmap with dithered rectangle
            ed.markerDefinePixmap(24, '''/* XPM */
    static char * test_xpm[] = {
    "32 16 2 1",
    "   c None",
    ".  c #F08000", // color used for dithering
    ". . . . . . . . . . . . . . . . ",
    "                                ",
    " . . . . . . . . . . . . . . . .",
    "                                ",
    ". . . . . . . . . . . . . . . . ",
    "                                ",
    " . . . . . . . . . . . . . . . .",
    "                                ",
    ". . . . . . . . . . . . . . . . ",
    "                                ",
    " . . . . . . . . . . . . . . . .",
    "                                ",
    ". . . . . . . . . . . . . . . . ",
    "                                ",
    " . . . . . . . . . . . . . . . .",
    "                                "};
    \0''')
            ed.setMarginMaskN(0, ed.getMarginMaskN(0) | 0x1000000) # draw marks in line number margin
            ed.setMarginMaskN(1, ed.getMarginMaskN(1) & ~0x1000000) # not in second margin
        elif solution==1: # incomplete solution #1 (Scintilla does not support aphablending of marker, but we can define a new marker without antialiasing, which should display correctly on black background)
            # redefine mark pixmap
            ed.markerDefinePixmap(24, '''/* XPM */
    static char * xpm[] = {
    "13 14 54 1",
    "   c None",
    ".  c #545254",
    "+  c #3C3E3C",
    "@  c #646464",
    "#  c #A4A4A4",
    "$  c #B7B8B7",
    "%  c #747284",
    "&  c #B4B2C4",
    "*  c #DCD7E4",
    "=  c #1C1A1C",
    "-  c #403E58",
    ";  c #5C5A8C",
    ">  c #7C7EAC",
    ",  c #7C8EBC",
    "'  c #242644",
    ")  c #282668",
    "!  c #24367C",
    "~  c #244A84",
    "{  c #2C5098",
    "]  c #14162C",
    "^  c #142E7C",
    "/  c #143789",
    "(  c #204990",
    "_  c #174091",
    ":  c #0C0630",
    "<  c #24327C",
    "[  c #2450A0",
    "}  c #345DB4",
    "|  c #3C68B8",
    "1  c #141244",
    "2  c #24428C",
    "3  c #3462B9",
    "4  c #4470C4",
    "5  c #4C7FD6",
    "6  c #4472CC",
    "7  c #24224C",
    "8  c #5C8DEC",
    "9  c #5C94F6",
    "0  c #5482DF",
    "a  c #619DF7",
    "b  c #6CA6FC",
    "c  c #64A2FC",
    "d  c #1C2E5C",
    "e  c #6CA2FC",
    "f  c #74B2FC",
    "g  c #7CB8FC",
    "h  c #1C3264",
    "i  c #346AD4",
    "j  c #7CBEFC",
    "k  c #3C72DC",
    "l  c #243250",
    "m  c #346AB4",
    "n  c #3C82DC",
    "o  c #6C6A6C",
    "     .+.     ",
    "   @##$##@   ",
    "  @%&***&%@  ",
    " =-;>,,,>;-= ",
    " ')!~{{{~!)' ",
    "])^/({{{(_^)]",
    ":<_[}|||}[_<:",
    "12[3455563[21",
    "7_365899063_7",
    " /|09abc904/ ",
    " d}8efgfb83d ",
    "  hiafjgakh  ",
    "   l~mnm~l   ",
    "     o@o     "};
    \0''')
    
     
  • klo
    klo
    2011-05-12

    About solution #2:
    if by 'not complete' you mean that highlight color is not drawn under line number, I'd say - it's complete :)

    That's my personal taste of course, but it looks really nice to me, and it is distinctive

    Hiding folding margin when there is no need for it is just neat

    Thanks again for your solutions

     
  • Yes, by ' not complete' I meant 'not exactly as proposed', because the color is not under line number but only on each side of it.  I tried to put the color under, but would have to modify Scintilla to do it.  The modification is easy, just have to put the marks drawing loop before the line number drawing loop, but we would have to verify that no editor using Scintilla rely on the fact that marks are over the numbers.

     
  • Paul Neubauer
    Paul Neubauer
    2012-03-13

    I am not clear on how to apply this idea. I don't have a startup.py file. Am I supposed to?

    How would I implement this? Do I simply create a startup.py file with this as the content?

    Does this require that I install Python? Does this idea only apply to the editing of Python files?

    Are startup files covered in the documentation? A first pass with Google does not show anything about them. Do you have a pointer for me?

    Thanks,
    Paul

     
  • Yes, you have to install the Python Script plugin for this to work. The startup.py file is the python script that is executed when the plugin starts; you need to set the initialization mode of Python Script plugin to "ATSTARTUP" if you want it to start at the same time as Notepad++ (otherwise it defaults to start when you first select a script in its menu).  The initialization mode is changed in menu Plugins->Python Script->Configuration, at the bottom of the dialog (you can choose between "ATSTARTUP" and "LAZY").