environment/lib/python2.7/site-packages/IPython/frontend/qt/console/console_widget.py
def eventFilter(self, obj, event):
        """ Reimplemented to ensure a console-like behavior in the underlying
            text widgets.
        """
        etype = event.type()
        if etype == QtCore.QEvent.KeyPress:

            # Re-map keys for all filtered widgets.
            key = event.key()
            if self._control_key_down(event.modifiers()) and \
                    key in self._ctrl_down_remap:
                new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
                                            self._ctrl_down_remap[key],
                                            QtCore.Qt.NoModifier)
                QtGui.qApp.sendEvent(obj, new_event)
                return True

            elif obj == self._control:
                return self._event_filter_console_keypress(event)

            elif obj == self._page_control:
                return self._event_filter_page_keypress(event)

        # Make middle-click paste safe.
        elif etype == QtCore.QEvent.MouseButtonRelease and \
                event.button() == QtCore.Qt.MidButton and \
                obj == self._control.viewport():
            cursor = self._control.cursorForPosition(event.pos())
            self._control.setTextCursor(cursor)
            self.paste(QtGui.QClipboard.Selection)
            return True

        # Manually adjust the scrollbars *after* a resize event is dispatched.
        elif etype == QtCore.QEvent.Resize and not self._filter_resize:
            self._filter_resize = True
            QtGui.qApp.sendEvent(obj, event)
            self._adjust_scrollbars()
            self._filter_resize = False
            return True

        # Override shortcuts for all filtered widgets.
        elif etype == QtCore.QEvent.ShortcutOverride and \
                self.override_shortcuts and \
                self._control_key_down(event.modifiers()) and \
                event.key() in self._shortcuts:
            event.accept()

        # Ensure that drags are safe. The problem is that the drag starting
        # logic, which determines whether the drag is a Copy or Move, is locked
        # down in QTextControl. If the widget is editable, which it must be if
        # we're not executing, the drag will be a Move. The following hack
        # prevents QTextControl from deleting the text by clearing the selection
        # when a drag leave event originating from this widget is dispatched.
        # The fact that we have to clear the user's selection is unfortunate,
        # but the alternative--trying to prevent Qt from using its hardwired
        # drag logic and writing our own--is worse.
        elif etype == QtCore.QEvent.DragEnter and \
                obj == self._control.viewport() and \
                event.source() == self._control.viewport():
            self._filter_drag = True
        elif etype == QtCore.QEvent.DragLeave and \
                obj == self._control.viewport() and \
                self._filter_drag:
            cursor = self._control.textCursor()
            cursor.clearSelection()
            self._control.setTextCursor(cursor)
            self._filter_drag = False

        # Ensure that drops are safe.
        elif etype == QtCore.QEvent.Drop and obj == self._control.viewport():
            cursor = self._control.cursorForPosition(event.pos())
            if self._in_buffer(cursor.position()):
                text = event.mimeData().text()
                self._insert_plain_text_into_buffer(cursor, text)

            # Qt is expecting to get something here--drag and drop occurs in its
            # own event loop. Send a DragLeave event to end it.
            QtGui.qApp.sendEvent(obj, QtGui.QDragLeaveEvent())
            return True

        # Handle scrolling of the vsplit pager. This hack attempts to solve
        # problems with tearing of the help text inside the pager window.  This
        # happens only on Mac OS X with both PySide and PyQt. This fix isn't
        # perfect but makes the pager more usable.
        elif etype in self._pager_scroll_events and \
                obj == self._page_control:
            self._page_control.repaint()
            return True
        return super(ConsoleWidget, self).eventFilter(obj, event)
