+
+//
+// -------------------------------------------------------------------------
+//
+class ScanAction : public NCursesMenuItem
+{
+public:
+ ScanAction(const char* s) : NCursesMenuItem(s) {
+ }
+
+ bool action() {
+ NCursesPanel *std = new NCursesPanel();
+
+ NCursesPanel *w = new NCursesPanel(std->lines() - 2, std->cols() - 2, 1, 1);
+ w->box();
+ w->refresh();
+
+ NCursesPanel *s = new NCursesPanel(w->lines() - 6, w->cols() - 6, 3, 3);
+ s->scrollok(TRUE);
+ ::echo();
+
+ s->printw("Enter decimal integers. The running total will be shown\n");
+ int value = -1;
+ int result = 0;
+ while (value != 0) {
+ value = 0;
+ s->scanw("%d", &value);
+ if (value != 0) {
+ s->printw("%d: ", result += value);
+ }
+ s->refresh();
+ }
+ s->printw("\nPress any key to continue...");
+ s->getch();
+
+ delete s;
+ delete w;
+ delete std;
+ ::noecho();
+ return FALSE;
+ }
+};
+