From: Christian Heller Date: Fri, 17 May 2013 00:36:59 +0000 (+0200) Subject: resize_window() now does its own check for existence of active window. X-Git-Tag: tce~1289 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/process?a=commitdiff_plain;h=336d57bf85ed4b64307dea367c696ec9b477504a;p=plomrogue resize_window() now does its own check for existence of active window. --- diff --git a/roguelike.c b/roguelike.c index e7ece3a..bc21ab5 100644 --- a/roguelike.c +++ b/roguelike.c @@ -494,13 +494,13 @@ int main () { shift_window(&win_meta, 'f'); else if (key == get_action_key(world.keybindings, "shift backwards")) shift_window(&win_meta, 'b'); - else if (key == get_action_key(world.keybindings, "grow horizontally") && win_meta.active != 0) + else if (key == get_action_key(world.keybindings, "grow horizontally")) resize_window(&win_meta, '*'); - else if (key == get_action_key(world.keybindings, "shrink horizontally") && win_meta.active != 0) + else if (key == get_action_key(world.keybindings, "shrink horizontally")) resize_window(&win_meta, '_'); - else if (key == get_action_key(world.keybindings, "grow vertically") && win_meta.active != 0) + else if (key == get_action_key(world.keybindings, "grow vertically")) resize_window(&win_meta, '+'); - else if (key == get_action_key(world.keybindings, "shrink vertically") && win_meta.active != 0) + else if (key == get_action_key(world.keybindings, "shrink vertically")) resize_window(&win_meta, '-'); else if (key == get_action_key(world.keybindings, "save keys")) save_keybindings(&world); diff --git a/windows.c b/windows.c index cc9f0f2..ebf6ecf 100644 --- a/windows.c +++ b/windows.c @@ -193,15 +193,16 @@ void draw_all_windows (struct WinMeta * win_meta) { void resize_window (struct WinMeta * win_meta, char change) { // Grow or shrink currently active window. Correct its geometry and that of its followers. - if (change == '-' && win_meta->active->height > 1) + if (0 != win_meta->active) { + if (change == '-' && win_meta->active->height > 1) win_meta->active->height--; - else if (change == '+' && win_meta->active->height < win_meta->height - 1) - win_meta->active->height++; - else if (change == '_' && win_meta->active->width > 1) + else if (change == '+' && win_meta->active->height < win_meta->height - 1) + win_meta->active->height++; + else if (change == '_' && win_meta->active->width > 1) win_meta->active->width--; - else if (change == '*') - win_meta->active->width++; - update_windows(win_meta, win_meta->chain_start); } + else if (change == '*') + win_meta->active->width++; + update_windows(win_meta, win_meta->chain_start); } } void cycle_active_window (struct WinMeta * win_meta, char dir) { // Cycle active window selection forwards (dir = 'n') or backwards.