def _load_minimap(self, show): if show: if self._mini is None: self._mini = minimap.MiniMap(self) # Signals self.SCN_UPDATEUI.connect(self._mini.scroll_map) self.SCN_ZOOM.connect(self._mini.slider.update_position) self._mini.setDocument(self.document()) self._mini.setLexer(self.lexer) # FIXME: register syntax self._mini.show() self._mini.adjust_to_parent() elif self._mini is not None: # FIXME: lost doc pointer? self._mini.shutdown() self._mini.deleteLater() self._mini = None
def __init__(self, neditable): QPlainTextEdit.__init__(self) itab_item.ITabItem.__init__(self) self._neditable = neditable #Config Editor self.set_flags() self.__lines_count = None self.lang = 'python' self._last_block_position = 0 self.__lines_count = 0 self._sidebarWidget = sidebar_widget.SidebarWidget(self, neditable) self.highlighter = None self.allows_less_indentation = ['else', 'elif', 'finally', 'except'] #Set editor style self.apply_editor_style() self.set_font(settings.FONT_FAMILY, settings.FONT_SIZE) #For Highlighting in document self.extraSelections = [] self._selected_word = '' self._patIsWord = re.compile('\w+') #Brace matching self._braces = None self.__encoding = None #Completer self.completer = completer_widget.CodeCompletionWidget(self) #Flag to dont bug the user when answer *the modification dialog* #self.just_saved = False #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_Colon: self.__retreat_to_keywords, Qt.Key_BracketRight: self.__brace_completion, Qt.Key_BraceRight: self.__brace_completion, Qt.Key_ParenRight: self.__brace_completion, Qt.Key_Apostrophe: self.__quot_completion, Qt.Key_QuoteDbl: self.__quot_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_quotes, Qt.Key_QuoteDbl: self.__complete_quotes } self._current_line_color = QColor( resources.CUSTOM_SCHEME.get( 'current-line', resources.COLOR_SCHEME['current-line'])) self.connect(self, SIGNAL("updateRequest(const QRect&, int)"), self._sidebarWidget.update_area) #FIXME: Should file saved be handled by neditable?? self.connect(self, SIGNAL("undoAvailable(bool)"), self._file_saved) self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.connect(self, SIGNAL("blockCountChanged(int)"), self._update_file_metadata) self._mini = None if settings.SHOW_MINIMAP: self._mini = minimap.MiniMap(self) self._mini.show() #Indentation self.load_project_config() #Context Menu Options self.__actionFindOccurrences = QAction(self.tr("Find Usages"), self) self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"), self._find_occurrences) # Set the editor after initialization self._neditable.set_editor(self)
def __init__(self, filename, project, project_obj=None): 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.migration = migration_2to3.MigrationTo3(self) self.textModified = False self.newDocument = True self.highlighter = None self.syncDocErrorsSignal = False self._selected_word = '' #Set editor style self.apply_editor_style() self.set_font(settings.FONT_FAMILY, settings.FONT_SIZE) #For Highlighting in document self.extraSelections = [] self.wordSelection = [] self._patIsWord = re.compile('\w+') #Brace matching self._braces = None self.__encoding = None #Completer self.completer = completer_widget.CodeCompletionWidget(self) #Indentation if project_obj is not None: self.indent = project_obj.indentation self.useTabs = project_obj.useTabs else: self.indent = settings.INDENT self.useTabs = settings.USE_TABS #Flag to dont bug the user when answer *the modification dialog* self.ask_if_externally_modified = False self.just_saved = False #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, Qt.Key_Apostrophe: self.__quot_completion, Qt.Key_QuoteDbl: self.__quot_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_quotes, Qt.Key_QuoteDbl: self.__complete_quotes } 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.migration, SIGNAL("finished()"), self.show_migration_info) self.connect(self.errors, SIGNAL("finished()"), self.show_static_errors) self.connect(self, SIGNAL("blockCountChanged(int)"), self._update_file_metadata) self._mini = None if settings.SHOW_MINIMAP: self._mini = minimap.MiniMap(self) self._mini.show() self.connect(self, SIGNAL("updateRequest(const QRect&, int)"), self._mini.update_visible_area) #Set tab usage if self.useTabs: self.set_tab_usage() #Context Menu Options self.__actionFindOccurrences = QAction(self.tr("Find Usages"), self) self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"), self._find_occurrences)