#include "ncurses.h"
#include <stdlib.h>

class cur{

public:
    cur()
    {
        initscr();
        cbreak();
        keypad(stdscr, TRUE);
        halfdelay(1);
        noecho();
    }
    ~cur()
    {
        endwin();
    }

    void nowait()
    {
        halfdelay(1);
    }

    void wait()
    {
        nocbreak();
        cbreak();
    }

    int getInt()
    {
        echo();
        wait();
        char c=0;
        int num = 0;
        c = getch();
        while (c!=EOF && c!='\n' && c !=' ')
        {
            if (c < 48 || c > 57)
            {
                printw("error number expected\n");
                num = 0;
            }
            else
                num = (num*10) + (c-48);
            c = getch();
        }
        noecho();
        nowait();
        return num;
    }

    operator int ()
    {
        return getInt();
    }    
};
