MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | // MorgenGrauen MUDlib |
| 2 | // |
| 3 | // util/input.c -- generic input handling |
| 4 | // |
| 5 | // $Id: input.c 8349 2013-02-04 21:15:28Z Zesstra $ |
| 6 | |
| 7 | #include <input_to.h> |
| 8 | |
| 9 | #pragma strong_types |
| 10 | #pragma save_types |
| 11 | #pragma pedantic |
| 12 | #pragma range_check |
| 13 | #pragma no_clone |
| 14 | |
| 15 | varargs void input(mixed prompt, mixed pargs, mixed ctrl, mixed ctrlargs) |
| 16 | { |
| 17 | mixed prompttext; |
| 18 | if(closurep(prompt)) |
| 19 | prompttext = apply(prompt, pointerp(pargs) ? pargs : ({})); |
| 20 | else prompttext = prompt; |
| 21 | if (!stringp(prompttext)) prompttext=""; |
| 22 | input_to("done", INPUT_PROMPT, prompttext, prompt, pargs, ctrl, ctrlargs); |
| 23 | } |
| 24 | |
| 25 | void done(string in, mixed prompt, mixed pargs, mixed ctrl, mixed ctrlargs) |
| 26 | { |
| 27 | if(closurep(ctrl) && |
| 28 | apply(ctrl, ({ in }) + (pointerp(ctrlargs) ? ctrlargs : ({})))) |
| 29 | return; |
| 30 | input(prompt, pargs, ctrl, ctrlargs); |
| 31 | } |