(query, resp, def)
| 3149 | } |
| 3150 | |
| 3151 | char |
| 3152 | Gem_yn_function(query, resp, def) |
| 3153 | const char *query, *resp; |
| 3154 | char def; |
| 3155 | { |
| 3156 | OBJECT *z_ob = zz_oblist[YNCHOICE]; |
| 3157 | int d_exit, i, len; |
| 3158 | long anzahl; |
| 3159 | char *tmp; |
| 3160 | const char *ptr; |
| 3161 | |
| 3162 | if (WIN_MESSAGE != WIN_ERR && Gem_nhwindow[WIN_MESSAGE].gw_window) |
| 3163 | mar_display_nhwindow(WIN_MESSAGE); |
| 3164 | |
| 3165 | /* if query for direction the special dialog */ |
| 3166 | if (strstr(query, "irect")) |
| 3167 | return (mar_ask_direction()); |
| 3168 | |
| 3169 | len = min(strlen(query), (max_w - 8 * gr_cw) / gr_cw); |
| 3170 | z_ob[ROOT].ob_width = (len + 8) * gr_cw; |
| 3171 | z_ob[YNPROMPT].ob_width = gr_cw * len + 8; |
| 3172 | tmp = ob_get_text(z_ob, YNPROMPT, 0); |
| 3173 | ob_set_text(z_ob, YNPROMPT, mar_copy_of(query)); |
| 3174 | |
| 3175 | if (resp) { /* single inputs */ |
| 3176 | ob_hide(z_ob, SOMECHARS, FALSE); |
| 3177 | ob_hide(z_ob, ANYCHAR, TRUE); |
| 3178 | |
| 3179 | if (strchr(resp, 'q')) |
| 3180 | send_yn_esc('q'); |
| 3181 | else if (strchr(resp, 'n')) |
| 3182 | send_yn_esc('n'); |
| 3183 | else |
| 3184 | send_yn_esc( |
| 3185 | def); /* strictly def should be returned, but in trad. I it's |
| 3186 | 0 */ |
| 3187 | |
| 3188 | if (strchr(resp, '#')) { /* count possible */ |
| 3189 | ob_hide(z_ob, YNOK, FALSE); |
| 3190 | ob_hide(z_ob, COUNT, FALSE); |
| 3191 | } else { /* no count */ |
| 3192 | ob_hide(z_ob, YNOK, TRUE); |
| 3193 | ob_hide(z_ob, COUNT, TRUE); |
| 3194 | } |
| 3195 | |
| 3196 | if ((anzahl = (long) strchr(resp, '\033'))) { |
| 3197 | anzahl -= (long) resp; |
| 3198 | } else { |
| 3199 | anzahl = strlen(resp); |
| 3200 | } |
| 3201 | for (i = 0, ptr = resp; i < 2 * anzahl; i += 2, ptr++) { |
| 3202 | ob_hide(z_ob, YN1 + i, FALSE); |
| 3203 | mar_change_button_char(z_ob, YN1 + i, *ptr); |
| 3204 | ob_undoflag(z_ob, YN1 + i, DEFAULT); |
| 3205 | if (*ptr == def) |
| 3206 | ob_doflag(z_ob, YN1 + i, DEFAULT); |
| 3207 | } |
| 3208 |
nothing calls this directly
no test coverage detected