/*
 * ncurses.h: the part of the curses API that Umoria uses, for the fredygames.com browser build
 * (Emscripten). The game's src/curses.h includes <ncurses.h>; the build puts this file first on the
 * include path. See emcurses.cpp.
 * Copyright (C) 2026 FredyGames. Distributed under the GNU General Public License, version 3 or (at
 * your option) any later version, like Umoria.
 */
#ifndef EMCURSES_H
#define EMCURSES_H

typedef unsigned int chtype;

struct WINDOW {
    int rows;
    int cols;
    int cury;
    int curx;
    unsigned char *cells; // rows * cols characters
};

extern WINDOW *stdscr;
extern WINDOW *curscr;
extern int LINES;
extern int COLS;

#define ERR (-1)
#define OK 0

#define getyx(win, y, x) ((y) = (win)->cury, (x) = (win)->curx)

WINDOW *initscr(void);
int endwin(void);
int raw(void);
int noecho(void);
int nonl(void);
int keypad(WINDOW *win, bool enable);
int curs_set(int visibility);
int set_escdelay(int ms);
WINDOW *newwin(int rows, int cols, int y, int x);
int overwrite(const WINDOW *src, WINDOW *dst);
int touchwin(WINDOW *win);
int wrefresh(WINDOW *win);
int refresh(void);
int clear(void);
int clrtoeol(void);
int clrtobot(void);
int move(int y, int x);
int addch(chtype ch);
int mvaddch(int y, int x, chtype ch);
int addstr(const char *str);
int mvaddstr(int y, int x, const char *str);
int getch(void);
int timeout(int ms);
int mvcur(int oldy, int oldx, int newy, int newx);

#endif
