void draw_text_from_bottom (struct Win * win) {
// Draw text in win->data from end/bottom to the top.
void draw_text_from_bottom (struct Win * win) {
// Draw text in win->data from end/bottom to the top.
- for (y = 0; y < start_y; y++)
- for (x = 0; x < win->width; x++)
- mvwaddch(win->curses_win, y, x, ' '); }
else if (y > win->height) {
offset = y - win->height;
for (y = 0; y < offset; y++)
else if (y > win->height) {
offset = y - win->height;
for (y = 0; y < offset; y++)
mvwaddch(win->curses_win, y, x, '@');
else
mvwaddch(win->curses_win, y, x, cells[z]);
mvwaddch(win->curses_win, y, x, '@');
else
mvwaddch(win->curses_win, y, x, cells[z]);
void draw_info (struct Win * win) {
// Draw info window by appending win->data integer value to "Turn: " display.
void draw_info (struct Win * win) {
// Draw info window by appending win->data integer value to "Turn: " display.
if (keyswindata->select < (keyswindata->max - (win->height / 2)))
offset = keyswindata->select - (win->height / 2);
else
if (keyswindata->select < (keyswindata->max - (win->height / 2)))
offset = keyswindata->select - (win->height / 2);
else
- offset = keyswindata->max - win->height + 1; }
- int keydescwidth = 9; // max length assured by get_keyname()
- char * keydesc = malloc(keydescwidth + 1);
+ offset = keyswindata->max - win->height + 1; } }
+ int keydescwidth = 9 + 1; // max length assured by get_keyname() + \0
+ char * keydesc = malloc(keydescwidth);
attri = 0;
if (y == keyswindata->select - offset) {
attri = A_REVERSE;
if (1 == keyswindata->edit)
attri = attri | A_BLINK; }
keyname = get_keyname(keybindings[y + offset].key);
attri = 0;
if (y == keyswindata->select - offset) {
attri = A_REVERSE;
if (1 == keyswindata->edit)
attri = attri | A_BLINK; }
keyname = get_keyname(keybindings[y + offset].key);
- snprintf(keydesc, keydescwidth + 1, "%-9s", keyname);
+ snprintf(keydesc, keydescwidth, "%-9s", keyname);
mvwaddch(win->curses_win, y, x, keydesc[x] | attri);
else if (strlen(keydesc) < x && x < strlen(keybindings[y + offset].name) + strlen(keydesc) + 1)
mvwaddch(win->curses_win, y, x, keybindings[y + offset].name[x - strlen(keydesc) - 1] | attri);
else
mvwaddch(win->curses_win, y, x, ' ' | attri); }
mvwaddch(win->curses_win, y, x, keydesc[x] | attri);
else if (strlen(keydesc) < x && x < strlen(keybindings[y + offset].name) + strlen(keydesc) + 1)
mvwaddch(win->curses_win, y, x, keybindings[y + offset].name[x - strlen(keydesc) - 1] | attri);
else
mvwaddch(win->curses_win, y, x, ' ' | attri); }
- free(keydesc);
- if (y < win->height)
- for (; y < win->height; y++)
- for (x = 0; x < win->width; x++)
- mvwaddch(win->curses_win, y, x, ' '); }
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
fseek(file, 0, SEEK_SET);
char * command = malloc(linemax);
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
fseek(file, 0, SEEK_SET);
char * command = malloc(linemax);
memcpy(keybindings[keycount].name, command, commcount);
keybindings[keycount].key = key;
keycount++;
memcpy(keybindings[keycount].name, command, commcount);
keybindings[keycount].key = key;
keycount++;
struct WinMeta win_meta = init_win_meta(screen);
struct Win win_keys = init_window(&win_meta, "Keys");
struct WinMeta win_meta = init_win_meta(screen);
struct Win win_keys = init_window(&win_meta, "Keys");
else if (key == get_action_key(world.keybindings, "toggle keys window"))
toggle_window(&win_meta, &win_keys);
else if (key == get_action_key(world.keybindings, "toggle map window"))
else if (key == get_action_key(world.keybindings, "toggle keys window"))
toggle_window(&win_meta, &win_keys);
else if (key == get_action_key(world.keybindings, "toggle map window"))
shift_window(&win_meta, 'f');
else if (key == get_action_key(world.keybindings, "shift backwards") && win_meta.active != 0)
shift_window(&win_meta, 'b');
shift_window(&win_meta, 'f');
else if (key == get_action_key(world.keybindings, "shift backwards") && win_meta.active != 0)
shift_window(&win_meta, 'b');
resize_window(&win_meta, '-');
else if (key == get_action_key(world.keybindings, "save keys"))
save_keybindings(&world);
resize_window(&win_meta, '-');
else if (key == get_action_key(world.keybindings, "save keys"))
save_keybindings(&world);