home · contact · privacy
More consistent code styling whitespace rules.
[plomrogue] / src / wincontrol.c
index 41ba94525a24f1de3c05635a89ba7cd79ae84fae..f6e0d2973093d270b9a00103b514b56fde3a2cbe 100644 (file)
@@ -10,7 +10,7 @@
                       * structs Win, WinMeta
                       */
 #include "yx_uint16.h" /* for yx_uint16 struct */
-#include "main.h" /* for Wins struct */
+#include "main.h" /* for world global */
 #include "readwrite.h" /* for get_linemax(), try_fopen(), try_fclose(),
                         * try_fgets(), try_fclose_unlink_rename(), try_fwrite()
                         */
@@ -33,8 +33,6 @@
 /* Return string "prefix" + "id"; malloc()'s string, remember to call free()! */
 static char * string_prefixed_id(char * prefix, char id);
 
-
-
 /* Create Winconf, init ->view/height_type/width_type to 0, ->id to "id". */
 static void create_winconf(char id, struct WinConf * wcp);
 
@@ -50,15 +48,11 @@ static void save_win_config(char id);
 /* Free data pointed to inside WinConf struct. */
 static void free_winconf_data(char id);
 
-
-
 /* Write geometry of a window to its WinConf, as positive or negative values
  * (dependent on state ofWinConf->height_type / WinConf->width_type).
  */
 static void set_winconf_geometry(char id);
 
-
-
 /* Get WinConf by "id"; get id of WinConf mothering "win". */
 static struct WinConf * get_winconf_by_id(char id);
 
@@ -157,17 +151,11 @@ static void init_winconf_from_file(char id)
 
 static void init_win_from_winconf(char id)
 {
-    char * tmp = "Trouble in init_win_from_file() with init_win() (win id: _).";
-    char * err = try_malloc(strlen(tmp) + 1, "init_win_from_file()");
-    memcpy(err, tmp, strlen(tmp) + 1);
-    err[strlen(tmp) - 3] = id;
+    char * err = "get_drawfunc_by_char() returns NULL to init_win_from_file().";
     struct WinConf * winconf = get_winconf_by_id(id);
     void * f = get_drawfunc_by_char(winconf->draw);
     exit_err(NULL == f, err);
-    uint8_t test = init_win(world.wmeta, &winconf->win, winconf->title,
-                            winconf->height, winconf->width, f);
-    exit_err(test, err);
-    free(err);
+    init_win(&winconf->win, winconf->title, winconf->height, winconf->width, f);
 }
 
 
@@ -449,12 +437,11 @@ extern void sorted_wintoggle_and_activate()
         {
             continue;
         }
-        struct Win * win = get_win_by_id(win_order[i]);
-        toggle_window(world.wmeta, win);
+        toggle_window(win_order[i]);
 
         if (a == (uint8_t) win_order[i])
         {
-            world.wmeta->active = win;
+            world.wmeta->active = get_win_by_id(win_order[i]);
         }
     }
 }
@@ -498,23 +485,25 @@ extern void save_win_configs()
 
 
 
-extern uint8_t toggle_window(struct WinMeta * win_meta, struct Win * win)
+extern void toggle_window(char id)
 {
-    if (0 == win->prev && win_meta->chain_start != win) /* Win outside chain. */
-    {
-        return append_win(win_meta, win);
+    struct Win * win = get_win_by_id(id);
+    if (0 == win->prev && world.wmeta->chain_start != win)  /* Win struct is  */
+    {                                                       /* outside chain. */
+        append_win(win);
     }
     else
     {
-        return suspend_win(win_meta, win);
+        suspend_win(win);
     }
 }
 
 
 
-extern void toggle_winconfig(struct Win * win)
+extern void toggle_winconfig()
 {
-    struct WinConf * wcp = get_winconf_by_win(win);
+   struct Win * win = world.wmeta->active;
+   struct WinConf * wcp = get_winconf_by_win(win);
     if      (0 == wcp->view)
     {
         win->draw = draw_winconf_geometry;
@@ -539,8 +528,9 @@ extern void toggle_winconfig(struct Win * win)
 
 
 
-extern void toggle_win_height_type(struct Win * win)
+extern void toggle_win_height_type()
 {
+    struct Win * win = world.wmeta->active;
     struct WinConf * wcp = get_winconf_by_win(win);
     if (0 == wcp->height_type)
     {
@@ -555,8 +545,9 @@ extern void toggle_win_height_type(struct Win * win)
 
 
 
-extern void toggle_win_width_type(struct Win * win)
+extern void toggle_win_width_type()
 {
+    struct Win * win = world.wmeta->active;
     struct WinConf * wcp = get_winconf_by_win(win);
     if (0 == wcp->width_type && win->framesize.x <= world.wmeta->padsize.x)
     {
@@ -571,21 +562,21 @@ extern void toggle_win_width_type(struct Win * win)
 
 
 
-extern void scroll_pad(struct WinMeta * win_meta, char dir)
+extern void scroll_pad(char dir)
 {
     if      ('+' == dir)
     {
-        reset_pad_offset(win_meta, win_meta->pad_offset + 1);
+        reset_pad_offset(world.wmeta->pad_offset + 1);
     }
     else if ('-' == dir)
     {
-        reset_pad_offset(win_meta, win_meta->pad_offset - 1);
+        reset_pad_offset(world.wmeta->pad_offset - 1);
     }
 }
 
 
 
-extern uint8_t growshrink_active_window(char change)
+extern void growshrink_active_window(char change)
 {
     if (0 != world.wmeta->active)
     {
@@ -606,7 +597,7 @@ extern uint8_t growshrink_active_window(char change)
         {
             size.x++;
         }
-        uint8_t x = resize_active_win(world.wmeta, size);
+        resize_active_win(size);
         struct WinConf * wcp = get_winconf_by_win(world.wmeta->active);
         if (   1 == wcp->width_type
             && world.wmeta->active->framesize.x > world.wmeta->padsize.x)
@@ -614,7 +605,5 @@ extern uint8_t growshrink_active_window(char change)
             wcp->width_type = 0;
         }
         set_winconf_geometry(wcp->id);
-        return x;
     }
-    return 0;
 }