MCPcopy Create free account
hub / github.com/NetHack/NetHack / curses_get_wid

Function curses_get_wid

win/curses/cursmisc.c:187–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185/* Return a winid for a new window of the given type */
186
187winid
188curses_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/*

Callers 4

curses_character_dialogFunction · 0.85
curses_prev_mesgFunction · 0.85
curses_create_nhwindowFunction · 0.85
curses_view_fileFunction · 0.85

Calls 2

curses_window_existsFunction · 0.85
impossibleFunction · 0.50

Tested by

no test coverage detected