def _enable_lsp_modes(self): if cfg.lsp_code_completion and self.supports_completions: self._enable_mode(modes.CodeCompletionMode()) self._enable_mode(modes.AutoCompleteMode()) # These modes consume key presses that are used by the completion # modes, and should therefore be moved to the end. self._move_mode_to_end('AutoIndentMode') self._move_mode_to_end('SmartBackSpaceMode') if cfg.lsp_calltips and self.supports_calltips: self._enable_mode(lsp_modes.CalltipsMode()) # The diagnostics mode also does some bookkeeping that is generally # required for LSP support. Therefore it's always installed, but only # shows the actual diagnostics if the show_diagnostics keyword is True. diagnostics_mode = lsp_modes.DiagnosticsMode( show_diagnostics=cfg.lsp_diagnostics and self.supports_diagnostics) diagnostics_mode.set_ignore_rules([ ir.strip() for ir in cfg.lsp_diagnostics_ignore.split(u';') if ir.strip() ]) diagnostics_mode.server_status_changed.connect( self._on_server_status_changed) self._enable_mode(diagnostics_mode) if cfg.lsp_diagnostics and self.supports_diagnostics: self._enable_panel(panels.CheckerPanel(), panels.GlobalCheckerPanel.Position.LEFT) self._enable_panel(panels.GlobalCheckerPanel(), panels.GlobalCheckerPanel.Position.RIGHT) if cfg.lsp_symbols and self.supports_symbols: self._enable_mode( lsp_modes.SymbolsMode( cfg.lsp_symbols_kind.split(';') if isinstance( cfg.lsp_symbols_kind, basestring) else []))
def __init__(self, parent=None, server_script=server.__file__, interpreter=sys.executable, args=None, create_default_actions=True, color_scheme='qt', reuse_backend=False): super(PyCodeEdit, self).__init__(parent=parent, create_default_actions=create_default_actions) self.backend.start(server_script, interpreter, args, reuse=reuse_backend) self.setLineWrapMode(self.NoWrap) self.setWindowTitle("pyQode - Python Editor") # install those modes first as they are required by other modes/panels self.modes.append(modes.OutlineMode(defined_names)) # panels self.panels.append(panels.SearchAndReplacePanel(), panels.SearchAndReplacePanel.Position.BOTTOM) self.panels.append(panels.FoldingPanel()) self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.CheckerPanel()) self.panels.append(panels.GlobalCheckerPanel(), panels.GlobalCheckerPanel.Position.RIGHT) self.add_separator() # modes # generic self.modes.append(modes.ExtendedSelectionMode()) self.modes.append(modes.CaseConverterMode()) self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.FileWatcherMode()) self.modes.append(modes.RightMarginMode()) self.modes.append(modes.ZoomMode()) self.modes.append(modes.SymbolMatcherMode()) self.modes.append(modes.CodeCompletionMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode()) # python specifics self.modes.append(pymodes.PyAutoIndentMode()) self.modes.append(pymodes.PyAutoCompleteMode()) self.modes.append(pymodes.PyFlakesChecker()) self.modes.append(pymodes.PEP8CheckerMode()) self.modes.append(pymodes.CalltipsMode()) self.modes.append(pymodes.PyIndenterMode()) self.modes.append(pymodes.GoToAssignmentsMode()) self.modes.append(pymodes.CommentsMode()) self.modes.append( pymodes.PythonSH(self.document(), color_scheme=ColorScheme(color_scheme))) self.syntax_highlighter.fold_detector = PythonFoldDetector() self.panels.append(pypanels.QuickDocPanel(), api.Panel.Position.BOTTOM) self.panels.append(panels.EncodingPanel(), api.Panel.Position.TOP) self.panels.append(panels.ReadOnlyPanel(), api.Panel.Position.TOP)
def __init__(self, parent=None, server_script=server.__file__, interpreter=sys.executable, args=None, create_default_actions=True, color_scheme='default'): super(PyCodeEditor, self).__init__(parent=parent, create_default_actions=create_default_actions) self.backend.start(server_script, interpreter, args) self.setLineWrapMode(self.NoWrap) self.setWindowTitle("pyQode for LPy") # panels self.panels.append(panels.FoldingPanel()) self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.CheckerPanel()) self.panels.append(panels.GlobalCheckerPanel(), panels.GlobalCheckerPanel.Position.RIGHT) self._panel_search = panels.SearchAndReplacePanel() self.panels.append(self._panel_search, panels.SearchAndReplacePanel.Position.BOTTOM) self.panels.append(panels.EncodingPanel(), api.Panel.Position.TOP) self.add_separator() self.panels.append(pypanels.QuickDocPanel(), api.Panel.Position.BOTTOM) # modes # generic self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.FileWatcherMode()) self.modes.append(modes.RightMarginMode()) self.modes.append(modes.ZoomMode()) self.modes.append(modes.SymbolMatcherMode()) self.modes.append(modes.CodeCompletionMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode()) self.modes.append(modes.ExtendedSelectionMode()) # python specifics self.modes.append(pymodes.PyAutoIndentMode()) self.modes.append(pymodes.PyAutoCompleteMode()) # self.modes.append(pymodes.FrostedCheckerMode()) self.modes.append(pymodes.PEP8CheckerMode()) self.modes.append(pymodes.CalltipsMode()) self.modes.append(pymodes.PyIndenterMode()) self.modes.append(pymodes.GoToAssignmentsMode()) self.modes.append(pymodes.CommentsMode()) self.modes.append( pymodes.PythonSH(self.document(), color_scheme=ColorScheme(color_scheme))) self.syntax_highlighter.fold_detector = PythonFoldDetector()
def _setup_panels(self): self.search_panel = self.panels.append(panels.SearchAndReplacePanel(), api.Panel.Position.BOTTOM) self.folding_panel = self.panels.append(panels.FoldingPanel(), api.Panel.Position.LEFT) self.line_nbr_panel = self.panels.append(panels.LineNumberPanel(), api.Panel.Position.LEFT) self.checker_panel = self.panels.append(panels.CheckerPanel(), api.Panel.Position.LEFT) self.global_checker_panel = self.panels.append( panels.GlobalCheckerPanel(), api.Panel.Position.RIGHT)
def __init__(self, parent=None, color_scheme='qt'): super().__init__(parent=parent) self.setLineWrapMode(self.NoWrap) # install those modes first as they are required by other modes/panels self.modes.append(modes.OutlineMode(defined_names)) # panels self.panels.append(panels.SearchAndReplacePanel(), panels.SearchAndReplacePanel.Position.BOTTOM) self.panels.append(panels.FoldingPanel()) self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.CheckerPanel()) self.panels.append(panels.GlobalCheckerPanel(), panels.GlobalCheckerPanel.Position.RIGHT) # modes # generic self.modes.append(modes.CursorHistoryMode()) self.modes.append(modes.ExtendedSelectionMode()) self.modes.append(modes.CaseConverterMode()) self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.FileWatcherMode()) self.modes.append(modes.RightMarginMode()) self.modes.append(modes.ZoomMode()) self.modes.append(modes.SymbolMatcherMode()) self.modes.append(modes.CodeCompletionMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode()) # python specifics self.modes.append(pymodes.PyAutoIndentMode()) self.modes.append(pymodes.PyAutoCompleteMode()) self.modes.append(pymodes.FrostedCheckerMode()) self.modes.append(pymodes.PEP8CheckerMode()) self.modes.append(pymodes.CalltipsMode()) self.modes.append(pymodes.PyIndenterMode()) self.add_separator() self.modes.append(AddImportMode()) self.modes.append(pymodes.GoToAssignmentsMode()) self.modes.append(pymodes.CommentsMode()) self.modes.append( pymodes.PythonSH(self.document(), color_scheme=ColorScheme(color_scheme))) self.syntax_highlighter.fold_detector = PythonFoldDetector() self.panels.append(pypanels.QuickDocPanel(), pyqode_api.Panel.Position.BOTTOM) self.panels.append(panels.EncodingPanel(), pyqode_api.Panel.Position.TOP) self.breakpoints_panel = self.panels.append(panels.MarkerPanel()) self.line_highlighter = self.modes.append(modes.LineHighlighterMode()) self.restart_backend()
def __init__(self, parent=None, color_scheme='qt'): super().__init__(parent=parent) # panels self.panels.append(panels.FoldingPanel()) self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.CheckerPanel()) self.panels.append(panels.GlobalCheckerPanel(), panels.GlobalCheckerPanel.Position.RIGHT) # modes self.modes.append(modes.RightMarginMode()) self.caret_highlighter = self.modes.append( modes.CaretLineHighlighterMode()) self.modes.append( pymodes.PythonSH(self.document(), color_scheme=ColorScheme(color_scheme))) self.syntax_highlighter.fold_detector = PythonFoldDetector() self.breakpoints_panel = self.panels.append(panels.MarkerPanel())
def setup_editor(code_edit): # append panels p = panels.FoldingPanel(highlight_caret_scope=True) code_edit.panels.append(p) p.show() p = panels.LineNumberPanel() code_edit.panels.append(p) p.show() p = panels.MarkerPanel() code_edit.panels.append(p) p.show() p = panels.CheckerPanel() code_edit.panels.append(p) p.show() p = panels.SearchAndReplacePanel() code_edit.panels.append(p, p.Position.BOTTOM) p.show() p = panels.GlobalCheckerPanel() code_edit.panels.append(p, p.Position.RIGHT) p.show() # append modes code_edit.modes.append(modes.AutoCompleteMode()) code_edit.modes.append(modes.CaseConverterMode()) code_edit.modes.append(modes.FileWatcherMode()) code_edit.modes.append(modes.CaretLineHighlighterMode()) code_edit.modes.append(modes.RightMarginMode()) code_edit.modes.append( modes.PygmentsSyntaxHighlighter(code_edit.document())) code_edit.modes.append(modes.ZoomMode()) code_edit.modes.append(modes.CodeCompletionMode()) code_edit.modes.append(modes.AutoIndentMode()) code_edit.modes.append(modes.IndenterMode()) code_edit.modes.append(modes.SymbolMatcherMode()) code_edit.modes.append(modes.WordClickMode()) code_edit.modes.get(modes.FileWatcherMode).auto_reload = True code_edit.syntax_highlighter.fold_detector = IndentFoldDetector() code_edit.modes.append(modes.SmartBackSpaceMode()) code_edit.modes.append(modes.ExtendedSelectionMode()) code_edit.modes.append(modes.OccurrencesHighlighterMode())