+extern void save_win_config(struct World * world, char id)
+{
+ char * err_o = "Trouble in save_win_config() with fopen().";
+ char * err_m = "Trouble in save_win_config() with malloc().";
+ 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 = malloc(size);
+ exit_err(NULL == line, world, err_m);
+ 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)
+{
+ 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;
+}
+
+
+