Add input for text mode.

Needs refactoring, modified from a previous project.
Merge branch 'dev/io' of https://github.com/ianrtaylor/ncmine
merge online changes.