//This file is main.C. #include #include #include "printable.h" #include "terminal1d.h" using namespace std; int main() { terminal1d term('.'); const terminal1d::keypad_t keypad = term.keypad(); const string s = "Type hlj for left, right, quit."; copy(s.begin(), s.end(), term.begin()); printable p = ' '; for (terminal1d::iterator it = term.begin() + term.size() / 2;;) { try { ++p; } catch (const printable::bad&) { p = ' '; } *it = p; //Copy the term to the top line of the screen. for (int x = 0; x < term.size(); ++x) { term_put(x, 0, term[x]); } char c; //uninitialized variable while ((c = term.key()) == '\0') { } if (c == 'q') { break; } const terminal1d::keypad_t::const_iterator i = keypad.find(c); if (i == keypad.end() || !term.in_range(it + i->second)) { term.beep(); } else { it += i->second; } } term.beep(); term.wait(1000); return EXIT_SUCCESS; }