+static void init_win_from_winconf(struct World * world, char id)
+{
+ char * tmp = "Trouble in init_win_from_file() with init_win() (win id: _).";
+ char * err = try_malloc(strlen(tmp) + 1, world, "init_win_from_file()");
+ memcpy(err, tmp, strlen(tmp) + 1);
+ err[strlen(tmp) - 3] = id;
+ struct WinConf * winconf = get_winconf_by_id(world, id);
+ void * f = get_drawfunc_by_char(winconf->draw);
+ exit_err(NULL == f, world, err);
+ exit_err(init_win(world->wmeta, &winconf->win, winconf->title,
+ winconf->height, winconf->width, world, f),
+ world, err);
+ free(err);
+}
+
+
+
+extern void save_win_config(struct World * world, char id)
+{
+ char * f_name = "save_win_config()";
+
+ char * path_tmp = string_prefixed_id(world, "config/windows/Win_tmp_", id);
+ FILE * file = try_fopen(path_tmp, "w", world, f_name);
+
+ struct WinConf * wc = get_winconf_by_id(world, id);
+ uint8_t size = strlen(wc->title) + 2;
+ if (size < 7)
+ {
+ size = 7;
+ }
+ char line[size];
+ sprintf(line, "%s\n", wc->title);
+ fwrite(line, sizeof(char), strlen(line), file);
+ sprintf(line, "%c\n", wc->draw);
+ fwrite(line, sizeof(char), strlen(line), file);
+ sprintf(line, "%d\n", wc->height);
+ fwrite(line, sizeof(char), strlen(line), file);
+ sprintf(line, "%d\n", wc->width);
+ fwrite(line, sizeof(char), strlen(line), file);
+
+ char * path = string_prefixed_id(world, "config/windows/Win_", id);
+ try_fclose_unlink_rename(file, path_tmp, path, world, f_name);
+ 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)