def __init__(self, parent): QPlainTextEdit.__init__(self, parent) # Set font to monospaced (TypeWriter) font = QFont('') font.setStyleHint(font.TypeWriter, font.PreferDefault) font.setPointSize(8) self.setFont(font)
def __init__(self, parent, project=None): QPlainTextEdit.__init__(self) EditorGeneric.__init__(self) BaseCentralWidget.__init__(self) self.parent = parent self.completer = Completer(self, project) self.setWordWrapMode(QTextOption.NoWrap) doc = self.document() option = QTextOption() option.setFlags(QTextOption.ShowTabsAndSpaces) doc.setDefaultTextOption(option) self.setDocument(doc) self.set_default_font() #file modification time POSIX self._mtime = None #Flag to dont bug the user when answer 'dont show the modification dialog' self.ask_if_externally_modified = True self.lineNumberArea = self.LineNumberArea(self) self.viewport().installEventFilter(self) self.highlighter = None styles.set_style(self, 'editor') self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.connect(self, SIGNAL("modificationChanged(bool)"), self.modif_changed) self.highlight_current_line()
def __init__(self, *args): QPlainTextEdit.__init__(self, *args) # toPlainText() takes a lot of time on long texts, therefore it is cached self._cachedText = None self._eol = self._DEFAULT_EOL self._indenter = Indenter(self) self.lineLengthEdge = None self.lineLengthEdgeColor = Qt.red self._atomicModificationDepth = 0 self.drawWhiteSpaceTrailing = True self.drawWhiteSpaceAnyIndentation = False self._rectangularSelection = RectangularSelection(self) """Sometimes color themes will be supported. Now black on white is hardcoded in the highlighters. Hardcode same palette for not highlighted text """ palette = self.palette() palette.setColor(QPalette.Base, QColor('#ffffff')) palette.setColor(QPalette.Text, QColor('#000000')) self.setPalette(palette) self._highlighter = None self._bracketHighlighter = BracketHighlighter() self._lines = Lines(self) self.completionThreshold = self._DEFAULT_COMPLETION_THRESHOLD self.completionEnabled = self._DEFAULT_COMPLETION_ENABLED self._completer = Completer(self) self._initActions() self._lineNumberArea = qutepart.sideareas.LineNumberArea(self) self._countCache = (-1, -1) self._markArea = qutepart.sideareas.MarkArea(self) self._bookmarks = qutepart.bookmarks.Bookmarks(self, self._markArea) self._userExtraSelections = [] # we draw bracket highlighting, current line and extra selections by user self._userExtraSelectionFormat = QTextCharFormat() self._userExtraSelectionFormat.setBackground(QBrush(QColor('#ffee00'))) self.blockCountChanged.connect(self._updateLineNumberAreaWidth) self.updateRequest.connect(self._updateSideAreas) self.cursorPositionChanged.connect(self._updateExtraSelections) self.textChanged.connect(self._dropUserExtraSelections) self.textChanged.connect(self._resetCachedText) fontFamilies = {'Windows':'Courier New', 'Darwin': 'Menlo'} fontFamily = fontFamilies.get(platform.system(), 'Monospace') self.setFont(QFont(fontFamily)) self._updateLineNumberAreaWidth(0) self._updateExtraSelections()
def __init__(self,parent=None): self.lang= None self.prevBlockNum=0 #~ self. self.foldableLines={} self.foldedLines={} QPlainTextEdit.__init__(self,parent) self.palette= QPalette() self.palette.setColor(QPalette.Base, Qt.white) self.palette.setColor(QPalette.Text, Qt.black) self.setPalette(self.palette) self.lineNumberArea = LineNumberArea (self) #~ self.connect(self, SIGNAL("textChanged()"), #~ self.findFoldableLines) self.connect(self, SIGNAL("blockCountChanged(int)"), self.updateLineNumberAreaWidth) self.connect(self, SIGNAL("updateRequest(const QRect &, int)"), self.updateLineNumberArea) #~ self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlightCurrentLine) self.updateLineNumberAreaWidth(0) self.errorPos=None self.highlightCurrentLine() self.setLineWrapMode(QPlainTextEdit.NoWrap) self.setWordWrapMode(QTextOption.NoWrap) self.findFoldableLines()
def __init__(self): QPlainTextEdit.__init__(self, u'>>> ') self.setUndoRedoEnabled(False) self.apply_editor_style() self.setToolTip(self.tr("Show/Hide (F4)")) self.moveCursor(QTextCursor.EndOfLine) self._patIsWord = re.compile('\w+') self.prompt = u'>>> ' self._console = console.Console() self._history = [] self._braces = None self.imports = ['import __builtin__'] self.patFrom = re.compile('^(\\s)*from ((\\w)+(\\.)*(\\w)*)+ import') self.patImport = re.compile('^(\\s)*import (\\w)+') self.patObject = re.compile('[^a-zA-Z0-9_\\.]') self.completer = completer_widget.CompleterWidget(self) self.okPrefix = QRegExp('[.)}:,\]]') #Create Context Menu self._create_context_menu() self._highlighter = highlighter.Highlighter(self.document(), 'python', resources.CUSTOM_SCHEME) self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.highlight_current_line()
def __init__(self, parent=None, text=None, EditorHighlighterClass=PythonHighlighter, indenter=PythonCodeIndenter): QPlainTextEdit.__init__(self, parent) self.setFrameStyle(QFrame.NoFrame) self.setTabStopWidth(4) self.setLineWrapMode(QPlainTextEdit.NoWrap) font = QFont() font.setFamily("lucidasanstypewriter") font.setFixedPitch(True) font.setPointSize(10) self.setFont(font) self.highlighter = EditorHighlighterClass(self) if text: self.setPlainText(text) self.frame_style = self.frameStyle() self.draw_line = True self.print_width = self.fontMetrics().width("x"*78) self.line_pen = QPen(QColor("lightgrey")) self.last_row = self.last_col = -1 self.last_block = None self.highlight_line = True self.highlight_color = self.palette().highlight().color().light(175) self.highlight_brush = QBrush(QColor(self.highlight_color)) self.connect(self, SIGNAL("cursorPositionChanged()"), self.onCursorPositionChanged) self.indenter = indenter(RopeEditorWrapper(self)) # True if you want to catch Emacs keys in actions self.disable_shortcuts = False self.prj = get_no_project() self.prj.root = None self.calltip = CallTip(self) self.autocomplete = AutoComplete(self)
def __init__(self, parent=None): QPlainTextEdit.__init__(self, parent) self.extra_selections_dict = {} # Undo/Redo self.undo_available = False self.redo_available = False self.connect(self, SIGNAL("undoAvailable(bool)"), self.set_undo) self.connect(self, SIGNAL("redoAvailable(bool)"), self.set_redo) self.connect(self, SIGNAL('textChanged()'), self.changed) self.connect(self, SIGNAL('cursorPositionChanged()'), self.cursor_position_changed) # Code completion / calltips self.completion_widget = CompletionWidget(self, parent) self.codecompletion_auto = False self.codecompletion_enter = False self.calltips = True self.completion_text = "" self.calltip_position = None # Brace matching self.bracepos = None self.setup()
def __init__(self): QPlainTextEdit.__init__(self, u'>>> ') self.setUndoRedoEnabled(False) self.apply_editor_style() self.setToolTip(self.tr("Show/Hide (F4)")) self.moveCursor(QTextCursor.EndOfLine) self._patIsWord = re.compile('\w+') self.prompt = u'>>> ' self._console = console.Console() self._history = [] self._braces = None self.imports = ['import __builtin__'] self.patFrom = re.compile('^(\\s)*from ((\\w)+(\\.)*(\\w)*)+ import') self.patImport = re.compile('^(\\s)*import (\\w)+') self.patObject = re.compile('[^a-zA-Z0-9_\\.]') self.completer = completer_widget.CompleterWidget(self) self.okPrefix = QRegExp('[.)}:,\]]') #Create Context Menu self._create_context_menu() self._highlighter = highlighter.Highlighter(self.document(), 'python', resources.CUSTOM_SCHEME) self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.highlight_current_line() self._proc = QProcess(self) self.connect(self._proc, SIGNAL("readyReadStandardOutput()"), self._python_path_detected) self.connect(self._proc, SIGNAL("error(QProcess::ProcessError)"), self.process_error) self._add_system_path_for_frozen()
def __init__(self, parent): QPlainTextEdit.__init__(self, parent) self._parent = parent self.setReadOnly(True) self.maxValue = 0 self.actualValue = 0 #traceback pattern self.patLink = re.compile(r'(\s)*File "(.*?)", line \d.+') #formats self.plain_format = QTextCharFormat() self.plain_format.setForeground(QBrush(QColor( resources.CUSTOM_SCHEME.get("editor-text", resources.COLOR_SCHEME["editor-text"])))) self.error_format = QTextCharFormat() self.error_format.setAnchor(True) self.error_format.setFontUnderline(True) self.error_format.setUnderlineStyle(QTextCharFormat.SingleUnderline) self.error_format.setUnderlineColor(Qt.red) self.error_format.setForeground(Qt.blue) self.error_format.setToolTip(self.tr("Click to show the source")) self.connect(self, SIGNAL("blockCountChanged(int)"), self._scroll_area) css = 'QPlainTextEdit {color: %s; background-color: %s;' \ 'selection-color: %s; selection-background-color: %s;}' \ % (resources.CUSTOM_SCHEME.get('editor-text', resources.COLOR_SCHEME['editor-text']), resources.CUSTOM_SCHEME.get('editor-background', resources.COLOR_SCHEME['editor-background']), resources.CUSTOM_SCHEME.get('editor-selection-color', resources.COLOR_SCHEME['editor-selection-color']), resources.CUSTOM_SCHEME.get('editor-selection-background', resources.COLOR_SCHEME['editor-selection-background'])) self.setStyleSheet(css)
def __init__(self): QPlainTextEdit.__init__(self, '>>> ') self.setUndoRedoEnabled(False) self.apply_editor_style() self.setToolTip(self.tr("Show/Hide (F4)")) self.moveCursor(QTextCursor.EndOfLine) self._patIsWord = re.compile('\w+') self.prompt = '>>> ' self._console = console.Console() self._history = [] self.history_index = 0 self._current_command = '' self._braces = None self.imports = ['import __builtin__'] self.patFrom = re.compile('^(\\s)*from ((\\w)+(\\.)*(\\w)*)+ import') self.patImport = re.compile('^(\\s)*import (\\w)+') self.patObject = re.compile('[^a-zA-Z0-9_\\.]') self.completer = completer_widget.CompleterWidget(self) self.okPrefix = QRegExp('[.)}:,\]]') self._pre_key_press = { Qt.Key_Enter: self._enter_pressed, Qt.Key_Return: self._enter_pressed, Qt.Key_Tab: self._tab_pressed, Qt.Key_Home: self._home_pressed, Qt.Key_PageUp: lambda x: True, Qt.Key_PageDown: lambda x: True, Qt.Key_Left: self._left_pressed, Qt.Key_Up: self._up_pressed, Qt.Key_Down: self._down_pressed, Qt.Key_Backspace: self._backspace, } #Create Context Menu self._create_context_menu() #Set Font self.set_font() #Create Highlighter parts_scanner, code_scanner, formats = \ syntax_highlighter.load_syntax(python_syntax.syntax) self.highlighter = syntax_highlighter.SyntaxHighlighter( self.document(), parts_scanner, code_scanner, formats) self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.highlight_current_line() self._proc = QProcess(self) self.connect(self._proc, SIGNAL("readyReadStandardOutput()"), self._python_path_detected) self.connect(self._proc, SIGNAL("error(QProcess::ProcessError)"), self.process_error) self._add_system_path_for_frozen()
def __init__(self): QPlainTextEdit.__init__(self, '>>> ') ConsoleGeneric.__init__(self) self.setUndoRedoEnabled(False) styles.set_style(self, 'editor') self.setToolTip('Show/Hide (F4)') self.highlighter = Highlighter(self.document(), 'python') self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.highlight_current_line()
def __init__(self, *args, **kwargs): QPlainTextEdit.__init__(self, *args, **kwargs) self.setFrameStyle(QPlainTextEdit.NoFrame) self.setTextInteractionFlags(Qt.TextBrowserInteraction) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) font = self.font() font.setStyleHint(QFont.Monospace) font.setFamily("Monospace") self.setFont(font)
def __init__(self, params, parent=None): self._editor_widget = self QPlainTextEdit.__init__(self, parent) WithSingleIO.__init__(self, params) WithCompletion.__init__(self, parent) WithWordCompletionMulty_.__init__(self, parent) WithFixedFont.__init__(self, parent) WithViewPortMargins.__init__(self, parent) WithLineNumbers.__init__(self, parent) WithLineHighlight.__init__(self, parent) WithMqEditIO.__init__(self, params)
def __init__(self, parent, debug): QPlainTextEdit.__init__(self) self.setupUi(self) self.setReadOnly(1) self.parent = parent self.name = "Output" self.debug = debug self.sigout = "IOOUTputtext" self.connect(self, SIGNAL(self.sigout), self.puttext) if sys.__stdout__.fileno() >= 0 and not self.debug: self.cioout = CIO(self, sys.__stdout__.fileno(), self.sigout) self.cioout.start()
def __init__(self, parent, debug): QPlainTextEdit.__init__(self) self.setupUi(self) self.setReadOnly(1) self.parent = parent self.name = "Errors" self.debug = debug self.sigerr = "IOERRputtext" self.connect(self, SIGNAL(self.sigerr), self.puttext) if sys.__stderr__.fileno() >= 0 and not self.debug: self.cioerr = CIO(self, sys.__stderr__.fileno(), self.sigerr) self.cioerr.start()
def __init__(self, *args): QPlainTextEdit.__init__(self, *args) self.instPtrImage = QImage(":/images/icons/enabled/inst_ptr_top.gif") self.brkpObjImage = QImage(":/images/icons/enabled/brkp_obj.gif") self.breakpoints = set() #self.setFrameStyle(QFrame.NoFrame) self.setFrameStyle(QFrame.NoFrame) self.highlight() #self.setLineWrapMode(QPlainTextEdit.NoWrap) self.cursorPositionChanged.connect(self.highlight)
def __init__(self, parent, debug): QPlainTextEdit.__init__(self) self.setupUi(self) self.setReadOnly(1) self.parent = parent self.name = "Output" self.debug = debug self.sigout = "IOOUTputtext" self.connect(self, SIGNAL(self.sigout), self.puttext) if sys.__stdout__.fileno() < 0 and not self.debug: # Open it if it does not exist, mostly for Windows sys.__stdout__ = os.fdopen(1, 'wb', 0) sys.stdout = sys.__stdout__ if sys.__stdout__.fileno() >= 0 and not self.debug: self.cioout = CIO(self, sys.__stdout__.fileno(), self.sigout) self.cioout.start()
def __init__(self, parent, debug): QPlainTextEdit.__init__(self) self.setupUi(self) self.setReadOnly(1) self.parent = parent self.name = "Errors" self.debug = debug self.sigerr = "IOERRputtext" self.connect(self, SIGNAL(self.sigerr), self.puttext) if sys.__stderr__.fileno() < 0 and not self.debug: # Open it if it does not exist, mostly for Windows sys.__stderr__ = os.fdopen(2, 'wb', 0) sys.stderr = sys.__stderr__ if sys.__stderr__.fileno() >= 0 and not self.debug: self.cioerr = CIO(self, sys.__stderr__.fileno(), self.sigerr) self.cioerr.start()
def __init__(self): QPlainTextEdit.__init__(self) font = QFont('Courier New', 9, False) self.setFont(font) palette = QPalette() palette.setColor(QPalette.Text, Qt.lightGray) self.setPalette(palette) self.setStyleSheet("QPlainTextEdit {background-color: #2B2B2B}, {text-color: yellow}") metrics = QFontMetrics(font) self.setTabStopWidth(4 * metrics.width(' ')) EHighlighter(self.document()) self.__IsControl = False
def __init__(self, *args, **kwargs): QPlainTextEdit.__init__(self, *args, **kwargs) self.setFrameStyle(QPlainTextEdit.NoFrame) self.setTextInteractionFlags(Qt.TextBrowserInteraction) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) font = self.font() if hasattr(QFont, "Monospace"): # Why is this not available on Debian squeeze font.setStyleHint(QFont.Monospace) else: font.setStyleHint(QFont.Courier) font.setFamily("Monaco") font.setPointSize(12) self.setFont(font)
def __init__(self, parent=None): QPlainTextEdit.__init__(self, parent) self.setMaximumBlockCount(1000) self.group = QActionGroup(self) self.actions = [QAction(log_lvl, self.group) for log_lvl in ["Debug", "Info", "Warning", "Error", "Critical"]] for action in self.actions: action.setCheckable(True) action.triggered.connect(self.on_log_filter) self.actions[0].setChecked(True) self.customContextMenuRequested.connect( self.on_custom_context_menu_requested) self.log_lvl = log_levels["DEBUG"]
def __init__(self, parent, mainwin): QPlainTextEdit.__init__(self, parent) self.mainwin = mainwin self.setObjectName("restedit") self._formats = {} self.textChanged.connect(self._restedit_update) self.blockCountChanged.connect(self._blockcount_update) shortcut = QShortcut(QKeySequence("Ctrl+T"), self) shortcut.activated.connect(self._choose_font) shortcut = QShortcut(QKeySequence.ZoomIn, self) shortcut.activated.connect(self._zoom_in) shortcut.setContext(Qt.WidgetShortcut) shortcut = QShortcut(QKeySequence.ZoomOut, self) shortcut.activated.connect(self._zoom_out) shortcut.setContext(Qt.WidgetShortcut) self._doc = QApplication.instance().rest self._last_warnings = {} # should be moved to the document
def __init__(self, parent=None): ''' Initialize console view. ''' QPlainTextEdit.__init__(self, parent) self.ensureCursorVisible() #self.text_buffer = self.get_buffer() # self.mark = self.text_buffer.create_mark('scroll_mark', # self.text_buffer.get_end_iter(), # False) # for code in self.ANSI_COLORS: # self.text_buffer.create_tag(code, # foreground=self.ANSI_COLORS[code], # weight=700) # self.text_buffer.create_tag('0') # self.text_buffer.create_tag('notouch', editable=False) self.color_pat = re.compile('\x01?\x1b\[(.*?)m\x02?')
def __init__(self, locals): QPlainTextEdit.__init__(self, u'>>> ') self.setUndoRedoEnabled(False) self.setStyleSheet(EDITOR_STYLE) self.setToolTip(self.tr("Show/Hide (F4)")) self._patIsWord = re.compile('\w+') self.prompt = u'>>> ' self._console = console.Console(locals) self._history = [] self._braces = None self._highlighter = highlighter.Highlighter(self.document(), 'python', highlighter.COLOR_SCHEME) self.connect(self, SIGNAL("cursorPositionChanged()"), self.highlight_current_line) self.highlight_current_line() self.setCursorPosition(0)
def __init__(self, parent): QPlainTextEdit.__init__(self, parent) self._parent = parent self.setReadOnly(True) self.maxValue = 0 self.actualValue = 0 #traceback pattern self.patLink = re.compile(r'(\s)*File "(.*?)", line \d.+') #formats self.plain_format = QTextCharFormat() self.error_format = QTextCharFormat() self.error_format.setAnchor(True) self.error_format.setFontUnderline(True) self.error_format.setUnderlineStyle(QTextCharFormat.SingleUnderline) self.error_format.setUnderlineColor(Qt.red) self.error_format.setForeground(Qt.blue) self.error_format.setToolTip(self.tr("Click to show the source")) self.connect(self, SIGNAL("blockCountChanged(int)"), self._scroll_area)
def __init__(self, parent=None): QPlainTextEdit.__init__(self, parent) self.setMaximumBlockCount(1000) self.group = QActionGroup(self) self.actions = [ QAction(log_lvl, self.group) for log_lvl in ["Debug", "Info", "Warning", "Error", "Critical"] ] for action in self.actions: action.setCheckable(True) action.triggered.connect(self.on_log_filter) self.actions[0].setChecked(True) self.customContextMenuRequested.connect( self.on_custom_context_menu_requested) self.log_lvl = log_levels["DEBUG"]
def __init__(self): QPlainTextEdit.__init__(self) self.position_margin = QFontMetricsF( self.document().defaultFont()).width("#") * 80 # Margin line self._margin = False # Sidebar self.sidebar = Sidebar(self) # Highlight current line self._color_current_line = QColor('lightblue') self._alpha_current_line = self._color_current_line.setAlpha(50) # Connection self.connect(self, SIGNAL("blockCountChanged(int)"), self.sidebar.update_area_width) self.connect(self, SIGNAL("updateRequest(const QRect&, int)"), self.sidebar.update_area) self.connect(self, SIGNAL("cursorPositionChanged()"), self._highlight_current_line) self._highlight_current_line()
def __init__(self): QPlainTextEdit.__init__(self) self.lineNumberArea = self.LineNumberArea(self) self.viewport().installEventFilter(self) self.highlighter = PythonHighlighter(self.document()) self.newDocument = True self.path = '' css = ''' QPlainTextEdit { font-family: monospace; font-size: 10; color: black; background-color: white; selection-color: white; selection-background-color: #437DCD; }''' self.setStyleSheet(css) self.highlight_current_line()
def __init__(self, parent=None): QPlainTextEdit.__init__(self, parent) BaseEditMixin.__init__(self) self.setAttribute(Qt.WA_DeleteOnClose) self.extra_selections_dict = {} self.connect(self, SIGNAL('textChanged()'), self.changed) self.connect(self, SIGNAL('cursorPositionChanged()'), self.cursor_position_changed) self.indent_chars = " " * 4 # Code completion / calltips if parent is not None: mainwin = parent while not isinstance(mainwin, QMainWindow): mainwin = mainwin.parent() if mainwin is None: break if mainwin is not None: parent = mainwin self.completion_widget = CompletionWidget(self, parent) self.codecompletion_auto = False self.codecompletion_case = True self.codecompletion_single = False self.codecompletion_enter = False self.calltips = True self.calltip_position = None self.calltip_size = 600 self.calltip_font = QFont() self.completion_text = "" # Highlight current line color self.currentline_color = QColor(Qt.red).lighter(190) # Brace matching self.bracepos = None self.matched_p_color = QColor(Qt.green) self.unmatched_p_color = QColor(Qt.red)
def __init__(self, parent): QPlainTextEdit.__init__(self, parent) self._parent = parent self.setReadOnly(True) self.maxValue = 0 self.actualValue = 0 #traceback pattern self.patLink = re.compile(r'(\s)*File "(.*?)", line \d.+') #formats font = QFont(settings.FONT_FAMILY, settings.FONT_SIZE) self.plain_format = QTextCharFormat() self.plain_format.setFont(font) self.plain_format.setForeground( QBrush( QColor( resources.CUSTOM_SCHEME.get( "editor-text", resources.COLOR_SCHEME["editor-text"])))) self.error_format = QTextCharFormat() self.error_format.setFont(font) self.error_format.setAnchor(True) self.error_format.setFontUnderline(True) self.error_format.setUnderlineStyle(QTextCharFormat.SingleUnderline) self.error_format.setUnderlineColor(Qt.red) self.error_format.setForeground(Qt.blue) self.error_format.setToolTip(self.tr("Click to show the source")) self.connect(self, SIGNAL("blockCountChanged(int)"), self._scroll_area) css = 'QPlainTextEdit {color: %s; background-color: %s;' \ 'selection-color: %s; selection-background-color: %s;}' \ % (resources.CUSTOM_SCHEME.get('editor-text', resources.COLOR_SCHEME['editor-text']), resources.CUSTOM_SCHEME.get('editor-background', resources.COLOR_SCHEME['editor-background']), resources.CUSTOM_SCHEME.get('editor-selection-color', resources.COLOR_SCHEME['editor-selection-color']), resources.CUSTOM_SCHEME.get('editor-selection-background', resources.COLOR_SCHEME['editor-selection-background'])) self.setStyleSheet(css)
def __init__(self, parent=None): QPlainTextEdit.__init__(self, parent) BaseEditMixin.__init__(self) self.setAttribute(Qt.WA_DeleteOnClose) self.extra_selections_dict = {} self.connect(self, SIGNAL('textChanged()'), self.changed) self.connect(self, SIGNAL('cursorPositionChanged()'), self.cursor_position_changed) self.indent_chars = " "*4 # Code completion / calltips if parent is not None: mainwin = parent while not isinstance(mainwin, QMainWindow): mainwin = mainwin.parent() if mainwin is None: break if mainwin is not None: parent = mainwin self.completion_widget = CompletionWidget(self, parent) self.codecompletion_auto = False self.codecompletion_case = True self.codecompletion_single = False self.codecompletion_enter = False self.calltips = True self.calltip_position = None self.calltip_size = 600 self.calltip_font = QFont() self.completion_text = "" # Highlight current line color self.currentline_color = QColor(Qt.red).lighter(190) # Brace matching self.bracepos = None self.matched_p_color = QColor(Qt.green) self.unmatched_p_color = QColor(Qt.red)
def __init__(self, parent=None, *args, **kwargs): """ Initializes the class. :param parent: Widget parent. :type parent: QObject :param \*args: Arguments. :type \*args: \* :param \*\*kwargs: Keywords arguments. :type \*\*kwargs: \*\* """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) QPlainTextEdit.__init__(self, parent, *args, **kwargs) # --- Setting class attributes. --- self.__searchPattern = None self.__minimumFontPointSize = 6 self.__maximumFontPointSize = 24 self.__textCursorAnchor = None
def __init__(self): QPlainTextEdit.__init__(self) self.setWordWrapMode(QTextOption.NoWrap) self.setFont(QFont("monospace", 10)) self.setCursorWidth(2) self.installEventFilter(self) self.cursorPositionChanged.connect(self.showHelp) self.completer = QCompleter(self) self.completer.setWidget(self) self.completer.setCaseSensitivity(Qt.CaseInsensitive) self.completer.activated.connect(self.insertCompletion) auto_complete = QShortcut(QKeySequence("Ctrl+Space"), self) auto_complete.activated.connect(self.activateCompleter) copy_line = QShortcut(QKeySequence("Ctrl+D"), self) copy_line.activated.connect(self.duplicateLine) select_fragment = QShortcut(QKeySequence("Ctrl+J"), self) select_fragment.activated.connect(self.selectFragment)
def __init__(self, tabWidget=None): QPlainTextEdit.__init__(self) self.line_number_area = LineNumberArea(self) self.line_number_area.setObjectName('lineNumberArea') # Used for slot #TODO: color theme palette = self.palette() palette.setColor(QPalette.Base, QColor('#fdf6e3')) palette.setColor(QPalette.Text, QColor('#002b36')) self.setPalette(palette) self.highlighter = Highlighter(self) self.blockCountChanged.connect(self._update_line_number_area_width) self.updateRequest.connect(self._update_line_number_area) self.source_file = '' self.modificationChanged.connect(self.modified) self.tabs = tabWidget save_action = QAction('Save', self) save_action.setShortcut(QKeySequence.Save) self.connect(save_action, QtCore.SIGNAL('triggered()'), self.save) self.addAction(save_action)
def __init__(self, parent=None, text=None, EditorHighlighterClass=PythonHighlighter, indenter=PythonCodeIndenter): QPlainTextEdit.__init__(self, parent) self.setFrameStyle(QFrame.NoFrame) self.setTabStopWidth(4) self.setLineWrapMode(QPlainTextEdit.NoWrap) font = QFont() font.setFamily("lucidasanstypewriter") font.setFixedPitch(True) font.setPointSize(10) self.setFont(font) self.highlighter = EditorHighlighterClass(self) if text: self.setPlainText(text) self.frame_style = self.frameStyle() self.draw_line = True self.print_width = self.fontMetrics().width("x" * 78) self.line_pen = QPen(QColor("lightgrey")) self.last_row = self.last_col = -1 self.last_block = None self.highlight_line = True self.highlight_color = self.palette().highlight().color().light(175) self.highlight_brush = QBrush(QColor(self.highlight_color)) self.connect(self, SIGNAL("cursorPositionChanged()"), self.onCursorPositionChanged) self.indenter = indenter(RopeEditorWrapper(self)) # True if you want to catch Emacs keys in actions self.disable_shortcuts = False self.prj = get_no_project() self.prj.root = None self.calltip = CallTip(self) self.autocomplete = AutoComplete(self)
def __init__(self, neditable): QPlainTextEdit.__init__(self) itab_item.ITabItem.__init__(self) self._neditable = neditable self._neditable.set_editor(self) #Config Editor self.set_flags() self.__lines_count = None self.lang = 'python' 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.connect(self._neditable, SIGNAL("checkersUpdated()"), self._show_tab_icon_notification) 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)
def __init__(self, parent=None, filename=None): """Initialization, can accept a filepath as argument""" QPlainTextEdit.__init__(self, parent) # Errors self.errors = {} self.isMAEMO = False self.scroller = None palette = self.palette() palette.setColor(QPalette.Base, Qt.white) palette.setColor(QPalette.Text, Qt.black) self.setPalette(palette) self.setWindowOpacity(0.9) self.hl_color = QColor('lightblue').lighter(120) self.qt18720 = False if ((parent.settings.value("qt18720")) == '2'): self.qt18720 = True else: self.qt18720 = False # Brace matching self.bracepos = None # Init scroller and area which are tricky hack to speed scrolling # try: # scroller = self.property("kineticScroller") # scroller.setEnabled(True) # except: # print 'Cannot instance kineticScroller' #Plugin init moved to editor_window.py #initialization init of plugin system #Maybe be not the best place to do it ... #init_plugin_system({'plugin_path': '/home/opt/khteditor/plugins', # 'plugins': ['autoindent']}) #If we have a filename self.filename = filename if (self.filename == None) or (self.filename == ''): self.filename = u'Unnamed.txt' self.document().setModified(False) parent.setWindowTitle(self.filename) #Set no wrap if (bool(parent.settings.value("WrapLine"))): self.setLineWrapMode(QPlainTextEdit.NoWrap) else: self.setLineWrapMode(QPlainTextEdit.WidgetWidth) font = QFont() try: if parent.settings.contains('FontName'): font.setFamily(parent.settings.value('FontName')) else: font.setFamily("Courier") except: font.setFamily("Courier") #Get Font Size try: if parent.settings.contains('FontSize'): font.setPointSize(int(parent.settings.value('FontSize'))) else: font.setPointSize(11) except: font.setPointSize(11) #Set Font self.fmetrics = QFontMetrics(font) self.document().setDefaultFont(font) #Remove auto capitalization self.setInputMethodHints(Qt.ImhNoAutoUppercase) #Keep threaded plugins references to avoid them to be garbage collected self.threaded_plugins = [] self.enabled_plugins = parent.enabled_plugins #Current Line highlight and Bracket matcher self.cursorPositionChanged.connect(self.curPositionChanged) self.textChanged.connect(self.textEditChanged)
def __init__(self, parent=None): QPlainTextEdit.__init__(self, parent) self.setMaximumBlockCount(1000)
def __init__(self, *args): QPlainTextEdit.__init__(self, *args) # toPlainText() takes a lot of time on long texts, therefore it is cached self._cachedText = None self._eol = self._DEFAULT_EOL self._indenter = Indenter(self) self.lineLengthEdge = None self.lineLengthEdgeColor = Qt.red self._atomicModificationDepth = 0 self.drawIncorrectIndentation = True self.drawAnyWhitespace = False self._rectangularSelection = RectangularSelection(self) """Sometimes color themes will be supported. Now black on white is hardcoded in the highlighters. Hardcode same palette for not highlighted text """ palette = self.palette() palette.setColor(QPalette.Base, QColor('#ffffff')) palette.setColor(QPalette.Text, QColor('#000000')) self.setPalette(palette) self._highlighter = None self._bracketHighlighter = BracketHighlighter() self._lines = Lines(self) self.completionThreshold = self._DEFAULT_COMPLETION_THRESHOLD self.completionEnabled = self._DEFAULT_COMPLETION_ENABLED self._completer = Completer(self) self._initActions() self._lineNumberArea = qutepart.sideareas.LineNumberArea(self) self._countCache = (-1, -1) self._markArea = qutepart.sideareas.MarkArea(self) self._bookmarks = qutepart.bookmarks.Bookmarks(self, self._markArea) self._userExtraSelections = [ ] # we draw bracket highlighting, current line and extra selections by user self._userExtraSelectionFormat = QTextCharFormat() self._userExtraSelectionFormat.setBackground(QBrush(QColor('#ffee00'))) self._lintMarks = {} self.blockCountChanged.connect(self._updateLineNumberAreaWidth) self.updateRequest.connect(self._updateSideAreas) self.cursorPositionChanged.connect(self._updateExtraSelections) self.textChanged.connect(self._dropUserExtraSelections) self.textChanged.connect(self._resetCachedText) self.textChanged.connect(self._clearLintMarks) fontFamilies = {'Windows': 'Courier New', 'Darwin': 'Menlo'} fontFamily = fontFamilies.get(platform.system(), 'Monospace') self.setFont(QFont(fontFamily)) self._updateLineNumberAreaWidth(0) self._updateExtraSelections()
def __init__(self, focusin, focusout, closed = None, parent = None): QPlainTextEdit.__init__(self, parent) self.focusin = focusin self.focusout = focusout self.closed = closed
def __init__(self, locals=None, parent=None): QPlainTextEdit.__init__(self, parent) code.InteractiveConsole.__init__(self, locals) self.history, self.historyInd = [""], 0 self.loop = self.interact() self.loop.next()
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)
def __init__(self, *args, **kwargs): QPlainTextEdit.__init__(self, *args, **kwargs)
def __init__(self, parent): QPlainTextEdit.__init__(self, parent) self.highlighter = QtScriptHighlighter(self)
def __init__(self, focusin, focusout): QPlainTextEdit.__init__(self) self.focusin = focusin self.focusout = focusout
def __init__(self, *__args): QPlainTextEdit.__init__(self, *__args) self.set_tab_size() self.highlight = PythonHighlighter(self.document())
def __init__(self, filename, project): 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.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) #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.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 settings.USE_TABS: self.set_tab_usage() #Context Menu Options self.__actionFindOccurrences = QAction( self.tr("Find Usages"), self) self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"), self._find_occurrences)
def __init__(self, filename, project): 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.textModified = False self.newDocument = True self.highlighter = None self.syncDocErrorsSignal = False #Set editor style styles.set_editor_style(self, resources.CUSTOM_SCHEME) self.set_font(settings.FONT_FAMILY, settings.FONT_SIZE) #For Highlighting in document self.extraSelections = [] self._patIsWord = re.compile('\w+') #Brace matching self._braces = None self._mtime = None self.encoding = None #Flag to dont bug the user when answer *the modification dialog* self.ask_if_externally_modified = True #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 } 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_braces, Qt.Key_QuoteDbl: self.__complete_braces } 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.errors, SIGNAL("finished()"), self.show_static_errors) self.connect(self, SIGNAL("blockCountChanged(int)"), self._update_file_metadata) #Context Menu Options self.__actionFindOccurrences = QAction(self.tr("Find Usages"), self) self.connect(self.__actionFindOccurrences, SIGNAL("triggered()"), self._find_occurrences)
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, parent=None, readonly=True, max_rows=1000, echo=True): QPlainTextEdit.__init__(self, parent) self.echo = echo self.setReadOnly(readonly) self.document().setMaximumBlockCount(max_rows) self.attach()