Пример #1
0
 def highlight_current_line(self):
     """Highlight current line"""
     selection = QTextEdit.ExtraSelection()
     selection.format.setProperty(QTextFormat.FullWidthSelection,
                                  to_qvariant(True))
     selection.format.setBackground(self.currentline_color)
     selection.cursor = self.textCursor()
     selection.cursor.clearSelection()
     self.set_extra_selections('current_line', [selection])
     self.update_extra_selections()
Пример #2
0
 def __highlight(self, positions, color=None, cancel=False):
     if cancel:
         self.clear_extra_selections('brace_matching')
         return
     extra_selections = []
     for position in positions:
         if position > self.get_position('eof'):
             return
         selection = QTextEdit.ExtraSelection()
         selection.format.setBackground(color)
         selection.cursor = self.textCursor()
         selection.cursor.clearSelection()
         selection.cursor.setPosition(position)
         selection.cursor.movePosition(QTextCursor.NextCharacter,
                                       QTextCursor.KeepAnchor)
         extra_selections.append(selection)
     self.set_extra_selections('brace_matching', extra_selections)
     self.update_extra_selections()
Пример #3
0
 def highlight_current_cell(self):
     """Highlight current cell"""
     if self.cell_separators is None:
         return
     selection = QTextEdit.ExtraSelection()
     selection.format.setProperty(QTextFormat.FullWidthSelection,
                                  to_qvariant(True))
     selection.format.setBackground(self.currentcell_color)
     selection.cursor, whole_file_selected, whole_screen_selected =\
         self.select_current_cell_in_visible_portion()
     if whole_file_selected:
         self.clear_extra_selections('current_cell')
     elif whole_screen_selected:
         if self.has_cell_separators:
             self.set_extra_selections('current_cell', [selection])
             self.update_extra_selections()
         else:
             self.clear_extra_selections('current_cell')
     else:
         self.set_extra_selections('current_cell', [selection])
         self.update_extra_selections()