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.
- int keydescwidth = 9; // max length assured by get_keyname()
- char * keydesc = malloc(keydescwidth + 1);
+ int keydescwidth = 9 + 1; // max length assured by get_keyname() + \0
+ char * keydesc = malloc(keydescwidth);
if (1 == keyswindata->edit)
attri = attri | A_BLINK; }
keyname = get_keyname(keybindings[y + offset].key);
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, ' '); }