def __init__(self, parent=None): super(CodeEditor, self).__init__(parent, False) # self.setObjectName( 'CodeEditor' ) self.font_size = 12 self.use_spaces_instead_of_tabs = False server_script = server.__file__ interpreter = sys.executable # self.backend.start( server_script, interpreter, None, reuse=True ) # append panels self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.SearchAndReplacePanel(), Panel.Position.BOTTOM) self.panels.append(panels.FoldingPanel()) # append modes # self.modes.append(modes.AutoCompleteMode()) self.modes.append(modes.ExtendedSelectionMode()) self.modes.append(modes.CaseConverterMode()) # self.modes.append(modes.FileWatcherMode()) self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.RightMarginMode()) sh = self.modes.append( modes.PygmentsSH(self.document(), color_scheme=ColorScheme('monokai'))) sh.fold_detector = IndentFoldDetector() self.modes.append(modes.ZoomMode()) # self.modes.append(modes.CodeCompletionMode()) self.modes.append(modes.AutoIndentMode()) self.modes.append(modes.IndenterMode()) self.modes.append(modes.SymbolMatcherMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode())
def __init__(self, parent=None, server_script=server.__file__, interpreter=sys.executable, args=None, create_default_actions=True, color_scheme='qt'): super(GenericCodeEdit, self).__init__(parent, create_default_actions) from pyqode.core import panels from pyqode.core import modes self.backend.start(server_script, interpreter, args) # append panels self.panels.append(panels.FoldingPanel()) self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.SearchAndReplacePanel(), Panel.Position.BOTTOM) self.panels.append(panels.EncodingPanel(), Panel.Position.TOP) # append modes self.modes.append(modes.AutoCompleteMode()) self.add_separator() self.modes.append(modes.CaseConverterMode()) self.modes.append(modes.FileWatcherMode()) self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.RightMarginMode()) self.modes.append(modes.PygmentsSyntaxHighlighter( self.document(), color_scheme=ColorScheme(color_scheme))) self.modes.append(modes.ZoomMode()) self.modes.append(modes.CodeCompletionMode()) self.modes.append(modes.AutoIndentMode()) self.modes.append(modes.IndenterMode()) self.modes.append(modes.SymbolMatcherMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode()) self.modes.append(modes.ExtendedSelectionMode()) self.syntax_highlighter.fold_detector = IndentFoldDetector()
def _init_code_edit(self, backend): self.modes.append(modes.SymbolMatcherMode()) self.modes.append(modes.IndenterMode()) super(Terminal, self)._init_code_edit(backend) try: self.panels.remove('ReadOnlyPanel') except KeyError: pass
def configure_modes_and_panels(self): # Modes self.modes.append(modes.IndenterMode()) self.modes.append(modes.AutoIndentMode()) self.modes.append(modes.AutoCompleteMode()) self.modes.append(CommentsMode()) # Panels self.panels.append(LineNumberPanel(), api.Panel.Position.LEFT) self.panels.append(panels.SearchAndReplacePanel(), api.Panel.Position.BOTTOM)
def _init_code_edit(self, backend): self.modes.append(modes.SymbolMatcherMode()) self.modes.append(CodeCompletionMode()) self.modes.append(pymodes.PyAutoCompleteMode()) self.modes.append(modes.IndenterMode()) super(PyConsole, self)._init_code_edit(backend) self.modes.append( SyntaxHighlighter(self.document(), color_scheme=ColorScheme( self._pygment_color_scheme))) try: self.panels.remove('ReadOnlyPanel') except KeyError: pass self.update_terminal_colors()
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(JSONCodeEdit, self).__init__(parent, create_default_actions=create_default_actions) self.backend.start(server_script, interpreter, args, reuse=reuse_backend) # append panels self.panels.append(panels.SearchAndReplacePanel(), Panel.Position.BOTTOM) self.panels.append(panels.FoldingPanel()) self.panels.append(panels.LineNumberPanel()) self.panels.append(json_panels.NavigationPanel(), Panel.Position.TOP) self.panels.append(panels.CheckerPanel()) # append modes self.modes.append(json_modes.AutoCompleteMode()) self.add_separator() self.modes.append(modes.ExtendedSelectionMode()) self.modes.append(modes.CaseConverterMode()) self.modes.append(modes.FileWatcherMode()) self.modes.append(modes.CaretLineHighlighterMode()) self.sh = self.modes.append( json_modes.JSONSyntaxHighlighter( self.document(), color_scheme=ColorScheme(color_scheme))) self.modes.append(modes.IndenterMode()) self.modes.append(modes.ZoomMode()) self.modes.append(modes.CodeCompletionMode()) self.modes.append(modes.AutoIndentMode()) self.modes.append(json_modes.AutoIndentMode()) self.modes.append(modes.SymbolMatcherMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode()) self.modes.append(json_modes.JSONLinter()) self.syntax_highlighter.fold_detector = JSONFoldDetector() self.panels.append(panels.EncodingPanel(), Panel.Position.TOP) self.panels.append(panels.ReadOnlyPanel(), Panel.Position.TOP)
def __init__(self, parent=None, server_script=None, interpreter=sys.executable, args=None, create_default_actions=True, color_scheme='qt', reuse_backend=True): super(RstCodeEdit, self).__init__(parent, create_default_actions) if server_script is None: server_script = self.DEFAULT_SERVER print 'is freezed?', hasattr(sys, 'frozen') print self.DEFAULT_SERVER print sys.executable print os.getcwd() sys.frozen = True self.backend.start(server_script, interpreter, args, reuse=reuse_backend) # append panels self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.SearchAndReplacePanel(), api.Panel.Position.TOP) # append modes self.modes.append(modes.CursorHistoryMode()) self.modes.append(modes.CaseConverterMode()) self.modes.append(modes.FileWatcherMode()) # self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.RightMarginMode()) self.modes.append(rstmodes.RstSH(self.document(), color_scheme=api.ColorScheme(color_scheme))) self.modes.append(modes.ZoomMode()) cc = modes.CodeCompletionMode() cc.trigger_symbols[:] = [] self.modes.append(cc) self.modes.append(modes.AutoIndentMode()) self.modes.append(modes.IndenterMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode()) self.modes.append(modes.CheckerMode(workers.linter)) self.panels.append(panels.EncodingPanel(), api.Panel.Position.TOP) self.panels.append(panels.ReadOnlyPanel(), api.Panel.Position.TOP) self.panels.append(panels.CheckerPanel())
def __init__(self, parent=None, server_script=None, interpreter=sys.executable, args=None, create_default_actions=True, color_scheme='qt', reuse_backend=False): super(GenericCodeEdit, self).__init__(parent, create_default_actions) from pyqode.core import panels from pyqode.core import modes if server_script is None: server_script = GenericCodeEdit.DEFAULT_SERVER self.backend.start(server_script, interpreter, args, reuse=reuse_backend) # append panels self.panels.append(panels.LineNumberPanel()) self.panels.append(panels.SearchAndReplacePanel(), Panel.Position.BOTTOM) self.panels.append(panels.FoldingPanel()) # append modes self.modes.append(modes.CursorHistoryMode()) self.modes.append(modes.AutoCompleteMode()) self.modes.append(modes.ExtendedSelectionMode()) self.modes.append(modes.CaseConverterMode()) self.modes.append(modes.FileWatcherMode()) self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.RightMarginMode()) self.modes.append( modes.PygmentsSyntaxHighlighter( self.document(), color_scheme=ColorScheme(color_scheme))) self.modes.append(modes.ZoomMode()) self.modes.append(modes.CodeCompletionMode()) self.modes.append(modes.AutoIndentMode()) self.modes.append(modes.IndenterMode()) self.modes.append(modes.SymbolMatcherMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.SmartBackSpaceMode()) self.panels.append(panels.EncodingPanel(), Panel.Position.TOP) self.panels.append(panels.ReadOnlyPanel(), Panel.Position.TOP)
def __init__(self, path): super().__init__() self.defFont = QFont() self.defFont.setFamily('Courier') self.defFont.setFixedPitch(True) self.defFont.setPointSize(10) self.modes.append(modes.PygmentsSyntaxHighlighter(self.document())) self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.IndenterMode()) self.modes.append(modes.AutoIndentMode()) self.modes.append(modes.SmartBackSpaceMode()) self.modes.append(modes.ZoomMode()) self.panels.append(panels.SearchAndReplacePanel(), api.Panel.Position.BOTTOM) self.panels.append(panels.LineNumberPanel(), api.Panel.Position.LEFT) self.file.open(path) self.setFont(self.defFont) self.head, self.fileName = os.path.split(path) self.filePath = path
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())
def __init__(self, parent=None, server_script=server.__file__, interpreter=sys.executable, args=None, create_default_actions=True, color_scheme='qt', reuse_backend=False): from pyqode.core import panels from pyqode.core import modes super(TextCodeEdit, self).__init__(parent, create_default_actions) self.backend.start(server_script, interpreter, args, reuse=reuse_backend) # append panels self.panels.append(panels.SearchAndReplacePanel(), Panel.Position.BOTTOM) self.panels.append(panels.FoldingPanel()) self.panels.append(panels.LineNumberPanel()) # append modes self.modes.append(modes.AutoCompleteMode()) self.modes.append(modes.ExtendedSelectionMode()) self.modes.append(modes.CaseConverterMode()) self.modes.append(modes.FileWatcherMode()) self.modes.append(modes.CaretLineHighlighterMode()) self.modes.append(modes.RightMarginMode()) self.modes.append( TextCodeEdit.TextSH(self.document(), ColorScheme(color_scheme))) self.modes.append(modes.ZoomMode()) self.modes.append(modes.OccurrencesHighlighterMode()) self.modes.append(modes.CodeCompletionMode()) self.modes.append(modes.AutoIndentMode()) self.modes.append(modes.IndenterMode()) self.modes.append(modes.SymbolMatcherMode()) self.panels.append(panels.EncodingPanel(), Panel.Position.TOP)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- if __name__ == '__main__': import sys from PySide.QtGui import QApplication, QMainWindow app = QApplication(sys.argv) from pyqode.core import api from pyqode.core import modes editor = api.CodeEdit() # Добавление модов: подсветка кода, подсветка текущей строки и # добавление/удаление отступов используя Tab/Shift+Tab editor.modes.append(modes.PygmentsSyntaxHighlighter(editor.document())) editor.modes.append(modes.CaretLineHighlighterMode()) editor.modes.append(modes.IndenterMode()) editor.setPlainText(open(__file__, encoding='utf-8').read(), None, None) mw = QMainWindow() mw.setWindowTitle('pyqode') mw.setCentralWidget(editor) mw.show() sys.exit(app.exec_())
def __init__(self, args): QMainWindow.__init__(self) self.setupUi(self) self.moderat = args['moderat'] self.client = args['client'] self.module_id = args['module_id'] self.alias = args['alias'] self.ip_address = args['ip_address'] self.p2p = args['p2p'] title_prefix = self.alias if len(self.alias) > 0 else self.ip_address self.setWindowTitle(u'[{}] {}'.format( title_prefix, self.moderat.MString('MSCRIPTING_TITLE'))) # init idle self.editor = api.CodeEdit() #self.editor.setStyleSheet('border: 0px; padding: 0px; background: #34495e;') # start the backend as soon as possible self.editor.backend.start(server.__file__) # append some modes and panels self.editor.modes.append(modes.CodeCompletionMode()) self.editor.modes.append(modes.AutoIndentMode()) self.editor.modes.append(modes.AutoCompleteMode()) self.editor.modes.append(modes.IndenterMode()) self.editor.modes.append(modes.ExtendedSelectionMode()) self.editor.modes.append(modes.SymbolMatcherMode()) self.editor.modes.append(modes.ZoomMode()) self.editor.modes.append(modes.LineHighlighterMode()) self.editor.modes.append( modes.PygmentsSyntaxHighlighter(self.editor.document())) sh = self.editor.modes.append(modes.PygmentsSH(self.editor.document())) sh.fold_detector = api.IndentFoldDetector() self.editor.modes.get( modes.PygmentsSyntaxHighlighter).pygments_style = 'monokai' self.editor.panels.append(panels.SearchAndReplacePanel(), api.Panel.Position.BOTTOM) self.editor.panels.append(panels.CheckerPanel()) self.editor.panels.append(panels.LineNumberPanel()) self.editor.panels.append(panels.MarkerPanel()) self.editor.panels.append(panels.EncodingPanel()) self.editor.panels.append(panels.FoldingPanel()) self.editor.panels.append(panels.ReadOnlyPanel()) self.output = Output(self.editor, self.moderat) self.splitter = QSplitter() self.splitter.setOrientation(Qt.Vertical) self.splitter.addWidget(self.editor) self.splitter.addWidget(self.output) self.setCentralWidget(self.splitter) # self.runButton.clicked.connect(self.run_script) # self.testButton.clicked.connect(self.run_test) # self.openButton.clicked.connect(self.from_file) # self.pluginsListButton.clicked.connect(self.open_list) # self.addPluginButton.clicked.connect(self.insert_plugin) # self.saveButton.clicked.connect(self.save_plugin) # self.pluginSearchLine.returnPressed.connect(self.insert_plugin) # self.clearButton.clicked.connect(self.clear_script) # self.pinButton.clicked.connect(self.always_top) # Autocompleter self.completer = QCompleter(self.moderat.plugins.keys()) self.completer.setCompletionMode(QCompleter.PopupCompletion) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.popup().setStyleSheet('''background-color: #273747; color: #c9f5f7; border: 1px solid #243342; border-top: none;''') self.addTools()