aboutsummaryrefslogtreecommitdiffstats
path: root/ncursor.c
blob: 4171f10f891ec9aeb7e8a9772bd3423b3ad9ae0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (C) 2014  Tomasz Kramkowski <tk@the-tk.com>
 *
 * This program is free software. It is licensed under version 3 of the
 * GNU General Public License.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see [http://www.gnu.org/licenses/].
 */

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

int main(int argc, char **argv)
{
    initscr();
    raw();
    noecho();

    int row, col;
    getmaxyx(stdscr, row, col);

    int x = 0, y = 0;

    bool run = true;
    while (run) {
        char c = getch();
        switch (c) {
            case 'w': if (x > 0) x--; break;
            case 's': if (x < (row - 1)) x++; break;
            case 'a': if (y > 0) y--; break;
            case 'd': if (y < (col - 1)) y++; break;
            case 'x': run = false; break;
        }
        move(x, y);
    }

    endwin();
}