+ exit_err(fclose(file), world, err_c);
+ char * path = string_prefixed_id(world, "config/windows/Win_", id);
+ if (!access(path, F_OK))
+ {
+ exit_err(unlink(path), world, err_u);
+ }
+ exit_err(rename(path_tmp, path), world, err_r);
+ free(path);
+ free(path_tmp);
+}
+
+
+
+static void set_winconf(struct World * world, char id)
+{
+ struct WinConf * wcp = get_winconf_by_id(world, id);
+ if (0 == wcp->height_type)
+ {
+ wcp->height = wcp->win->frame.size.y;
+ }
+ else if (1 == wcp->height_type)
+ {
+ wcp->height = wcp->win->frame.size.y - world->wmeta->padframe.size.y
+ + 1;
+ }
+ if (0 == wcp->width_type)
+ {
+ wcp->width = wcp->win->frame.size.x;
+ }
+ else if (1 == wcp->width_type)
+ {
+ wcp->width = wcp->win->frame.size.x - world->wmeta->padframe.size.x;
+ }
+}
+
+
+
+static struct WinConf * get_winconf_by_id(struct World * world, char id)
+{
+ uint8_t i = 0;
+ while (1)
+ {
+ if (id == world->winconfs[i].id)
+ {
+ return &world->winconfs[i];
+ }
+ i++;
+ }
+}
+
+
+
+static char get_id_by_win(struct World * world, struct Win * win)
+{
+ struct WinConf * wc = get_winconf_by_win(world, win);
+ return wc->id;
+}
+
+
+
+extern struct WinConf * get_winconf_by_win(struct World * world,
+ struct Win * win)
+{
+ uint8_t i = 0;
+ while (1)
+ {
+ if (win == world->winconfs[i].win)
+ {
+ return &world->winconfs[i];
+ }
+ i++;
+ }
+}
+
+
+
+extern struct Win * get_win_by_id(struct World * world, char id)
+{
+ struct WinConf * wc = get_winconf_by_id(world, id);
+ return wc->win;
+}
+
+
+
+extern void create_winconfs(struct World * world)
+{
+ char * err = "Trouble with malloc() in init_winconfs().";
+ struct WinConf * winconfs = malloc(4 * sizeof(struct WinConf));
+ exit_err(NULL == winconfs, world, err);
+ create_winconf('i', &winconfs[0], draw_info_win);
+ create_winconf('k', &winconfs[1], draw_keys_win);
+ create_winconf('l', &winconfs[2], draw_log_win);
+ create_winconf('m', &winconfs[3], draw_map_win);
+ world->winconfs = winconfs;
+}
+
+
+
+extern void init_winconfs(struct World * world)
+{
+ init_winconf_from_file(world, 'i');
+ init_winconf_from_file(world, 'k');
+ init_winconf_from_file(world, 'l');
+ init_winconf_from_file(world, 'm');
+}
+
+
+
+extern void free_winconf(struct World * world, char id)
+{
+ struct WinConf * wc = get_winconf_by_id(world, id);
+ free(wc->title);
+}
+
+
+
+extern void free_winconfs(struct World * world)
+{
+ free_winconf(world, 'i');
+ free_winconf(world, 'k');
+ free_winconf(world, 'l');
+ free_winconf(world, 'm');
+ free(world->winconfs);
+}
+
+
+
+extern void init_wins(struct World * world)
+{
+ init_win_from_winconf(world, 'i');
+ init_win_from_winconf(world, 'k');
+ init_win_from_winconf(world, 'l');
+ init_win_from_winconf(world, 'm');
+}
+
+
+
+extern void free_wins(struct World * world)
+{
+ free_win(get_win_by_id(world, 'i'));
+ free_win(get_win_by_id(world, 'k'));
+ free_win(get_win_by_id(world, 'l'));
+ free_win(get_win_by_id(world, 'm'));