Exemplo n.º 1
0
 def setMark(self, linenum, type):
     """Marks the given line number with a mark of the given type."""
     nums = [mark.blockNumber() for mark in self._marks[type]]
     if linenum in nums:
         return
     index = bisect.bisect_left(nums, linenum)
     mark = QTextCursor(self.document().findBlockByNumber(linenum))
     try:
         # only available in very recent PyQt4 versions
         mark.setKeepPositionOnInsert(True)
     except AttributeError:
         pass
     self._marks[type].insert(index, mark)
     self.marksChanged()
Exemplo n.º 2
0
 def setMark(self, linenum, type):
     """Marks the given line number with a mark of the given type."""
     nums = [mark.blockNumber() for mark in self._marks[type]]
     if linenum in nums:
         return
     index = bisect.bisect_left(nums, linenum)
     mark = QTextCursor(self.document().findBlockByNumber(linenum))
     try:
         # only available in very recent PyQt4 versions
         mark.setKeepPositionOnInsert(True)
     except AttributeError:
         pass
     self._marks[type].insert(index, mark)
     self.marksChanged()
Exemplo n.º 3
0
 def toggleMark(self, linenum, type):
     """Toggles the mark of the given type on the given line."""
     nums = [mark.blockNumber() for mark in self._marks[type]]
     index = bisect.bisect_left(nums, linenum)
     if linenum in nums:
         # remove double occurrences
         while True:
             del self._marks[type][index]
             del nums[index]
             if linenum not in nums:
                 break
             index = bisect.bisect_left(nums, linenum)
     else:
         mark = QTextCursor(self.document().findBlockByNumber(linenum))
         try:
             # only available in very recent PyQt4 versions
             mark.setKeepPositionOnInsert(True)
         except AttributeError:
             pass
         self._marks[type].insert(index, mark)
     self.marksChanged()
Exemplo n.º 4
0
 def toggleMark(self, linenum, type):
     """Toggles the mark of the given type on the given line."""
     nums = [mark.blockNumber() for mark in self._marks[type]]
     index = bisect.bisect_left(nums, linenum)
     if linenum in nums:
         # remove double occurrences
         while True:
             del self._marks[type][index]
             del nums[index]
             if linenum not in nums:
                 break
             index = bisect.bisect_left(nums, linenum)
     else:
         mark = QTextCursor(self.document().findBlockByNumber(linenum))
         try:
             # only available in very recent PyQt4 versions
             mark.setKeepPositionOnInsert(True)
         except AttributeError:
             pass
         self._marks[type].insert(index, mark)
     self.marksChanged()