Menu

Adding markers to search results

Help
2014-11-22
2014-11-22
  • ChildeAgrestis

    ChildeAgrestis - 2014-11-22

    I am trying to write a script that will bookmark lines that contain certain text. So far I have:

    editor.markerDeleteAll(0)
    def bookmarks(lineText, lineNumber, totalLines):
        patterns = ['>','<','[',']','SESSION']
        for p in patterns:
            if lineText.find(p) > -1:
                editor.markerAdd(lineNumber, 0) 
        return 1
    
    editor.forEachLine(bookmarks)
    

    This successfully finds the text being searched for, but neither deletes existing bookmarks (those added in the normal way by pressing F2) nor adds new ones. What am I misunderstanding?

     

    Last edit: ChildeAgrestis 2014-11-22
    • Dave Brotherstone

      It's the marker number. If you mark a line, then use markerGet (at least i
      think that's what its called, sadly scintilla naming is not consistent) on
      that line, you can find the marker number. From memory, that gives you the
      integer representation, but you provide the bit number to markerAdd - so
      bit 0 is 1, bit 1 is 2, bit 2 is 4, 3 is 8 and so on.

      I have a feeling notepad++ uses marker 19 for the bookmarks, but that's
      more or less a guess!

      Hope that helps.
      Dave

       
  • ChildeAgrestis

    ChildeAgrestis - 2014-11-22

    Many thanks! And it turns out the standard notepad++ bookmark marker number is 24.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.