+ exit_err(textfile_sizes(file, &linemax, NULL), world, err_s);
+ char line[linemax];
+
+ struct WinConf * winconf = get_winconf_by_id(world, id);
+ exit_err(NULL == fgets(line, linemax, file), world, err_g);
+ exit_err(NULL == (winconf->title = malloc(strlen(line))), world, err_m);
+ memcpy(winconf->title, line, strlen(line) - 1); /* Eliminate newline char */
+ winconf->title[strlen(line) - 1] = '\0'; /* char at end of string. */
+ exit_err(NULL == fgets(line, linemax, file), world, err_g);
+ winconf->height = atoi(line);
+ if (0 >= winconf->height)
+ {
+ winconf->height_type = 1;
+ }
+ exit_err(NULL == fgets(line, linemax, file), world, err_g);
+ winconf->width = atoi(line);
+ if (0 >= winconf->width)
+ {
+ winconf->width_type = 1;
+ }
+
+ exit_err(fclose(file), world, err_c);
+}
+
+
+
+static void init_win_from_winconf(struct World * world, char id)
+{
+ char * err = "Trouble in init_win_from_file() with init_win().";
+ struct WinConf * winconf = get_winconf_by_id(world, id);
+ exit_err(init_win(world->wmeta, &winconf->win, winconf->title,
+ winconf->height, winconf->width, world, winconf->draw),
+ world, err);
+}
+
+
+
+extern void save_win_config(struct World * world, char id)
+{
+ char * err_o = "Trouble in save_win_config() with fopen().";
+ char * err_c = "Trouble in save_win_config() with fclose().";
+ char * err_u = "Trouble in save_win_config() with unlink().";
+ char * err_r = "Trouble in save_win_config() with rename().";
+
+ char * path_tmp = string_prefixed_id(world, "config/windows/Win_tmp_", id);
+ FILE * file = fopen(path_tmp, "w");
+ exit_err(NULL == file, world, err_o);
+
+ 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, "%d\n", wc->height);
+ fwrite(line, sizeof(char), strlen(line), file);
+ sprintf(line, "%d\n", wc->width);
+ fwrite(line, sizeof(char), strlen(line), file);
+
+ 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)
+{