x11_flip(x);
}
-static void filter(void) {
- XConf x = {0};
- x11_init(&x);
- x11_mkdialog(&x, 640, 480, 0
+static void xinit(XConf* x) {
+ x11_init(x);
+ x11_mkdialog(x, 640, 480, 0
| StructureNotifyMask
| KeyPressMask
| ButtonPressMask
| ExposureMask
);
- x11_init_gc(&x);
- x11_centerwin(&x);
- if (!(x.font = x11_font_load(&x, Fonts[0]))) {
+ x11_init_gc(x);
+ x11_centerwin(x);
+ if (!(x->font = x11_font_load(x, Fonts[0]))) {
perror("unable to load base font");
exit(EXIT_FAILURE);
}
- x11_show(&x);
- x.eventfns[KeyPress] = xkeypress;
- x.eventfns[ButtonPress] = xbtnpress;
- x11_event_loop(&x, redraw);
+ x11_show(x);
+ x->eventfns[KeyPress] = xkeypress;
+ x->eventfns[ButtonPress] = xbtnpress;
+ redraw(x);
}
int main(int argc, char** argv) {
+ XConf x = {0};
if (argc >= 2) {
size_t sz = min(strlen(argv[1]), sizeof(Query)-1);
strncpy(Query, argv[1], sz);
QueryIdx = sz;
}
+ xinit(&x);
load_choices();
score();
if (vec_size(&Choices) > 1)
- filter();
+ x11_event_loop(&x, redraw);
Choice* choice = (Choice*)vec_at(&Choices, ChoiceIdx);
if (vec_size(&Choices) && ChoiceIdx != SIZE_MAX)
printf("%s\n", choice->string);