scroll persistent inventory window forwards or backwards or side-to-side */
| 133 | |
| 134 | /* scroll persistent inventory window forwards or backwards or side-to-side */ |
| 135 | static int |
| 136 | curs_scroll_invt(WINDOW *win UNUSED) |
| 137 | { |
| 138 | char menukeys[QBUFSZ], qbuf[QBUFSZ]; |
| 139 | unsigned uheight, uwidth, uhalfwidth, scrlmask; |
| 140 | int ch, menucmd, height, width; |
| 141 | int res = 0; |
| 142 | |
| 143 | curses_get_window_size(INV_WIN, &height, &width); |
| 144 | uheight = (unsigned) height; |
| 145 | uwidth = (unsigned) width; |
| 146 | uhalfwidth = uwidth / 2; |
| 147 | |
| 148 | menukeys[0] = '\0'; |
| 149 | scrlmask = 0U; |
| 150 | if (pi.rowoffset > 0) |
| 151 | scrlmask |= 1U; /* include scroll backwards: ^ and < */ |
| 152 | if (pi.rowoffset + uheight <= pi.inuseindx) |
| 153 | scrlmask |= 2U; /* include scroll forwards: > and | */ |
| 154 | if (pi.coloffset > 0) |
| 155 | scrlmask |= 4U; /* include scroll left: { */ |
| 156 | if (pi.widest > pi.coloffset + uwidth) |
| 157 | scrlmask |= 8U; /* include scroll right: } */ |
| 158 | (void) collect_menu_keys(menukeys, scrlmask, TRUE); |
| 159 | |
| 160 | Snprintf(qbuf, sizeof qbuf, "Inventory scroll: [%s%s%s] ", |
| 161 | menukeys, *menukeys ? " " : "", "Ret Esc"); |
| 162 | |
| 163 | curses_count_window(qbuf); |
| 164 | ch = getch(); |
| 165 | curses_count_window((char *) 0); |
| 166 | curses_clear_unhighlight_message_window(); |
| 167 | |
| 168 | menucmd = (ch <= 0 || ch >= 255) ? ch : (int) (uchar) map_menu_cmd(ch); |
| 169 | switch (menucmd) { |
| 170 | case KEY_ESC: |
| 171 | case C('c'): /* ^C */ |
| 172 | /* for <escape>, leave window with scrolling as-is */ |
| 173 | res = -1; |
| 174 | break; |
| 175 | case '\n': |
| 176 | case '\r': |
| 177 | case '\b': |
| 178 | case '\177': |
| 179 | /* for <return>, or <space> when already on last page, |
| 180 | restore window to unscrolled */ |
| 181 | pi.rowoffset = pi.coloffset = 0; |
| 182 | res = 1; |
| 183 | break; |
| 184 | case ' ': |
| 185 | if (pi.rowoffset + uheight <= pi.inuseindx) { |
| 186 | pi.rowoffset = pi.coloffset = 0; |
| 187 | res = 1; |
| 188 | break; |
| 189 | } |
| 190 | FALLTHROUGH; |
| 191 | /*FALLTHRU*/ |
| 192 | case KEY_RIGHT: |
no test coverage detected