def _setup_editor(self): font = QFont('Some font that does not exist') font.setStyleHint(font.TypeWriter, font.PreferDefault) editor = codeeditor.CodeEditor(self) try: editor.setup_editor(linenumbers=True, language='py', scrollflagarea=False, codecompletion_enter=self.enter_completion, tab_mode=False, edge_line=False, font=font, codecompletion_auto=True, go_to_definition=True, codecompletion_single=True, calltips=True) except TypeError: # codecompletion_single is gone in 2.3.0 editor.setup_editor(linenumbers=True, language='py', scrollflagarea=False, codecompletion_enter=self.enter_completion, tab_mode=False, edge_line=False, font=font, codecompletion_auto=True, go_to_definition=True, calltips=True) editor.setCursor(Qt.IBeamCursor) editor.horizontalScrollBar().setCursor(Qt.ArrowCursor) editor.verticalScrollBar().setCursor(Qt.ArrowCursor) return editor
def add_history(self, filename): """ Add new history tab Slot for add_history signal emitted by shell instance """ filename = encoding.to_unicode_from_fs(filename) if filename in self.filenames: return editor = codeeditor.CodeEditor(self) if osp.splitext(filename)[1] == '.py': language = 'py' icon = ima.icon('python') else: language = 'bat' icon = ima.icon('cmdprompt') editor.setup_editor(linenumbers=False, language=language, scrollflagarea=False) editor.focus_changed.connect(lambda: self.focus_changed.emit()) editor.setReadOnly(True) color_scheme = get_color_scheme(self.get_option('color_scheme_name')) editor.set_font( self.get_plugin_font(), color_scheme ) editor.toggle_wrap_mode( self.get_option('wrap') ) text, _ = encoding.read(filename) editor.set_text(text) editor.set_cursor_position('eof') self.editors.append(editor) self.filenames.append(filename) self.icons.append(icon) index = self.tabwidget.addTab(editor, osp.basename(filename)) self.find_widget.set_editor(editor) self.tabwidget.setTabToolTip(index, filename) self.tabwidget.setTabIcon(index, icon) self.tabwidget.setCurrentIndex(index)
def __init__(self, parent): QWidget.__init__(self, parent) self.editor = None # Read-only editor self.editor = codeeditor.CodeEditor(self) self.editor.setup_editor(linenumbers=False, language='py', scrollflagarea=False, edge_line=False) self.editor.focus_changed.connect(lambda: self.focus_changed.emit()) self.editor.setReadOnly(True) # Find/replace widget self.find_widget = FindReplace(self) self.find_widget.set_editor(self.editor) self.find_widget.hide() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.editor) layout.addWidget(self.find_widget) self.setLayout(layout)