def __init__(self, parent=None, **kw):
        """ Create a ConsoleWidget.

        Parameters
        ----------
        parent : QWidget, optional [default None]
            The parent for this widget.
        """
        super().__init__(**kw)
        if parent:
            self.setParent(parent)

        self._is_complete_msg_id = None
        self._is_complete_timeout = 0.1
        self._is_complete_max_time = None

        # While scrolling the pager on Mac OS X, it tears badly.  The
        # NativeGesture is platform and perhaps build-specific hence
        # we take adequate precautions here.
        self._pager_scroll_events = [QtCore.QEvent.Wheel]
        if hasattr(QtCore.QEvent, 'NativeGesture'):
            self._pager_scroll_events.append(QtCore.QEvent.NativeGesture)

        # Create the layout and underlying text widget.
        layout = QtWidgets.QStackedLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        self._control = self._create_control()
        if self.paging in ('hsplit', 'vsplit'):
            self._splitter = QtWidgets.QSplitter()
            if self.paging == 'hsplit':
                self._splitter.setOrientation(QtCore.Qt.Horizontal)
            else:
                self._splitter.setOrientation(QtCore.Qt.Vertical)
            self._splitter.addWidget(self._control)
            layout.addWidget(self._splitter)
        else:
            layout.addWidget(self._control)

        # Create the paging widget, if necessary.
        if self.paging in ('inside', 'hsplit', 'vsplit'):
            self._page_control = self._create_page_control()
            if self._splitter:
                self._page_control.hide()
                self._splitter.addWidget(self._page_control)
            else:
                layout.addWidget(self._page_control)

        # Initialize protected variables. Some variables contain useful state
        # information for subclasses; they should be considered read-only.
        self._append_before_prompt_cursor = self._control.textCursor()
        self._ansi_processor = QtAnsiCodeProcessor()
        if self.gui_completion == 'ncurses':
            self._completion_widget = CompletionHtml(self, self.gui_completion_height)
        elif self.gui_completion == 'droplist':
            self._completion_widget = CompletionWidget(self, self.gui_completion_height)
        elif self.gui_completion == 'plain':
            self._completion_widget = CompletionPlain(self)

        self._continuation_prompt = '> '
        self._continuation_prompt_html = None
        self._executing = False
        self._filter_resize = False
        self._html_exporter = HtmlExporter(self._control)
        self._input_buffer_executing = ''
        self._input_buffer_pending = ''
        self._kill_ring = QtKillRing(self._control)
        self._prompt = ''
        self._prompt_html = None
        self._prompt_cursor = self._control.textCursor()
        self._prompt_sep = ''
        self._reading = False
        self._reading_callback = None
        self._tab_width = 4

        # List of strings pending to be appended as plain text in the widget.
        # The text is not immediately inserted when available to not
        # choke the Qt event loop with paint events for the widget in
        # case of lots of output from kernel.
        self._pending_insert_text = []

        # Timer to flush the pending stream messages. The interval is adjusted
        # later based on actual time taken for flushing a screen (buffer_size)
        # of output text.
        self._pending_text_flush_interval = QtCore.QTimer(self._control)
        self._pending_text_flush_interval.setInterval(100)
        self._pending_text_flush_interval.setSingleShot(True)
        self._pending_text_flush_interval.timeout.connect(
                                            self._on_flush_pending_stream_timer)

        # Set a monospaced font.
        self.reset_font()

        # Configure actions.
        action = QtWidgets.QAction('Print', None)
        action.setEnabled(True)
        printkey = QtGui.QKeySequence(QtGui.QKeySequence.Print)
        if printkey.matches("Ctrl+P") and sys.platform != 'darwin':
            # Only override the default if there is a collision.
            # Qt ctrl = cmd on OSX, so the match gets a false positive on OSX.
            printkey = "Ctrl+Shift+P"
        action.setShortcut(printkey)
        action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.print_)
        self.addAction(action)
        self.print_action = action

        action = QtWidgets.QAction('Save as HTML/XML', None)
        action.setShortcut(QtGui.QKeySequence.Save)
        action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.export_html)
        self.addAction(action)
        self.export_action = action

        action = QtWidgets.QAction('Select All', None)
        action.setEnabled(True)
        selectall = QtGui.QKeySequence(QtGui.QKeySequence.SelectAll)
        if selectall.matches("Ctrl+A") and sys.platform != 'darwin':
            # Only override the default if there is a collision.
            # Qt ctrl = cmd on OSX, so the match gets a false positive on OSX.
            selectall = "Ctrl+Shift+A"
        action.setShortcut(selectall)
        action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.select_all_smart)
        self.addAction(action)
        self.select_all_action = action

        self.increase_font_size = QtWidgets.QAction("Bigger Font",
                self,
                shortcut=QtGui.QKeySequence.ZoomIn,
                shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
                statusTip="Increase the font size by one point",
                triggered=self._increase_font_size)
        self.addAction(self.increase_font_size)

        self.decrease_font_size = QtWidgets.QAction("Smaller Font",
                self,
                shortcut=QtGui.QKeySequence.ZoomOut,
                shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
                statusTip="Decrease the font size by one point",
                triggered=self._decrease_font_size)
        self.addAction(self.decrease_font_size)

        self.reset_font_size = QtWidgets.QAction("Normal Font",
                self,
                shortcut="Ctrl+0",
                shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
                statusTip="Restore the Normal font size",
                triggered=self.reset_font)
        self.addAction(self.reset_font_size)

        # Accept drag and drop events here. Drops were already turned off
        # in self._control when that widget was created.
        self.setAcceptDrops(True)
 Create a ConsoleWidget.

        Parameters
        ----------
        parent : QWidget, optional [default None]
            The parent for this widget.
        
angrmanagement/vendor/qtconsole/console_widget.py