From: Christian Heller Date: Sat, 24 Aug 2013 04:21:02 +0000 (+0200) Subject: Added further (though rarely informative) handling of windows library error. X-Git-Tag: tce~1061 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/process?a=commitdiff_plain;h=f74f720e631840566200e8f022b1068e6f3453fb;p=plomrogue Added further (though rarely informative) handling of windows library error. --- diff --git a/src/draw_wins.c b/src/draw_wins.c index 4dfd054..02b569c 100644 --- a/src/draw_wins.c +++ b/src/draw_wins.c @@ -11,6 +11,7 @@ #include "map_objects.h" /* for structs MapObj, Player */ #include "map.h" /* for Map struct */ #include "main.h" /* for World struct */ +#include "rexit.h" /* for err_exit() */ @@ -227,16 +228,18 @@ extern void draw_keys_win(struct Win * win) { if (0 == y && offset > 0) { - draw_scroll_hint(&win->frame, y, offset + 1, '^'); + exit_err(draw_scroll_hint(&win->frame, y, offset + 1, '^'), + world, NULL); continue; } else if (win->frame.size.y == y + 1 && 0 < world->keyswindata->max - (win->frame.size.y + offset - 1)) { - draw_scroll_hint(&win->frame, y, - world->keyswindata->max - - (offset + win->frame.size.y) + 2, 'v'); + exit_err(draw_scroll_hint(&win->frame, y, + world->keyswindata->max + - (offset + win->frame.size.y) + 2, 'v'), + world, NULL); continue; } attri = 0; diff --git a/src/keybindings.c b/src/keybindings.c index f33b559..0b5194c 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -10,6 +10,7 @@ #include "windows.h" /* for draw_all_wins() and WinMeta struct */ #include "misc.h" /* for texfile_sizes() */ #include "main.h" /* for World struct */ +#include "rexit.h" /* for err_exit() */ @@ -169,7 +170,7 @@ extern char * get_keyname(uint16_t keycode) extern void keyswin_mod_key(struct World * world, struct WinMeta * win_meta) { world->keyswindata->edit = 1; - draw_all_wins(win_meta); + exit_err(draw_all_wins(win_meta), world, "Window drawing error."); int key = getch(); if (key < 1000) { diff --git a/src/misc.c b/src/misc.c index 6f8c6c7..7256885 100644 --- a/src/misc.c +++ b/src/misc.c @@ -185,15 +185,15 @@ extern void save_game(struct World * world) -extern void toggle_window(struct WinMeta * win_meta, struct Win * win) +extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win) { if (0 != win->frame.curses_win) { - suspend_win(win_meta, win); + return suspend_win(win_meta, win); } else { - append_win(win_meta, win); + return append_win(win_meta, win); } } @@ -213,7 +213,7 @@ extern void scroll_pad(struct WinMeta * win_meta, char dir) -extern void growshrink_active_window(struct WinMeta * win_meta, char change) +extern uint8_t growshrink_active_window(struct WinMeta * win_meta, char change) { if (0 != win_meta->active) { @@ -234,8 +234,9 @@ extern void growshrink_active_window(struct WinMeta * win_meta, char change) { size.x++; } - resize_active_win (win_meta, size); + return resize_active_win (win_meta, size); } + return 0; } @@ -272,19 +273,19 @@ extern uint8_t meta_keys(int key, struct World * world, } else if (key == get_action_key(world->keybindings, "toggle keys window")) { - toggle_window(win_meta, win_keys); + exit_err(toggle_window(win_meta, win_keys), world, NULL); } else if (key == get_action_key(world->keybindings, "toggle map window")) { - toggle_window(win_meta, win_map); + exit_err(toggle_window(win_meta, win_map), world, NULL); } else if (key == get_action_key(world->keybindings, "toggle info window")) { - toggle_window(win_meta, win_info); + exit_err(toggle_window(win_meta, win_info), world, NULL); } else if (key == get_action_key(world->keybindings, "toggle log window")) { - toggle_window(win_meta, win_log); + exit_err(toggle_window(win_meta, win_log), world, NULL); } else if (key == get_action_key(world->keybindings, "cycle forwards")) { @@ -296,27 +297,27 @@ extern uint8_t meta_keys(int key, struct World * world, } else if (key == get_action_key(world->keybindings, "shift forwards")) { - shift_active_win(win_meta, 'f'); + exit_err(shift_active_win(win_meta, 'f'), world, NULL); } else if (key == get_action_key(world->keybindings, "shift backwards")) { - shift_active_win(win_meta, 'b'); + exit_err(shift_active_win(win_meta, 'b'), world, NULL); } else if (key == get_action_key(world->keybindings, "grow horizontally")) { - growshrink_active_window(win_meta, '*'); + exit_err(growshrink_active_window(win_meta, '*'), world, NULL); } else if (key == get_action_key(world->keybindings, "shrink horizontally")) { - growshrink_active_window(win_meta, '_'); + exit_err(growshrink_active_window(win_meta, '_'), world, NULL); } else if (key == get_action_key(world->keybindings, "grow vertically")) { - growshrink_active_window(win_meta, '+'); + exit_err(growshrink_active_window(win_meta, '+'), world, NULL); } else if (key == get_action_key(world->keybindings, "shrink vertically")) { - growshrink_active_window(win_meta, '-'); + exit_err(growshrink_active_window(win_meta, '-'), world, NULL); } else if (key == get_action_key(world->keybindings, "save keys")) { diff --git a/src/misc.h b/src/misc.h index 39efe6a..259a511 100644 --- a/src/misc.h +++ b/src/misc.h @@ -54,8 +54,11 @@ extern void save_game(struct World * world); -/* Toggle display of a window "win". */ -extern void toggle_window(struct WinMeta * win_meta, struct Win * win); +/* Toggle display of a window "win". + * + * Return 0 on success, 1 on (ncurses pad/window memory allocation) error. + */ +extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win); @@ -70,8 +73,10 @@ extern void scroll_pad(struct WinMeta * win_meta, char dir); /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or * vertically ("change = "+"/"-") by one cell size, subject to the limitations * provided by the window manager via resize_active_win(). + * + * Return 0 on success, 1 on (ncurses pad/window memory allocation) error. */ -extern void growshrink_active_window(struct WinMeta * win_meta, char change); +extern uint8_t growshrink_active_window(struct WinMeta * win_meta, char change);