| 321 | } |
| 322 | |
| 323 | int wgetch(WINDOW *win) |
| 324 | { |
| 325 | int key, waitcount; |
| 326 | |
| 327 | PDC_LOG(("wgetch() - called\n")); |
| 328 | |
| 329 | if (!win || !SP) |
| 330 | return ERR; |
| 331 | |
| 332 | waitcount = 0; |
| 333 | |
| 334 | /* set the number of 1/20th second napms() calls */ |
| 335 | |
| 336 | if (SP->delaytenths) |
| 337 | waitcount = 2 * SP->delaytenths; |
| 338 | else |
| 339 | if (win->_delayms) |
| 340 | { |
| 341 | /* Can't really do millisecond intervals, so delay in |
| 342 | 1/20ths of a second (50ms) */ |
| 343 | |
| 344 | waitcount = win->_delayms / 50; |
| 345 | if (!waitcount) |
| 346 | waitcount = 1; |
| 347 | } |
| 348 | |
| 349 | /* refresh window when wgetch is called if there have been changes |
| 350 | to it and it is not a pad */ |
| 351 | |
| 352 | if (!(win->_flags & _PAD) && ((!win->_leaveit && |
| 353 | (win->_begx + win->_curx != SP->curscol || |
| 354 | win->_begy + win->_cury != SP->cursrow)) || is_wintouched(win))) |
| 355 | wrefresh(win); |
| 356 | |
| 357 | /* if ungotten char exists, remove and return it */ |
| 358 | |
| 359 | if (SP->c_ungind) |
| 360 | return SP->c_ungch[--(SP->c_ungind)]; |
| 361 | |
| 362 | /* if normal and data in buffer */ |
| 363 | |
| 364 | if ((!SP->raw_inp && !SP->cbreak) && (SP->c_gindex < SP->c_pindex)) |
| 365 | return SP->c_buffer[SP->c_gindex++]; |
| 366 | |
| 367 | /* prepare to buffer data */ |
| 368 | |
| 369 | SP->c_pindex = 0; |
| 370 | SP->c_gindex = 0; |
| 371 | |
| 372 | /* to get here, no keys are buffered. go and get one. */ |
| 373 | |
| 374 | for (;;) /* loop for any buffering */ |
| 375 | { |
| 376 | /* is there a keystroke ready? */ |
| 377 | |
| 378 | if (!PDC_check_key()) |
| 379 | { |
| 380 | /* if not, handle timeout() and halfdelay() */ |
no test coverage detected
searching dependent graphs…