def paste(self): """ Reimplement QsciScintilla's method to fix the following issue: on Windows, pasted text has only 'LF' EOL chars even if the original text has 'CRLF' EOL chars """ clipboard = QApplication.clipboard() text = unicode(clipboard.text()) if len(text.splitlines()) > 1: eol_chars = self.get_line_separator() clipboard.setText( eol_chars.join((text+eol_chars).splitlines()) ) # Standard paste TextEditBaseWidget.paste(self)
def setup(self): """Reimplement TextEditBaseWidget method""" TextEditBaseWidget.setup(self) # Wrapping if CONF.get('editor', 'wrapflag'): self.setWrapVisualFlags(QsciScintilla.WrapFlagByBorder) # Indentation self.setIndentationGuides(True) self.setIndentationGuidesForegroundColor(Qt.lightGray) # 80-columns edge self.setEdgeColumn(80) self.setEdgeMode(QsciScintilla.EdgeLine) # Auto-completion self.setAutoCompletionSource(QsciScintilla.AcsAll)
def __init__(self, parent=None): TextEditBaseWidget.__init__(self, parent) # Indicate occurences of the selected word self.connect(self, SIGNAL('cursorPositionChanged(int, int)'), self.__cursor_position_changed) self.__find_start = None self.__find_end = None self.__find_flags = None self.SendScintilla(QsciScintilla.SCI_INDICSETSTYLE, self.OCCURENCE_INDICATOR, QsciScintilla.INDIC_BOX) self.SendScintilla(QsciScintilla.SCI_INDICSETFORE, self.OCCURENCE_INDICATOR, 0x4400FF) self.supported_language = None self.comment_string = None # Mark errors, warnings, ... self.markers = [] self.marker_lines = {} self.error = self.markerDefine(QPixmap(get_image_path('error.png'), 'png')) self.warning = self.markerDefine(QPixmap(get_image_path('warning.png'), 'png')) # Scintilla Python API self.api = None # Mark occurences timer self.occurences_timer = QTimer(self) self.occurences_timer.setSingleShot(True) self.occurences_timer.setInterval(750) self.connect(self.occurences_timer, SIGNAL("timeout()"), self.__mark_occurences) # Context menu self.setup_context_menu() # Tab key behavior self.tab_indents = None self.tab_mode = True # see QsciEditor.set_tab_mode