+static void draw_map_objects(struct World * world, struct MapObj * start,
+ struct Map * map, struct Win * win)
+{
+ struct MapObj * o;
+ struct MapObjDef * d;
+ char c;
+ uint8_t i;
+ for (i = 0; i < 2; i++)
+ {
+ for (o = start; o != 0; o = o->next)
+ {
+ if ( ( (0 == i && 0 == o->lifepoints) /* Draw in-animate */
+ || (1 == i && 0 < o->lifepoints)) /* objects first. */
+ && o->pos.y >= map->offset.y
+ && o->pos.y < map->offset.y + win->frame.size.y
+ && o->pos.x >= map->offset.x
+ && o->pos.x < map->offset.x + win->frame.size.x)
+ {
+ d = get_map_object_def(world, o->type);
+ c = d->char_on_map;
+ mvwaddch(win->frame.curses_win,
+ o->pos.y - map->offset.y, o->pos.x - map->offset.x, c);
+ }
+ }
+ }
+}
+
+
+
+static char * get_kb_line_and_iterate(struct World * world,
+ struct KeyBinding ** kb_pp)
+{
+ char * f_name = "get_kb_line_and_iterate()";
+ struct KeyBinding * kb_p = * kb_pp;
+ char * keyname = get_name_to_keycode(world, kb_p->key);
+ char * cmd_dsc = get_command_longdsc(world, kb_p->name);
+ uint16_t size = 9 + 1 + strlen(cmd_dsc) + 1;
+ char * line = try_malloc(size, world, f_name);
+ sprintf(line, "%-9s %s", keyname, cmd_dsc);
+ free(keyname);
+ * kb_pp = kb_p->next;
+ return line;
+}
+
+
+
+static uint8_t scroll_hint_helper(struct World * world, uint16_t start,
+ uint16_t y, uint16_t offset, uint16_t n_owned,
+ struct Frame * frame, char * f_name)
+{
+ uint8_t ret = 0;
+ char * err_hint = trouble_msg(world, f_name, "draw_scroll_hint()");
+ if (start == y && offset > 0)
+ {
+ uint8_t test = draw_scroll_hint(frame, y, offset + 1, '^');
+ exit_err(test, world, err_hint);
+ ret = 1;
+ }
+ else if ( frame->size.y == y + 1
+ && n_owned > frame->size.y + offset - 1 - start)
+ {
+ uint8_t pos = n_owned - (offset + frame->size.y) + 2 + start;
+ uint8_t test = draw_scroll_hint(frame, y, pos, 'v');
+ exit_err(test, world, err_hint);
+ ret = 1;
+ }
+ free(err_hint);
+ return ret;
+}
+
+
+
+static void draw_kb_view(struct World * world, struct Win * win,
+ char * f_name, struct KeyBiData * kb, uint8_t start)
+{
+ if (0 == kb->kbs)
+ {
+ draw_line(win, start, "(none)", 0, 0);
+ return;
+ }
+ uint16_t kb_max = get_n_of_keybs(kb->kbs) - 1;
+ uint16_t offset;
+ offset = center_offset(kb->select, kb_max, win->frame.size.y - 1 - start);
+ struct KeyBinding * kb_p = get_keyb_of_n(kb->kbs, offset + (offset > 0));
+ uint16_t y;
+ for (y = start; 0 != kb_p && y < win->frame.size.y; y++)
+ {
+ if (scroll_hint_helper(world, start, y, offset, kb_max, &win->frame,
+ f_name))
+ {
+ continue;
+ }
+ attr_t attri = 0;
+ if (y - start == kb->select - offset)
+ {
+ attri = A_REVERSE;
+ if (1 == kb->edit)
+ {
+ attri = attri | A_BLINK;
+ }
+ }
+ char * kb_line = get_kb_line_and_iterate(world, &kb_p);
+ draw_line(win, y, kb_line, attri, 1);
+
+ free(kb_line);
+ }
+}
+
+
+
+static uint16_t draw_titled_keybinding_list(struct World * world,
+ struct Win * win, uint16_t start,
+ char * title,
+ struct KeyBinding * kb_p)
+{
+ uint16_t x, y;
+ uint16_t i = 0;
+ uint8_t state = 0;
+ for (y = start; y < win->frame.size.y && (0 == state || 0 != kb_p); y++)
+ {
+ if (0 == state)
+ {
+ for (x = 0; x < win->frame.size.x; x++)
+ {
+ if (i == strlen(title))
+ {
+ y++;
+ state = 1 + (0 == kb_p);
+ i = 0;
+ break;
+ }
+ mvwaddch(win->frame.curses_win, y, x, title[i]);
+ i++;
+ }
+ continue;
+ }
+ char * kb_line = get_kb_line_and_iterate(world, &kb_p);
+ draw_line(win, y, kb_line, 0, 0);
+ free(kb_line);
+ }
+ if (2 == state)
+ {
+ draw_line(win, y, "(none)", 0, 0);
+ y++;
+ }
+ return y;
+}
+
+
+
+extern void draw_win_log(struct Win * win)