// Oldham, Jeffrey D. // 2000Mar13 // CS1321 // Brain-Dead String Editor // based on Eric Roberts's \emph{Programming Abstractions in C}, chapter~9. #include #include // has EXIT_SUCCESS #include #include // has tolower() #include "buffer.h" int main() { buffer b; string command; cout << "prompt> "; while (getline(cin, command)) { if (command.size() > 0) { char c = tolower(command[0]); if (c == 'b') b.backCursor(); else if (c == 'f') b.forwardCursor(); else if (c == 'd') b.deleteChar(); else if (c == 'i') b.insertChars(command.substr(1)); // extract all but the first character else if (c == 'q') return EXIT_SUCCESS; // quit else cerr << "Illegal command\n"; } cout << b << endl; printCursor(cout, b) << endl; cout << "prompt> "; } return EXIT_SUCCESS; }