Commit a942ed06 authored by Niels Möller's avatar Niels Möller
Browse files

* src/interact.h (interact_dialog): New class.

(INTERACT_DIALOG): New method.

* src/interact.c (make_interact_dialog): New function.

Rev: src/interact.c:1.8
Rev: src/interact.h:1.13
parent 2d0191c6
......@@ -45,3 +45,20 @@
#include "interact.h.x"
struct interact_dialog *
make_interact_dialog(unsigned nprompt)
NEW(interact_dialog, self);
unsigned i;
self->nprompt = nprompt;
self->prompt = lsh_space_alloc(nprompt * sizeof(struct lsh_string *));
self->response = lsh_space_alloc(nprompt * sizeof(struct lsh_string *));
self->echo = lsh_space_alloc(nprompt * sizeof(int));
for (i = 0; i < nprompt; i++)
self->prompt[i] = self->response[i] = NULL;
return self;
......@@ -59,6 +59,19 @@ struct terminal_dimensions;
#define WINDOW_CHANGE_CALLBACK(c, i) ((c)->f((c), (i)))
/* GABA:
(name interact_dialog)
(nprompt . unsigned)
(prompt space (string) nprompt)
(response space (string) nprompt)
(echo space int nprompt)))
struct interact_dialog *
make_interact_dialog(unsigned nprompt);
/* GABA:
(name interact)
......@@ -67,11 +80,15 @@ struct terminal_dimensions;
; Consumes the prompt
(read_password method (string)
"uint32_t max_length"
"const struct lsh_string *prompt")
"const struct lsh_string *prompt")
(set_askpass method void "const char *askpass")
(yes_or_no method int
"const struct lsh_string *prompt"
"int def" "int free")
; Consumes instruction
(dialog method int
"const struct lsh_string *instruction"
"const struct interact_dialog *dialog")
(get_attributes method (object terminal_attributes) )
(set_attributes method int "struct terminal_attributes *attr")
......@@ -89,6 +106,8 @@ struct terminal_dimensions;
((i)->set_askpass((i), (a)))
#define INTERACT_YES_OR_NO(i, p, d, f) \
((i)->yes_or_no((i), (p), (d), (f)))
#define INTERACT_DIALOG(i, s, d) \
((i)->dialog((i), (s), (d)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment