display the inventory menu-like data collected in pi.array[] */
| 330 | |
| 331 | /* display the inventory menu-like data collected in pi.array[] */ |
| 332 | static void |
| 333 | curs_show_invt(WINDOW *win) |
| 334 | { |
| 335 | const char *str; |
| 336 | char accelerator, tmpbuf[BUFSZ]; |
| 337 | int attr, color; |
| 338 | unsigned lineno, stroffset, widest, left_col, right_col, |
| 339 | first_shown = 0, last_shown = 0, item_count = 0, xtra_line = 0; |
| 340 | int x, y, width, height, available_width, |
| 341 | border = curses_window_has_border(INV_WIN) ? 1 : 0, |
| 342 | /* we actually care about the topmost of message, map, or status |
| 343 | but either they all have borders or none do so just check map */ |
| 344 | otherborder = curses_window_has_border(MAP_WIN) ? 1 : 0; |
| 345 | |
| 346 | x = border; /* same for every line; 1 if border, 0 otherwise */ |
| 347 | |
| 348 | curses_get_window_size(INV_WIN, &height, &width); |
| 349 | widest = pi.widest; |
| 350 | left_col = pi.coloffset + 1; |
| 351 | right_col = left_col + (unsigned) width - 1; |
| 352 | |
| 353 | /* |
| 354 | * If there will be any blank lines left at the bottom, sometimes |
| 355 | * insert one blank line at the top. If the first line is an item |
| 356 | * (via !sortpack) which will be obscured by the column indicator, |
| 357 | * or there is only one line (such as "not carrying anything") if |
| 358 | * that line would be at the very top aligned with the top border |
| 359 | * of another window (windowborders=3,4) because that looks odd. |
| 360 | * This only handles the single page case [because scrolling always |
| 361 | * fills pages beyond the first rather than just continuing from |
| 362 | * last line of preceding page, hence no blank line(s) at bottom]. |
| 363 | */ |
| 364 | if ((pi.array[0].letter && pi.inuseindx < (unsigned) height |
| 365 | && widest > (unsigned) width) |
| 366 | || (pi.inuseindx == 1 && otherborder && !border)) { |
| 367 | wmove(win, 1, x); |
| 368 | wprintw(win, "%.*s", width - 2 * border, ""); |
| 369 | xtra_line = 1; |
| 370 | } |
| 371 | |
| 372 | for (lineno = 0; lineno < pi.rowoffset; ++lineno) |
| 373 | if (pi.array[lineno].letter) |
| 374 | ++item_count; |
| 375 | |
| 376 | for (lineno = pi.rowoffset; lineno < pi.inuseindx; ++lineno) { |
| 377 | str = pi.array[lineno].invtxt; |
| 378 | accelerator = pi.array[lineno].letter; |
| 379 | attr = pi.array[lineno].c_attr; /* already converted when stored */ |
| 380 | color = pi.array[lineno].color; |
| 381 | if (color == NO_COLOR) |
| 382 | color = NONE; |
| 383 | |
| 384 | if (accelerator) |
| 385 | ++item_count; |
| 386 | |
| 387 | /* Figure out where to draw the line */ |
| 388 | y = (int) (lineno + xtra_line - pi.rowoffset) + border; |
| 389 | if (y - border >= height) { /* height already -2 for Top+Btm border */ |
no test coverage detected