Example #1
0
 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)
Example #2
0
 def setup(self):
     """Reimplement TextEditBaseWidget method"""
     TextEditBaseWidget.setup(self)
     
     # Wrapping
     if CONF.get('editor', 'wrapflag'):
         self.setWrapVisualFlags(QsciScintilla.WrapFlagByBorder)
     
     # 80-columns edge
     self.setEdgeColumn(80)
     self.setEdgeMode(QsciScintilla.EdgeLine)
     
     # Auto-completion
     self.setAutoCompletionSource(QsciScintilla.AcsAll)
Example #3
0
    def __init__(self, parent=None):
        TextEditBaseWidget.__init__(self, parent)
        
        # Do not remove the following attribut (compat. with QtEditor)
        self.highlighter = None
        
        self.eol_mode = None

        # Code analysis markers: errors, warnings
        self.ca_markers = []
        self.ca_marker_lines = {}
        self.error = self.markerDefine(QPixmap(get_image_path('error.png'),
                                               'png'))
        self.warning = self.markerDefine(QPixmap(get_image_path('warning.png'),
                                                 'png'))
        
        # Todo finder
        self.todo_lines = {}
        self.todo_markers = []
        self.todo = self.markerDefine(QPixmap(get_image_path('todo.png'),
                                              'png'))
        
        # Mark occurences timer
        self.occurence_highlighting = None
        self.occurence_timer = QTimer(self)
        self.occurence_timer.setSingleShot(True)
        self.occurence_timer.setInterval(1500)
        self.connect(self.occurence_timer, SIGNAL("timeout()"), 
                     self.__mark_occurences)
        self.occurences = []
        
        # Scrollbar flag area
        self.scrollflagarea_enabled = None
        self.scrollflagarea = ScrollFlagArea(self)
        self.scrollflagarea.hide()
        
        self.setup_editor_args = None
        
        self.document_id = id(self)
                    
        # 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,
                           0x10A000)
        self.SendScintilla(QsciScintilla.SCI_INDICSETSTYLE,
                           self.CA_REFERENCE_INDICATOR,
                           QsciScintilla.INDIC_SQUIGGLE)
        self.SendScintilla(QsciScintilla.SCI_INDICSETFORE,
                           self.CA_REFERENCE_INDICATOR,
                           0x39A2F1)

        self.supported_language = None
        self.classfunc_match = None
        self.comment_string = None
        
        # Current line and find markers
        self.currentline_marker = None
        self.foundline_markers = []
        self.currentline = self.markerDefine(QsciScintilla.Background)
        bcol = CONF.get('editor', 'currentline/backgroundcolor')
        self.setMarkerBackgroundColor(QColor(bcol), self.currentline)
        self.foundline = self.markerDefine(QsciScintilla.Background)
        bcol = CONF.get('editor', 'foundline/backgroundcolor')
        self.setMarkerBackgroundColor(QColor(bcol), self.foundline)

        # Scintilla Python API
        self.api = None
        
        # Context menu
        self.setup_context_menu()
        
        # Tab key behavior
        self.tab_indents = None
        self.tab_mode = True # see QsciEditor.set_tab_mode