tweak history prefix search (up/^p) in qtconsole

moving the cursor around the line could result in
weird inconsistencies in the prefix.

This simplifies the logic by always using the cursor position
to set the history prefix,
and better determine when the history prefix has actually changed.
fix typo in qtconsole history_next

while condition was always checking initial value,
rather than the iterating value.
time(it) magic: format timespans up to hours in human readable form

* Refactor time formatting of timeit into a new function
* Add minutes and hours for long running cells/lines
* Convert time and timeit magic to use the new function

Minutes and hours are float formatted, so 1.5 h is "1 hour, 30 minutes".

Signed-off-by: Jan Schulz <jasc@gmx.net>
time magic: make it usable as cell magic

Convert time to be usable as cell level magic. Also fix some examples,
which didn't have a '%' in front of the magic.

Signed-off-by: Jan Schulz <jasc@gmx.net>
Don't load curses on startup
Defer import of urllib
Defer import of xml.dom.minidom
Defer import of IPython.lib.inputhook
Defer import of json
Remove unused code
Defer import of optparse
Remove unused imports
codeutil should be imported
Make enable_gui a staticmethod again
Document API change
fix celltoolbar layout on FF
minor css fixes
Print a real "µs" instead of "us"

The unicode version is guarded so that it won't crash in terminals which
do not support that sign.

Signed-off-by: Jan Schulz <jasc@gmx.net>
time(it) magic: More human readable time format for value >1min

Signed-off-by: Jan Schulz <jasc@gmx.net>
time magic: fix unittests

time is now reported as '0 ns' and not '0.00 s'

Signed-off-by: Jan Schulz <jasc@gmx.net>