Switched to using a stack of input-mode handlers

The concept is to push new handlers on the stack/list, and pop
them when they are no longer necessary.

There is no provision yet to stop sending keys to handlers, so
a single key can, as of now, trigger more than one action-thingie.