Ejemplo n.º 1
0
 def __init__(self):
     QPlainTextEdit.__init__(self)
     EditorMixin.__init__(self)
     # Style
     self.__init_style()
     self.__apply_style()
     self.__visible_blocks = []
Ejemplo n.º 2
0
    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.cursorPositionChanged.connect(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)
Ejemplo n.º 3
0
    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.cursorPositionChanged.connect(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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
    def __init__(self):
        QPlainTextEdit.__init__(self)
        self.logArea = QPlainTextEdit()
        self.setMaximumBlockCount(10000)
        self.setReadOnly(True)

        self.setStyleSheet("background-color: black;color:white;")
        self.setFont(QFont("Monospace", 8))
Ejemplo n.º 6
0
 def __init__(self, parent=None):
     QPlainTextEdit.__init__(self, parent)
     self.lineNumberArea = LineNumberArea(self)
     self.blockCountChanged.connect(self.updateLineNumberAreaWidth)
     self.updateRequest.connect(self.updateLineNumberArea)
     self.cursorPositionChanged.connect(self.highlightCurrentLine)
     self.updateLineNumberAreaWidth(0)
     self.highlightCurrentLine()
Ejemplo n.º 7
0
    def __init__(self):
        QPlainTextEdit.__init__(self)
        self.setMinimumSize(720, 180)
        self.printLevel = CmdLogArea.printLevels['I']
        self.setMaximumBlockCount(10000)
        self.setReadOnly(True)

        self.setStyleSheet("background-color: black;color:white;")
        self.setFont(QFont("Monospace", styles.smallFont))
Ejemplo n.º 8
0
 def __init__(self):
     QPlainTextEdit.__init__(self)
     EditorMixin.__init__(self)
     # Word separators
     # Can be used by code completion and the link emulator
     self.word_separators = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"
     # Style
     self.__init_style()
     self.__apply_style()
     self.__visible_blocks = []
Ejemplo n.º 9
0
 def __init__(self, parent=None):
     # FIXME[question]: can we use real python multiple inheritance here?
     # (that is just super().__init__(*args, **kwargs))
     QPlainTextEdit.__init__(self, parent)
     logging.Handler.__init__(self)
     self.setReadOnly(True)
     self._records = []
     self._counter = 1
     self._message_signal.connect(self.appendMessage)
     self._message_signal.emit("Log view initialized")
Ejemplo n.º 10
0
 def __init__(self):
     QPlainTextEdit.__init__(self)
     EditorMixin.__init__(self)
     # Word separators
     # Can be used by code completion and the link emulator
     self.word_separators = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"
     # Style
     self.__init_style()
     self.__apply_style()
     self.__visible_blocks = []
    def __init__(self, prompt='$> ', startup_message='', parent=None):
        #QtGui.QPlainTextEdit.__init__(self, parent) #linux code PyQt4
        QPlainTextEdit.__init__(self, parent)
        self.prompt = prompt
        self.history = []
        self.namespace = {}
        self.construct = []

        self.setGeometry(50, 60, 300, 100)
        self.setWordWrapMode(QtGui.QTextOption.WrapAnywhere)
        self.setUndoRedoEnabled(False)
        self.document().setDefaultFont(
            QtGui.QFont("monospace", 10, QtGui.QFont.Normal))
        self.showMessage(startup_message)
Ejemplo n.º 12
0
    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)
Ejemplo n.º 13
0
    def __init__(self, actor):
        QPlainTextEdit.__init__(self)
        self.setMinimumSize(400, 180)
        self.actor = actor

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.parseLog)
        self.timer.setInterval(RawLogArea.refresh * 1000)
        self.timer.start()

        self.setMaximumBlockCount(RawLogArea.maxBlockCount)
        self.setReadOnly(True)

        self.setStyleSheet("background-color: black;color:white;")
        self.setFont(QFont("Monospace", styles.smallFont))

        self.logs = ''
        self.parseLog(nbline=2000)
