Refactor inputhook to allow easy extension

Not ready for merge

Prompted by #5645, @minrk suggested that we should provide an extension mechanism for input hooks, so that that code (which we don't use, test or maintain very much) can be maintained outside IPython. This is a prototype of that.

To define a new GUI integration, you register a class like this:

```python
from IPython.lib.inputhook import register, InputHookBase

@register('clutter')
class ClutterInputHook(InputHookBase):
    def enable(self, app=None):
        self.manager.set_inputhook(inputhook_clutter)
```

It can also define a `disable()` method, but only one of the 7 we include needs that. Once this code has run (e.g. by importing a module or using `%load_ext`), the user should be able to do `%gui clutter`.

To do:

- [x] Similar mechanisms for the kernel event loop
- [x] Docs
- [ ] Tests

Fair enough. This is a pretty advanced / low-level API, so I guess that's okay.