| 185 | /* Return a winid for a new window of the given type */ |
| 186 | |
| 187 | winid |
| 188 | curses_get_wid(int type) |
| 189 | { |
| 190 | static winid menu_wid = 20; /* Always even */ |
| 191 | static winid text_wid = 21; /* Always odd */ |
| 192 | winid ret; |
| 193 | |
| 194 | switch (type) { |
| 195 | case NHW_MESSAGE: |
| 196 | return MESSAGE_WIN; |
| 197 | case NHW_MAP: |
| 198 | return MAP_WIN; |
| 199 | case NHW_STATUS: |
| 200 | return STATUS_WIN; |
| 201 | case NHW_MENU: |
| 202 | ret = menu_wid; |
| 203 | break; |
| 204 | case NHW_TEXT: |
| 205 | ret = text_wid; |
| 206 | break; |
| 207 | default: |
| 208 | impossible("curses_get_wid: unsupported window type"); |
| 209 | ret = -1; |
| 210 | } |
| 211 | |
| 212 | while (curses_window_exists(ret)) { |
| 213 | ret += 2; |
| 214 | if ((ret + 2) > 10000) { /* Avoid "wid2k" problem */ |
| 215 | ret -= 9900; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | if (type == NHW_MENU) { |
| 220 | menu_wid += 2; |
| 221 | } else { |
| 222 | text_wid += 2; |
| 223 | } |
| 224 | |
| 225 | return ret; |
| 226 | } |
| 227 | |
| 228 | |
| 229 | /* |
no test coverage detected