From 336d57bf85ed4b64307dea367c696ec9b477504a Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 17 May 2013 02:36:59 +0200 Subject: [PATCH] resize_window() now does its own check for existence of active window. --- roguelike.c | 8 ++++---- windows.c | 15 ++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) 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. -- 2.30.2