def OnStoreBM(cls, msg): data = msg.GetData() buf = data.get('stc') line = data.get('line') mark = Bookmark() mark.Filename = buf.GetFileName() mark.Line = line if data.get('added', False): if mark not in cls._marks: # Store the stc bookmark handle mark.Handle = data.get('handle', None) # Store an alias for the bookmark name = u"" cline = buf.GetCurrentLine() if line == cline: name = buf.GetSelectedText() if not name: name = buf.GetLine(line) mark.Name = name.strip() cls._marks.append(mark) else: if mark in cls._marks: idx = cls._marks.index(mark) cls._marks.pop(idx)
def __init__(self, parent): super(BookmarkList, self).__init__(parent, style=wx.LC_REPORT|\ wx.LC_EDIT_LABELS|\ wx.LC_VIRTUAL) # Setup self._il = wx.ImageList(16, 16) self._idx = self._il.Add(Bookmark().Bitmap) self.SetImageList(self._il, wx.IMAGE_LIST_SMALL) self.InsertColumn(BookmarkList.BOOKMARK, _("Bookmark")) self.InsertColumn(BookmarkList.FILE_NAME, _("File Location")) self.InsertColumn(BookmarkList.LINE_NUM, _("Line Number")) self.setResizeColumn(BookmarkList.FILE_NAME + 1) #NOTE: +1 bug in mixin self.SetItemCount(len(EdBookmarks.GetMarks()))