[qwaq] Make stdscr available to progs

This commit is contained in:
Bill Currie 2020-02-29 14:38:54 +09:00
parent 5e4677f8d5
commit f5f50ae231
2 changed files with 9 additions and 0 deletions

View file

@ -2,6 +2,8 @@
typedef struct window_s *window_t;
window_t stdscr = (window_t) 1;
void initialize (void) = #0;
window_t create_window (int xpos, int ypos, int xlen, int ylen) = #0;
void destroy_window (window_t win) = #0;

View file

@ -142,6 +142,7 @@ typedef struct panel_s {
typedef struct qwaq_resources_s {
progs_t *pr;
int initialized;
window_t stdscr;
PR_RESMAP (window_t) window_map;
PR_RESMAP (panel_t) panel_map;
RING_BUFFER (qwaq_event_t, QUEUE_SIZE) event_queue;
@ -184,6 +185,10 @@ window_index (qwaq_resources_t *res, window_t *win)
static always_inline window_t * __attribute__((pure))
get_window (qwaq_resources_t *res, const char *name, int handle)
{
if (handle == 1) {
return &res->stdscr;
}
window_t *window = window_get (res, handle);
if (!window || !window->win) {
@ -681,6 +686,8 @@ bi_initialize (progs_t *pr)
mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
write(1, MOUSE_MOVES, sizeof (MOUSE_MOVES) - 1);
refresh();
res->stdscr.win = stdscr;
}
static void