10 /* Whether we actually need to draw this frame or not */
11 static uint_fast8_t need_to_draw
= 1;
16 /* The event we'll give back */
17 static struct ui_event pass_back
= { 0 };
20 int ui_init(struct quiver
*i_q
)
27 /* Deal with the fact that the quiver was changed */
28 int ui_respond_quiver_change(void)
39 /* Record that a frame has been started */
40 int ui_start_frame(void)
45 /* Draw a frame, sleep to framelimit */
46 int ui_finish_frame(void)
50 struct rational
*e
= 0;
51 size_t line_length
= 0;
57 printf("%*s| Name\n----------\n", 4, "i");
59 for (j
= 0; j
< q
->v_num
; ++j
) {
60 printf("%*llu | %s\n", 4, (long long unsigned) j
, q
->v
[j
].name
);
63 line_length
= printf("%*s| ", 4, "i\\j");
65 for (j
= 0; j
< q
->v_num
; ++j
) {
66 line_length
+= printf("%*llu", 5, (long long unsigned) j
);
71 for (j
= 0; j
< line_length
; ++j
) {
75 for (i
= 0; i
< q
->v_num
; ++i
) {
76 printf("\n %*llu| ", 3, (long long unsigned) i
);
78 for (j
= 0; j
< q
->v_num
; ++j
) {
79 e
= &(q
->e
[i
* q
->v_len
+ j
]);
83 } else if (e
->q
== 1) {
84 printf("%*lld", 5, (long long int) e
->p
);
86 printf("%*lld/%llu", 3, (long long int) e
->p
,
87 (long long unsigned) e
->q
);
99 int ui_confirm_deny(const char *s
)
103 printf("%s [y/n]\n", s
);
105 while ((c
= fgetc(stdin
))) {
107 pass_back
= (struct ui_event
) { .type
= ET_FORCE_QUIT
};
113 pass_back
= (struct ui_event
) { .type
= ET_CONFIRM
};
115 } else if (c
== 'n' ||
117 pass_back
= (struct ui_event
) { .type
= ET_DENY
};
125 int ui_get_event(struct ui_event
*e
, uint_fast8_t *more
)
129 pass_back
= (struct ui_event
) { 0 };