Ejemplo n.º 14
0
    def __init__(self, parent):
        # super(CodeEditor, self).__init__()
        QPlainTextEdit.__init__(self, parent)
        self.lineNumberArea = LineNumberArea(self)
        self.setTabStopWidth(20)
        self.blockCountChanged.connect(self.updateLineNumberAreaWidth)
        self.updateRequest.connect(self.updateLineNumberArea)
        self.cursorPositionChanged.connect(self.highlightCurrentLine)
        self.updateLineNumberAreaWidth(0)
        self.highlightCurrentLine()
        self.highlighter = PythonHighlighter(self.document())

        # Determine if the line number area needs to be shown or not
        lineNumbersCheckedState = self.settings.value(
            'editor_line_numbers_visible', type=bool)
        if lineNumbersCheckedState:
            self.showLineNumberArea()
        else:
            self.hideLineNumberArea()

        self.initUI()
Ejemplo n.º 15
0
    def __init__(self, parent=None):
        QPlainTextEdit.__init__(self, parent)
        # default settings
        self._fontsize = 12
        self._fmin = 8
        self._fmax = 30

        # setup of prototxt_editor
        self.setLineWrapMode(0)

        # loading of subwidgets
        self.sidebar = editor_side_bar.Sidebar(self)  # line numbers
        self.searchbar = editor_search_bar.SearchBar(self, self)  # search
        self.slider = editor_slider.EditorSlider(self._fmin, self._fontsize,
                                                 self._fmax,
                                                 self)  # fontsize slider
        # conntions
        self.slider.valueChanged.connect(self.setFontsize)
        self.blockCountChanged.connect(self._updateSidebarWidth)
        self.updateRequest.connect(self._updateSidebar)
        # show
        self._updateFont()
        self._updateSidebarWidth()
        self.sidebar.show()
Ejemplo n.º 16
0
 def __init__(self, title):
     QPlainTextEdit.__init__(self)
     self.setWindowTitle(title)
     self.setReadOnly(True) # assuming QPlainTextEdit
     self.hide()
     self.resize(QSize(450, 300))
 def __init__(self, *args, **kwargs):
     QPlainTextEdit.__init__(self, *args, **kwargs)
Ejemplo n.º 18
0
    def __init__(self, neditable):
        QPlainTextEdit.__init__(self)
        self.setFrameStyle(0)  # Remove border
        self._neditable = neditable
        self.setMouseTracking(True)
        # Style
        self._background_color = QColor(
            resources.get_color('EditorBackground'))
        self._foreground_color = QColor(resources.get_color('Default'))
        self._selection_color = QColor(
            resources.get_color('EditorSelectionColor'))
        self._selection_background_color = QColor(
            resources.get_color('EditorSelectionBackground'))
        self.__apply_style()

        self._init_settings()
        self._highlighter = None
        self.__visible_blocks = []
        self._last_line_position = 0
        self.__encoding = None
        self.__show_whitespaces = settings.SHOW_TABS_AND_SPACES
        self.__side_widgets = []
        # Extra Selections
        self._extra_selections = OrderedDict()
        self._current_line_selection = None
        self.__checker_extra_selections = []
        self.__occurrences = []
        # Load indenter based on language
        self._indenter = indenter.load_indenter(self, neditable.language())
        # Set editor font before build lexer
        self.set_font(settings.FONT)
        self.register_syntax_for(neditable.language())
        # Register all editor extension
        self.initialize_extensions()
        # FIXME: based on lang
        self.enable_extension('indentation_guides',
                              settings.SHOW_INDENTATION_GUIDE)
        self.enable_extension('margin_line', settings.SHOW_MARGIN_LINE)
        self.enable_extension('line_highlighter', True)
        self.enable_extension('symbol_highlighter', True)
        self.enable_extension('quotes', True)
        self.enable_extension('braces', True)
        # self._symbol_completer = symbol_completer.SymbolCompleter(self)

        # Mark occurrences timer
        self._highlight_word_timer = QTimer()
        self._highlight_word_timer.setSingleShot(True)
        self._highlight_word_timer.setInterval(800)
        self._highlight_word_timer.timeout.connect(
            self.highlight_selected_word)
        # Install custom scrollbar
        self._scrollbar = scrollbar.NScrollBar(self)
        self._scrollbar.setAttribute(Qt.WA_OpaquePaintEvent, False)
        self.setVerticalScrollBar(self._scrollbar)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.additional_builtins = None
        # Set the editor after initialization
        if self._neditable is not None:
            if self._neditable.editor:
                self.setDocument(self._neditable.document)
            else:
                self._neditable.set_editor(self)
            self._neditable.checkersUpdated.connect(self._highlight_checkers)
        # Widgets on side area
        self._line_number_area = None
        if settings.SHOW_LINE_NUMBERS:
            self._line_number_area = self.add_side_widget(
                line_number_area.LineNumberArea, 2)
        self._lint_area = None
        # if settings.SHOW_LINT_AREA:
        #    self._lint_area = self.add_side_widget(lint_area.LintArea, 3)
        self._marker_area = None
        # if settings.SHOW_MARK_AREA:
        #    self._marker_area = self.add_side_widget(marker_area.MarkerArea, 1)
        self._text_change_area = None
        if settings.SHOW_TEXT_CHANGE_AREA:
            self._text_change_area = self.add_side_widget(
                text_change_area.TextChangeArea, 0)
        # FIXME: we need a method to initialize
        self.__set_whitespaces_flags(self.__show_whitespaces)

        self.cursorPositionChanged.connect(self._on_cursor_position_changed)
        self.cursorPositionChanged.connect(self.viewport().update)
