def _create_control(self):
        """ Creates and connects the underlying text widget.
        """
        # Create the underlying control.
        if self.custom_control:
            control = self.custom_control()
        elif self.kind == 'plain':
            control = QtWidgets.QPlainTextEdit()
        elif self.kind == 'rich':
            control = QtWidgets.QTextEdit()
            control.setAcceptRichText(False)
            control.setMouseTracking(True)

        # Prevent the widget from handling drops, as we already provide
        # the logic in this class.
        control.setAcceptDrops(False)

        # Install event filters. The filter on the viewport is needed for
        # mouse events.
        control.installEventFilter(self)
        control.viewport().installEventFilter(self)

        # Connect signals.
        control.customContextMenuRequested.connect(
            self._custom_context_menu_requested)
        control.copyAvailable.connect(self.copy_available)
        control.redoAvailable.connect(self.redo_available)
        control.undoAvailable.connect(self.undo_available)

        # Hijack the document size change signal to prevent Qt from adjusting
        # the viewport's scrollbar. We are relying on an implementation detail
        # of Q(Plain)TextEdit here, which is potentially dangerous, but without
        # this functionality we cannot create a nice terminal interface.
        layout = control.document().documentLayout()
        layout.documentSizeChanged.disconnect()
        layout.documentSizeChanged.connect(self._adjust_scrollbars)

        # Configure the scrollbar policy
        if self.scrollbar_visibility:
            scrollbar_policy = QtCore.Qt.ScrollBarAlwaysOn
        else :
            scrollbar_policy = QtCore.Qt.ScrollBarAlwaysOff

        # Configure the control.
        control.setAttribute(QtCore.Qt.WA_InputMethodEnabled, True)
        control.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        control.setReadOnly(True)
        control.setUndoRedoEnabled(False)
        control.setVerticalScrollBarPolicy(scrollbar_policy)
        return control
 Creates and connects the underlying text widget.
        
angrmanagement/vendor/qtconsole/console_widget.py