X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fclient%2Fwindows.c;h=1459ec2303c6c3b83946dbc4f94a8bd5252c16a5;hb=96ec154837699bd8687d1067deec4f6e593d99c9;hp=dcf450b3fecff04703bb513d256cb021f5f594d4;hpb=dd9d65ee727ac7e95801da0f8b5bae7009811802;p=plomrogue diff --git a/src/client/windows.c b/src/client/windows.c index dcf450b..1459ec2 100644 --- a/src/client/windows.c +++ b/src/client/windows.c @@ -1,14 +1,15 @@ /* src/client/windows.c */ #include "windows.h" +#include /* NULL */ #include /* uint8_t, uint16_t, uint32_t, UINT16_MAX */ #include /* sprintf() */ #include /* free() */ #include /* strlen(), memcpy(), strnlen() */ -#include /* pnoutrefresh(), doupdate(), werase(), wnoutrefresh(), - * erase(), getmaxx(), getmaxy(), delwin(), endwin(), - * initscr(), noecho(), curs_set(), newpad(), mvwaddch(), - * mvwaddstr(), wresize(), chtype +#include /* chtype, pnoutrefresh(), doupdate(), werase(), erase(), + * wnoutrefresh(), getmaxx(), getmaxy(), initscr(), + * noecho(), curs_set(), newpad(), mvwaddch(), mvwaddstr(), + * wresize() */ #include "../common/rexit.h" /* for exit_err() */ #include "../common/try_malloc.h" /* for try_malloc() */ @@ -422,29 +423,38 @@ static void shift_win_backward() -extern void init_win_meta() +extern void init_wmeta_and_ncurses() { - char * err_s = "init_win_meta() creates virtual screen beyond legal size."; - char * err_m = "init_win_meta() triggers memory alloc error via newpad()."; world.wmeta.screen = initscr(); set_cleanup_flag(CLEANUP_NCURSES); noecho(); curs_set(0); - uint32_t maxy_test = getmaxy(world.wmeta.screen); - uint32_t maxx_test = getmaxx(world.wmeta.screen); - exit_err(maxy_test > UINT16_MAX || maxx_test > UINT16_MAX, err_s); - world.wmeta.padsize.y = maxy_test; - world.wmeta.padsize.x = maxx_test; + world.wmeta.padsize.y = 0; + world.wmeta.padsize.x = 0; world.wmeta.chain_start = 0; world.wmeta.chain_end = 0; world.wmeta.pad_offset = 0; - world.wmeta.pad = newpad(world.wmeta.padsize.y, 1); - exit_err(NULL == world.wmeta.pad, err_m); + world.wmeta.pad = NULL; world.wmeta.active = 0; } +extern void make_pad() +{ + char * err_s = "make_pad() creates an illegaly large virtual screen."; + char * err_m = "make_pad() triggers memory allocation error via newpad()."; + uint32_t maxy_test = getmaxy(world.wmeta.screen); + uint32_t maxx_test = getmaxx(world.wmeta.screen); + exit_err(maxy_test > UINT16_MAX || maxx_test > UINT16_MAX, err_s); + world.wmeta.padsize.y = maxy_test; + world.wmeta.padsize.x = maxx_test; + world.wmeta.pad = newpad(world.wmeta.padsize.y, 1); + exit_err(NULL == world.wmeta.pad, err_m); +} + + + extern void init_win(struct Win ** wp, char * title, int16_t height, int16_t width, void * func) { @@ -460,35 +470,29 @@ extern void init_win(struct Win ** wp, char * title, int16_t height, w->draw = func; w->center.y = 0; w->center.x = 0; - if (0 < width) + w->framesize.y = world.wmeta.padsize.y - 1; + if (0 < height && height <= world.wmeta.padsize.y - 1) { - w->framesize.x = width; + w->framesize.y = height; } - else if (0 >= width) + else if (0 > height && world.wmeta.padsize.y + (height - 1) > 0) { - w->framesize.x = world.wmeta.padsize.x + width; + w->framesize.y = world.wmeta.padsize.y + (height - 1); } - if (0 < height && height <= world.wmeta.padsize.y - 1) + w->framesize.x = world.wmeta.padsize.x; + if (0 < width) { - w->framesize.y = height; + w->framesize.x = width; } - else if (0 >= height && world.wmeta.padsize.y + (height - 1) > 0) + else if (0 > width && world.wmeta.padsize.x + width > 0) { - w->framesize.y = world.wmeta.padsize.y + (height - 1); + w->framesize.x = world.wmeta.padsize.x + width; } *wp = w; } -extern void free_winmeta_and_endwin() -{ - delwin(world.wmeta.pad); - endwin(); -} - - - extern void free_win(struct Win * win) { free(win->title);