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): super().__init__() self.show_context_menu = False self.sh = self.modes.append( modes.PygmentsSH(self.document(), DiffLexer())) self.lines = self.panels.append(panels.LineNumberPanel(), panels.LineNumberPanel.Position.LEFT) self.setReadOnly(True) self.syntax_highlighter.color_scheme = api.ColorScheme( settings.color_scheme())
def __init__(self): icon = QtGui.QIcon.fromTheme('preferences-desktop-font') super().__init__(_('Font & Colors'), icon=icon, category=_('Editor')) self.ui = settings_page_editor_colors_ui.Ui_Form() self.ui.setupUi(self) self.ui.edit_preview.modes.append(modes.CaretLineHighlighterMode()) self.ui.edit_preview.modes.append( modes.PygmentsSH(self.ui.edit_preview.document())) self.ui.edit_preview.setPlainText(PREVIEW_TEXT, 'text/x-python', 'utf8') self.ui.combo_color_schemes.clear() styles = api.PYGMENTS_STYLES for custom_style in [ 'qt', 'darcula', 'aube', 'crepuscule', 'ark-dark' ]: if custom_style not in styles: styles.append(custom_style) for style in sorted(styles): self.ui.combo_color_schemes.addItem(style) self.ui.combo_color_schemes.currentIndexChanged.connect( self.update_preview) self.ui.fontComboBox.currentFontChanged.connect(self.update_preview) self.ui.spinbox_font_size.valueChanged.connect(self.update_preview)
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()