Ejemplo n.º 19
0
 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()
Ejemplo n.º 20
0
 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()
Ejemplo n.º 21
0
 def __init__(self, parent=None):
     QPlainTextEdit.__init__(self, parent)
     self.setAcceptDrops(True)
     self.file = ''
Ejemplo n.º 22
0
 def __init__(self, parent):
     QPlainTextEdit.__init__(self, parent)
     self.highlighter = QtQmlHighlighter(self)
Ejemplo n.º 23
0
 def __init__(self, *, default_text='', read_only=False):
     QPlainTextEdit.__init__(self, default_text)
     self.setReadOnly(read_only)
Ejemplo n.º 24
0
 def __init__(self, text=None):
     QPlainTextEdit.__init__(self, text)
     self.setText = self.setPlainText
     self.text = self.toPlainText
     self.buttons = []
Ejemplo n.º 25
0
 def __init__(self, parent):
     QPlainTextEdit.__init__(self, parent)
     self.highlighter = QtQmlHighlighter(self)
Ejemplo n.º 26
0
 def __init__(self, text=None):
     QPlainTextEdit.__init__(self, text)
     self.setText = self.setPlainText
     self.text = self.toPlainText
     self.buttons: Iterable[QAbstractButton] = []
Ejemplo n.º 27
0
    def __init__(self, neditable):
        QPlainTextEdit.__init__(self)
        self.setFrameStyle(0)  # Remove border
        self._neditable = neditable
        self.setMouseTracking(True)

        # Style
        self._background_color = QColor(
            resources.get_color('EditorBackground'))
        self._foreground_color = QColor(resources.get_color('Default'))
        self._selection_color = QColor(
            resources.get_color('EditorSelectionColor'))
        self._selection_background_color = QColor(
            resources.get_color('EditorSelectionBackground'))
        self.__apply_style()

        self.setCursorWidth(2)
        self._highlighter = None
        self.__visible_blocks = []
        self._last_line_position = 0
        self.__encoding = None
        self.__show_whitespaces = settings.SHOW_TABS_AND_SPACES
        self.__side_widgets = []
        # Extra Selections
        self._extra_selections = OrderedDict()
        self.__occurrences = []
        # Load indenter based on language
        self._indenter = indenter.load_indenter(self, neditable.language())
        # Set editor font before build lexer
        self.default_font = settings.FONT
        self.register_syntax_for(neditable.language())
        # Register extensions
        self.__extensions = {}
        # Brace matching
        self._brace_matching = self.register_extension(
            symbol_highlighter.SymbolHighlighter)
        self.brace_matching = settings.BRACE_MATCHING
        # Current line highlighter
        self._line_highlighter = self.register_extension(
            line_highlighter.CurrentLineHighlighter)
        self.highlight_current_line = settings.HIGHLIGHT_CURRENT_LINE
        # Right margin line
        self._margin_line = self.register_extension(margin_line.RightMargin)
        self.margin_line = settings.SHOW_MARGIN_LINE
        self.margin_line_position = settings.MARGIN_LINE
        self.margin_line_background = settings.MARGIN_LINE_BACKGROUND
        # Indentation guides
        self._indentation_guides = self.register_extension(
            indentation_guides.IndentationGuide)
        self.show_indentation_guides(settings.SHOW_INDENTATION_GUIDES)
        # Autocomplete braces
        self.__autocomplete_braces = self.register_extension(
            braces.AutocompleteBraces)
        self.autocomplete_braces(settings.AUTOCOMPLETE_BRACKETS)
        # Autocomplete quotes
        self.__autocomplete_quotes = self.register_extension(
            quotes.AutocompleteQuotes)
        self.autocomplete_quotes(settings.AUTOCOMPLETE_QUOTES)
        # Mark occurrences timer
        self._highlight_word_timer = QTimer()
        self._highlight_word_timer.setSingleShot(True)
        self._highlight_word_timer.setInterval(800)
        self._highlight_word_timer.timeout.connect(
            self.highlight_selected_word)
        # Install custom scrollbar
        self._scrollbar = scrollbar.NScrollBar(self)
        self._scrollbar.setAttribute(Qt.WA_OpaquePaintEvent, False)
        self.setVerticalScrollBar(self._scrollbar)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.additional_builtins = None
        # Set the editor after initialization
        if self._neditable is not None:
            if self._neditable.editor:
                self.setDocument(self._neditable.document)
            else:
                self._neditable.set_editor(self)
            self._neditable.checkersUpdated.connect(self._highlight_checkers)
        # Widgets on side area
        self._line_number_area = self.add_side_widget(
            line_number_area.LineNumberArea, order=2)
        self.show_line_numbers(settings.SHOW_LINE_NUMBERS)

        self._text_change_area = self.add_side_widget(
            text_change_area.TextChangeArea, order=0)
        self.show_text_changes(settings.SHOW_TEXT_CHANGES)

        self._marker_area = self.add_side_widget(marker_area.MarkerArea, 1)

        # FIXME: we need a method to initialize
        self.__set_whitespaces_flags(self.__show_whitespaces)

        self.cursorPositionChanged.connect(self._on_cursor_position_changed)
        self.cursorPositionChanged.connect(self.viewport().update)
