home · contact · privacy
resize_window() now does its own check for existence of active window.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 17 May 2013 00:36:59 +0000 (02:36 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 17 May 2013 00:36:59 +0000 (02:36 +0200)
roguelike.c
windows.c

index e7ece3a0a58601b8d99a22b40ec1a10959e28422..bc21ab5a0dfb5b6c23bbc51fac3b514f777b5e81 100644 (file)
@@ -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);
index cc9f0f2b9c20a0cc944b74d8a4cd54c3820d5187..ebf6ecf7af55148f8ed27222a5090644a9576010 100644 (file)
--- 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.