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

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

(interact): Renamed the class abstract_interact. Added methods
get_attributes and set_attributes.

* src/interact.h (window_change_callback): New class.
(abstract_interact): Replaced the window_change method with to
methods, window_size and window_change_subscribe.

* src/interact.c: Moved unix_interact class to unix_interact.c.

Rev: src/interact.c:1.4
Rev: src/interact.h:1.4
parent 9fd31429
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "interact.h.x" #include "interact.h.x"
#undef GABA_DEFINE #undef GABA_DEFINE
#if 0
int tty_fd = -1; int tty_fd = -1;
int lsh_open_tty(void) int lsh_open_tty(void)
...@@ -159,4 +160,4 @@ int yes_or_no(struct lsh_string *s, int def, int free) ...@@ -159,4 +160,4 @@ int yes_or_no(struct lsh_string *s, int def, int free)
return 0; return 0;
} }
} }
#endif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "lsh.h" #include "lsh.h"
/* Forward declaration */ /* Forward declaration */
struct abstract_interact; struct interact;
struct terminal_dimensions; struct terminal_dimensions;
#define GABA_DECLARE #define GABA_DECLARE
...@@ -47,18 +47,29 @@ struct terminal_dimensions ...@@ -47,18 +47,29 @@ struct terminal_dimensions
UINT32 pixel_height; UINT32 pixel_height;
}; };
/* GABA:
(class
(name terminal_attributes)
(vars
(make_raw method (object terminal_attributes))
(encode method (string))))
*/
#define TERM_MAKE_RAW(t) ((t)->make_raw((t)))
#define TERM_ENCODE(t) ((t)->encode((t)))
/* GABA: /* GABA:
(class (class
(name window_change_callback) (name window_change_callback)
(vars (vars
(f method void "struct abstract_interact *i"))) (f method void "struct interact *i")))
*/ */
#define WINDOW_CHANGE_CALLBACK(c, i) ((c)->f((c), (i))) #define WINDOW_CHANGE_CALLBACK(c, i) ((c)->f((c), (i)))
/* GABA: /* GABA:
(class (class
(name abstract_interact) (name interact)
(vars (vars
(is_tty method int) (is_tty method int)
; (read_line method int "UINT32 size" "UINT8 *buffer") ; (read_line method int "UINT32 size" "UINT8 *buffer")
...@@ -69,6 +80,10 @@ struct terminal_dimensions ...@@ -69,6 +80,10 @@ struct terminal_dimensions
(yes_or_no method int (yes_or_no method int
"struct lsh_string *prompt" "struct lsh_string *prompt"
"int def" "int free") "int def" "int free")
(get_attributes method (object terminal_attributes) )
(set_attributes method int "struct terminal_attributes *attr")
(window_size method int "struct terminal_dimensions *") (window_size method int "struct terminal_dimensions *")
(window_change_subscribe method (object resource) (window_change_subscribe method (object resource)
"struct window_change_callback *callback"))) "struct window_change_callback *callback")))
...@@ -80,15 +95,24 @@ struct terminal_dimensions ...@@ -80,15 +95,24 @@ struct terminal_dimensions
((i)->read_password((i), (l), (p), (f))) ((i)->read_password((i), (l), (p), (f)))
#define INTERACT_YES_OR_NO(i, p, d, f) \ #define INTERACT_YES_OR_NO(i, p, d, f) \
((i)->yes_or_no((i), (p), (d), (f))) ((i)->yes_or_no((i), (p), (d), (f)))
#define INTERACT_GET_ATTRIBUTES(i) \
((i)->get_attributes((i)))
#define INTERACT_SET_ATTRIBUTES(i, t) \
((i)->set_attributes((i), (t)))
#define INTERACT_WINDOW_SIZE(i, d) \ #define INTERACT_WINDOW_SIZE(i, d) \
((i)->window_size((i), (d))) ((i)->window_size((i), (d)))
#define INTERACT_WINDOW_SUBSCRIBE(i, c) \ #define INTERACT_WINDOW_SUBSCRIBE(i, c) \
((i)->window_change_subscribe((i), (c))) ((i)->window_change_subscribe((i), (c)))
#if 0
extern int tty_fd; extern int tty_fd;
int lsh_open_tty(void); int lsh_open_tty(void);
int tty_read_line(UINT32 size, UINT8 *buffer); int tty_read_line(UINT32 size, UINT8 *buffer);
int yes_or_no(struct lsh_string *s, int def, int free); int yes_or_no(struct lsh_string *s, int def, int free);
#endif
struct interact *
make_unix_interact(struct io_backend *backend);
#endif /* LSH_INTERACT_H_INCLUDED */ #endif /* LSH_INTERACT_H_INCLUDED */
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