Refactor space.py, add key layout extenders

* Key layouts can be extended in event class to generate custom commands
programmatically. Useful for dialog options, inventory items and other
multiple choice situations.
* Unit tests for collapsing and expanding layouts.
* Cyclomatic complexity of space.py is reduced, now it looks a bit more
tolerable. However work here is not done, UI is a bit screwed up.

Commit references #46.