| 40 | } |
| 41 | |
| 42 | static void |
| 43 | hooked_tty_getlin( |
| 44 | const char *query, |
| 45 | char *bufp, |
| 46 | getlin_hook_proc hook) |
| 47 | { |
| 48 | char *obufp = bufp; |
| 49 | int c; |
| 50 | struct WinDesc *cw = wins[WIN_MESSAGE]; |
| 51 | boolean doprev = FALSE; |
| 52 | |
| 53 | if (ttyDisplay->toplin == TOPLINE_NEED_MORE && !(cw->flags & WIN_STOP)) |
| 54 | more(); |
| 55 | cw->flags &= ~WIN_STOP; |
| 56 | ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT; |
| 57 | ttyDisplay->inread++; |
| 58 | |
| 59 | /* |
| 60 | * Issue the prompt. |
| 61 | * |
| 62 | * custompline() will call vpline() which calls flush_screen() which |
| 63 | * calls bot(). The core now disables bot() processing while inside |
| 64 | * getlin, so the screen won't be modified during whatever this prompt |
| 65 | * is for. |
| 66 | */ |
| 67 | custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s ", query); |
| 68 | |
| 69 | #ifdef EDIT_GETLIN |
| 70 | /* bufp is input/output; treat current contents (presumed to be from |
| 71 | previous getlin()) as default input */ |
| 72 | addtopl(obufp); |
| 73 | bufp = eos(obufp); |
| 74 | #else |
| 75 | /* !EDIT_GETLIN: bufp is output only; init it to empty */ |
| 76 | *bufp = '\0'; |
| 77 | #endif |
| 78 | |
| 79 | for (;;) { |
| 80 | (void) fflush(stdout); |
| 81 | Strcat(strcat(strcpy(gt.toplines, query), " "), obufp); |
| 82 | term_curs_set(1); |
| 83 | c = pgetchar(); |
| 84 | term_curs_set(0); |
| 85 | if (c == '\033' || c == EOF) { |
| 86 | if (c == EOF) |
| 87 | iflags.term_gone = 1; |
| 88 | if (c == '\033' && obufp[0] != '\0') { |
| 89 | obufp[0] = '\0'; |
| 90 | bufp = obufp; |
| 91 | tty_clear_nhwindow(WIN_MESSAGE); |
| 92 | cw->maxcol = cw->maxrow; |
| 93 | addtopl(query); |
| 94 | addtopl(" "); |
| 95 | addtopl(obufp); |
| 96 | } else { |
| 97 | obufp[0] = '\033'; |
| 98 | obufp[1] = '\0'; |
| 99 | break; |
no test coverage detected