+void growshrink_active_window (struct WinMeta * win_meta, char change) {
+// Grow or shrink active window horizontally or vertically by one cell size.
+ if (0 != win_meta->active) {
+ int height = win_meta->active->height;
+ int width = win_meta->active->width;
+ if (change == '-')
+ height--;
+ else if (change == '+')
+ height++;
+ else if (change == '_')
+ width--;
+ else if (change == '*')
+ width++;
+ resize_active_window (win_meta, height, width); } }
+
+void init_keybindings(struct World * world) {
+// Initialize keybindings from file "keybindings".
+ FILE * file = fopen("keybindings", "r");
+ int lines = 0;
+ int c = 0;
+ int linemax = 0;
+ int c_count = 0;
+ while (EOF != c) {
+ c_count++;
+ c = getc(file);
+ if ('\n' == c) {
+ if (c_count > linemax)
+ linemax = c_count + 1;
+ c_count = 0;
+ lines++; } }
+ struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
+ fseek(file, 0, SEEK_SET);
+ char * command = malloc(linemax);
+ int commcount = 0;
+ char * cmdptr;
+ while (fgets(command, linemax, file)) {
+ keybindings[commcount].key = atoi(command);
+ cmdptr = strchr(command, ' ') + 1;
+ keybindings[commcount].name = malloc(strlen(cmdptr));
+ memcpy(keybindings[commcount].name, cmdptr, strlen(cmdptr) - 1);
+ keybindings[commcount].name[strlen(cmdptr) - 1] = '\0';
+ commcount++; }
+ free(command);
+ fclose(file);
+ struct KeysWinData * keyswindata = malloc(sizeof(struct KeysWinData));
+ keyswindata->max = lines - 1;
+ keyswindata->select = 0;
+ keyswindata->edit = 0;
+ world->keybindings = keybindings;
+ world->keyswindata = keyswindata; }
+