コード例 #1
0
    def __init__(self):
        super(ConsoleWidget, self).__init__('>>> ')
        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(settings.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()

        ninjaide = IDE.get_service('ide')
        self.connect(ninjaide,
                     SIGNAL("ns_preferences_editor_font(PyQt_PyObject)"),
                     self.set_font)
コード例 #2
0
ファイル: console_widget.py プロジェクト: Fieldbyte/ninja-ide
    def __init__(self):
        QPlainTextEdit.__init__(self, u'>>> ')
        self.setUndoRedoEnabled(False)
        styles.set_editor_style(self, resources.CUSTOM_SCHEME)
        self.setToolTip(self.tr("Show/Hide (F4)"))

        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.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()
コード例 #3
0
    def __init__(self, parent=None):
        super().__init__("❭ ")
        self.setUndoRedoEnabled(False)
        self.document().setDefaultFont(settings.FONT)
        self.setFrameShape(0)
        self.prompt = "❭ "
        # Hostory
        self._history_index = 0
        self._history = []
        self._current_command = ''

        self.moveCursor(QTextCursor.EndOfLine)
        self._console = console.Console()
        syntax = syntaxhighlighter.build_highlighter_for(language='python')
        self._highlighter = Highlighter(self.document(),
                                        syntax.partition_scanner,
                                        syntax.scanners, syntax.formats)

        self.apply_editor_style()
        # Key operations
        self._key_operations = {
            Qt.Key_Enter: self.__manage_enter,
            Qt.Key_Return: self.__manage_enter,
            Qt.Key_Backspace: self.__manage_backspace,
            Qt.Key_Left: self.__manage_left,
            Qt.Key_Home: self.__manage_home,
            Qt.Key_Up: self.__up_pressed,
            Qt.Key_Down: self.__down_pressed
        }
コード例 #4
0
    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()
コード例 #5
0
    def __init__(self, parent=None):
        super().__init__()
        self.setUndoRedoEnabled(False)
        self.setCursorWidth(10)
        self.setFrameShape(0)
        self.moveCursor(QTextCursor.EndOfLine)
        self.__incomplete = False
        # History
        self._history_index = 0
        self._history = []
        self._current_command = ''
        # Console
        self._console = console.Console()
        self.setFont(settings.FONT)
        # Set highlighter and indenter for Python
        syntax = highlighter.build_highlighter(language='python')
        if syntax is not None:
            self._highlighter = Highlighter(self.document(),
                                            syntax.partition_scanner,
                                            syntax.scanners, syntax.context)
        #     self._highlighter = Highlighter(self.document(), syntax)
        self._indenter = indenter.load_indenter(self, lang="python")
        # Sidebar
        self.sidebar = ConsoleSideBar(self)
        self.setViewportMargins(self.sidebar.sizeHint().width(), 0, 0, 0)
        # Key operations
        self._key_operations = {
            Qt.Key_Enter: self.__manage_enter,
            Qt.Key_Return: self.__manage_enter,
            Qt.Key_Left: self.__manage_left,
            Qt.Key_Up: self.__up_pressed,
            Qt.Key_Down: self.__down_pressed,
            Qt.Key_Home: self.__manage_home,
            Qt.Key_Backspace: self.__manage_backspace
        }
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._context_menu)

        _ToolsDock.register_widget("Interpreter", self)