def __init__(self): QPlainTextEdit.__init__(self, u'>>> ') self.setUndoRedoEnabled(False) styles.set_editor_style(self, resources.CUSTOM_SCHEME) self.setToolTip(self.tr("Show/Hide (F4)")) self._patIsWord = re.compile('\w+') self.prompt = u'>>> ' self._console = console.Console() self._history = [] self._braces = None self.imports = ['import __builtin__'] self.patFrom = re.compile('^(\\s)*from ((\\w)+(\\.)*(\\w)*)+ import') self.patImport = re.compile('^(\\s)*import (\\w)+') self.patObject = re.compile('[^a-zA-Z0-9_\\.]') self.completer = completer.CompleterWidget(self) self.okPrefix = QRegExp('[.)}:,\]]') #Create Context Menu self._create_context_menu() self._highlighter = highlighter.Highlighter(self.document(), 'python', resources.CUSTOM_SCHEME) self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.highlight_current_line()
def restyle(self, syntaxLang=None): styles.set_editor_style(self, resources.CUSTOM_SCHEME) if not syntaxLang: ext = file_manager.get_file_extension(self.ID) self.highlighter.apply_highlight( settings.EXTENSIONS.get(ext, 'python'), resources.CUSTOM_SCHEME) else: self.highlighter.apply_highlight( str(syntaxLang), resources.CUSTOM_SCHEME)
def restyle(self, syntaxLang=None): styles.set_editor_style(self, resources.CUSTOM_SCHEME) if self.highlighter is None: self.highlighter = highlighter.Highlighter(self.document(), None, resources.CUSTOM_SCHEME) if not syntaxLang: ext = file_manager.get_file_extension(self.ID) self.highlighter.apply_highlight( settings.EXTENSIONS.get(ext, 'python'), resources.CUSTOM_SCHEME) else: self.highlighter.apply_highlight(str(syntaxLang), resources.CUSTOM_SCHEME)
def restyle(self, syntaxLang=None): styles.set_editor_style(self, resources.CUSTOM_SCHEME) if self.highlighter is None: self.highlighter = highlighter.Highlighter(self.document(), None, resources.CUSTOM_SCHEME, self.errors, self.pep8) if not syntaxLang: ext = file_manager.get_file_extension(self.ID) self.highlighter.apply_highlight( settings.EXTENSIONS.get(ext, 'python'), resources.CUSTOM_SCHEME) if self._mini: self._mini.highlighter.apply_highlight( settings.EXTENSIONS.get(ext, 'python'), resources.CUSTOM_SCHEME) else: self.highlighter.apply_highlight( str(syntaxLang), resources.CUSTOM_SCHEME) if self._mini: self._mini.highlighter.apply_highlight( str(syntaxLang), resources.CUSTOM_SCHEME)
def __init__(self, filename, project): QPlainTextEdit.__init__(self) itab_item.ITabItem.__init__(self) #Config Editor self.set_flags() self.__lines_count = None self._sidebarWidget = sidebar_widget.SidebarWidget(self) if filename in settings.BREAKPOINTS: self._sidebarWidget._breakpoints = settings.BREAKPOINTS[filename] if filename in settings.BOOKMARKS: self._sidebarWidget._bookmarks = settings.BOOKMARKS[filename] self.pep8 = pep8_checker.Pep8Checker(self) self.errors = errors_checker.ErrorsChecker(self) self.textModified = False self.newDocument = True self.highlighter = None self.syncDocErrorsSignal = False #Set editor style styles.set_editor_style(self, resources.CUSTOM_SCHEME) self.set_font(settings.FONT_FAMILY, settings.FONT_SIZE) #For Highlighting in document self.extraSelections = [] self._patIsWord = re.compile('\w+') #Brace matching self._braces = None self._mtime = None self.encoding = None #Flag to dont bug the user when answer *the modification dialog* self.ask_if_externally_modified = True #Dict functions for KeyPress self.preKeyPress = { Qt.Key_Tab: self.__insert_indentation, Qt.Key_Backspace: self.__backspace, Qt.Key_Home: self.__home_pressed, Qt.Key_Enter: self.__ignore_extended_line, Qt.Key_Return: self.__ignore_extended_line, Qt.Key_BracketRight: self.__brace_completion, Qt.Key_BraceRight: self.__brace_completion, Qt.Key_ParenRight: self.__brace_completion} self.postKeyPress = { Qt.Key_Enter: self.__auto_indent, Qt.Key_Return: self.__auto_indent, Qt.Key_BracketLeft: self.__complete_braces, Qt.Key_BraceLeft: self.__complete_braces, Qt.Key_ParenLeft: self.__complete_braces, Qt.Key_Apostrophe: self.__complete_braces, Qt.Key_QuoteDbl: self.__complete_braces} self.connect(self, SIGNAL("updateRequest(const QRect&, int)"), self._sidebarWidget.update_area) self.connect(self, SIGNAL("undoAvailable(bool)"), self._file_saved) self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.connect(self.pep8, SIGNAL("finished()"), self.show_pep8_errors) self.connect(self.errors, SIGNAL("finished()"), self.show_static_errors) self.connect(self, SIGNAL("blockCountChanged(int)"), self._update_file_metadata) #Context Menu Options self.__actionFindOccurrences = QAction( self.tr("Find Usages"), self) self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"), self._find_occurrences)
def restyle(self): styles.set_editor_style(self, resources.CUSTOM_SCHEME) self._highlighter.apply_highlight('python', resources.CUSTOM_SCHEME)
def __init__(self, filename, project): QPlainTextEdit.__init__(self) itab_item.ITabItem.__init__(self) #Config Editor self.set_flags() self.__lines_count = None self._sidebarWidget = sidebar_widget.SidebarWidget(self) if filename in settings.BREAKPOINTS: self._sidebarWidget._breakpoints = settings.BREAKPOINTS[filename] if filename in settings.BOOKMARKS: self._sidebarWidget._bookmarks = settings.BOOKMARKS[filename] self.pep8 = pep8_checker.Pep8Checker(self) self.errors = errors_checker.ErrorsChecker(self) self.textModified = False self.newDocument = True self.highlighter = None self.syncDocErrorsSignal = False #Set editor style styles.set_editor_style(self, resources.CUSTOM_SCHEME) self.set_font(settings.FONT_FAMILY, settings.FONT_SIZE) #For Highlighting in document self.extraSelections = [] self._patIsWord = re.compile('\w+') #Brace matching self._braces = None self._mtime = None self.encoding = None #Flag to dont bug the user when answer *the modification dialog* self.ask_if_externally_modified = True #Dict functions for KeyPress self.preKeyPress = { Qt.Key_Tab: self.__insert_indentation, Qt.Key_Backspace: self.__backspace, Qt.Key_Home: self.__home_pressed, Qt.Key_Enter: self.__ignore_extended_line, Qt.Key_Return: self.__ignore_extended_line, Qt.Key_BracketRight: self.__brace_completion, Qt.Key_BraceRight: self.__brace_completion, Qt.Key_ParenRight: self.__brace_completion } self.postKeyPress = { Qt.Key_Enter: self.__auto_indent, Qt.Key_Return: self.__auto_indent, Qt.Key_BracketLeft: self.__complete_braces, Qt.Key_BraceLeft: self.__complete_braces, Qt.Key_ParenLeft: self.__complete_braces, Qt.Key_Apostrophe: self.__complete_braces, Qt.Key_QuoteDbl: self.__complete_braces } self.connect(self, SIGNAL("updateRequest(const QRect&, int)"), self._sidebarWidget.update_area) self.connect(self, SIGNAL("undoAvailable(bool)"), self._file_saved) self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.connect(self.pep8, SIGNAL("finished()"), self.show_pep8_errors) self.connect(self.errors, SIGNAL("finished()"), self.show_static_errors) self.connect(self, SIGNAL("blockCountChanged(int)"), self._update_file_metadata) #Context Menu Options self.__actionFindOccurrences = QAction(self.tr("Find Usages"), self) self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"), self._find_occurrences)