Ejemplo n.º 28
0
 def __init__(self, focusin, focusout, closed = None, parent = None):
     QPlainTextEdit.__init__(self, parent)        
     self.focusin = focusin
     self.focusout = focusout
     self.closed = closed
Ejemplo n.º 29
0
 def __init__(self, text: Optional[str] = None) -> None:
     QPlainTextEdit.__init__(self, text)
     self.setText = self.setPlainText
     self.text = self.toPlainText
     self.buttons: Iterable[QAbstractButton] = []
 def __init__(self, input, parent):
     QPlainTextEdit.__init__(self, parent)
     #self.setLineWrapMode(True)
     self.countOfRows = 1
     self.setPlainText(input)
     self.changeRows(1)
Ejemplo n.º 31
0
 def __init__(self, text=None):
     QPlainTextEdit.__init__(self, text)
     self.setText = self.setPlainText
     self.text = self.toPlainText
     self.buttons = []
Ejemplo n.º 32
0
    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

        has_parent_settings = hasattr(parent, 'settings')
        if has_parent_settings and 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 has_parent_settings and 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 = getattr(parent, 'enabled_plugins', [])

        #Current Line highlight and Bracket matcher
        self.cursorPositionChanged.connect(self.curPositionChanged)
        self.textChanged.connect(self.textEditChanged)