Example #1
0
 def register_syntax_for(self, language="python", force=False):
     syntax = highlighter.build_highlighter(language)
     if syntax is not None:
         self._highlighter = highlighter.SyntaxHighlighter(
             self.document(),
             syntax.partition_scanner,
             syntax.scanners,
             syntax.context
         )
Example #2
0
 def register_syntax_for(self, language="python", force=False):
     syntax = highlighter.build_highlighter(language)
     if syntax is not None:
         self._highlighter = highlighter.SyntaxHighlighter(
             self.document(),
             syntax.partition_scanner,
             syntax.scanners,
             syntax.context
         )
Example #3
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)
Example #4
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)