Initial XTerm support

This set of commits implements XTerm support (command and key sequences) enough to run Midnight Commander with the same level of comfort as in XTerm on typical Linux X Windows install: switching panels on/off to access underlying shell screen works, most keys work (not all so far), etc.

More refactoring and elaboration is required for this patchset, I submit this for initial feedback/review and as FYI for people who may want/hack on the same functionality.