def eventFilter(self, obj, event):
        """ Reimplemented to ensure a console-like behavior in the underlying
            text widgets.
        """
        etype = event.type()
        if etype == QtCore.QEvent.KeyPress:

            # Re-map keys for all filtered widgets.
            key = event.key()
            if self._control_key_down(event.modifiers()) and \
                    key in self._ctrl_down_remap:
                new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
                                            self._ctrl_down_remap[key],
                                            QtCore.Qt.NoModifier)
                QtGui.qApp.sendEvent(obj, new_event)
                return True

            elif obj == self._control:
                return self._event_filter_console_keypress(event)

            elif obj == self._page_control:
                return self._event_filter_page_keypress(event)

        # Make middle-click paste safe.
        elif etype == QtCore.QEvent.MouseButtonRelease and \
                event.button() == QtCore.Qt.MidButton and \
                obj == self._control.viewport():
            cursor = self._control.cursorForPosition(event.pos())
            self._control.setTextCursor(cursor)
            self.paste(QtGui.QClipboard.Selection)
            return True

        # Manually adjust the scrollbars *after* a resize event is dispatched.
        elif etype == QtCore.QEvent.Resize and not self._filter_resize:
            self._filter_resize = True
            QtGui.qApp.sendEvent(obj, event)
            self._adjust_scrollbars()
            self._filter_resize = False
            return True

        # Override shortcuts for all filtered widgets.
        elif etype == QtCore.QEvent.ShortcutOverride and \
                self.override_shortcuts and \
                self._control_key_down(event.modifiers()) and \
                event.key() in self._shortcuts:
            event.accept()

        # Ensure that drags are safe. The problem is that the drag starting
        # logic, which determines whether the drag is a Copy or Move, is locked
        # down in QTextControl. If the widget is editable, which it must be if
        # we're not executing, the drag will be a Move. The following hack
        # prevents QTextControl from deleting the text by clearing the selection
        # when a drag leave event originating from this widget is dispatched.
        # The fact that we have to clear the user's selection is unfortunate,
        # but the alternative--trying to prevent Qt from using its hardwired
        # drag logic and writing our own--is worse.
        elif etype == QtCore.QEvent.DragEnter and \
                obj == self._control.viewport() and \
                event.source() == self._control.viewport():
            self._filter_drag = True
        elif etype == QtCore.QEvent.DragLeave and \
                obj == self._control.viewport() and \
                self._filter_drag:
            cursor = self._control.textCursor()
            cursor.clearSelection()
            self._control.setTextCursor(cursor)
            self._filter_drag = False

        # Ensure that drops are safe.
        elif etype == QtCore.QEvent.Drop and obj == self._control.viewport():
            cursor = self._control.cursorForPosition(event.pos())
            if self._in_buffer(cursor.position()):
                text = event.mimeData().text()
                self._insert_plain_text_into_buffer(cursor, text)

            # Qt is expecting to get something here--drag and drop occurs in its
            # own event loop. Send a DragLeave event to end it.
            QtGui.qApp.sendEvent(obj, QtGui.QDragLeaveEvent())
            return True

        # Handle scrolling of the vsplit pager. This hack attempts to solve
        # problems with tearing of the help text inside the pager window.  This
        # happens only on Mac OS X with both PySide and PyQt. This fix isn't
        # perfect but makes the pager more usable.
        elif etype in self._pager_scroll_events and \
                obj == self._page_control:
            self._page_control.repaint()
            return True
        return super(ConsoleWidget, self).eventFilter(obj, event)
def eventFilter ( self , obj , event ) : etype = event . type ( ) if etype == QtCore . QEvent . KeyPress : # Re-map keys for all filtered widgets. key = event . key ( ) if self . _control_key_down ( event . modifiers ( ) ) and key in self . _ctrl_down_remap : new_event = QtGui . QKeyEvent ( QtCore . QEvent . KeyPress , self . _ctrl_down_remap [ key ] , QtCore . Qt . NoModifier ) QtGui . qApp . sendEvent ( obj , new_event ) return True elif obj == self . _control : return self . _event_filter_console_keypress ( event ) elif obj == self . _page_control : return self . _event_filter_page_keypress ( event ) # Make middle-click paste safe. elif etype == QtCore . QEvent . MouseButtonRelease and event . button ( ) == QtCore . Qt . MidButton and obj == self . _control . viewport ( ) : cursor = self . _control . cursorForPosition ( event . pos ( ) ) self . _control . setTextCursor ( cursor ) self . paste ( QtGui . QClipboard . Selection ) return True # Manually adjust the scrollbars *after* a resize event is dispatched. elif etype == QtCore . QEvent . Resize and not self . _filter_resize : self . _filter_resize = True QtGui . qApp . sendEvent ( obj , event ) self . _adjust_scrollbars ( ) self . _filter_resize = False return True # Override shortcuts for all filtered widgets. elif etype == QtCore . QEvent . ShortcutOverride and self . override_shortcuts and self . _control_key_down ( event . modifiers ( ) ) and event . key ( ) in self . _shortcuts : event . accept ( ) # Ensure that drags are safe. The problem is that the drag starting # logic, which determines whether the drag is a Copy or Move, is locked # down in QTextControl. If the widget is editable, which it must be if # we're not executing, the drag will be a Move. The following hack # prevents QTextControl from deleting the text by clearing the selection # when a drag leave event originating from this widget is dispatched. # The fact that we have to clear the user's selection is unfortunate, # but the alternative--trying to prevent Qt from using its hardwired # drag logic and writing our own--is worse. elif etype == QtCore . QEvent . DragEnter and obj == self . _control . viewport ( ) and event . source ( ) == self . _control . viewport ( ) : self . _filter_drag = True elif etype == QtCore . QEvent . DragLeave and obj == self . _control . viewport ( ) and self . _filter_drag : cursor = self . _control . textCursor ( ) cursor . clearSelection ( ) self . _control . setTextCursor ( cursor ) self . _filter_drag = False # Ensure that drops are safe. elif etype == QtCore . QEvent . Drop and obj == self . _control . viewport ( ) : cursor = self . _control . cursorForPosition ( event . pos ( ) ) if self . _in_buffer ( cursor . position ( ) ) : text = event . mimeData ( ) . text ( ) self . _insert_plain_text_into_buffer ( cursor , text ) # Qt is expecting to get something here--drag and drop occurs in its # own event loop. Send a DragLeave event to end it. QtGui . qApp . sendEvent ( obj , QtGui . QDragLeaveEvent ( ) ) return True # Handle scrolling of the vsplit pager. This hack attempts to solve # problems with tearing of the help text inside the pager window.  This # happens only on Mac OS X with both PySide and PyQt. This fix isn't # perfect but makes the pager more usable. elif etype in self . _pager_scroll_events and obj == self . _page_control : self . _page_control . repaint ( ) return True return super ( ConsoleWidget , self ) . eventFilter ( obj , event )
Reimplemented to ensure a console-like behavior in the underlying
            text widgets.
Reimplemented to ensure a console - like behavior in the underlying text widgets .