From 2112b1ca2e821e08bbfe6c197856860b6d49b69f Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Fri, 14 Sep 2018 21:32:52 +0200 Subject: System message queue The screen and user interaction is managed by the main thread. Other parts of calcurse (threads) wishing to use the screen or communicate with the user, must do it via the main thread. For this purpose the main input loop is extended with a message queue. A thread may insert a message in the queue. The main thread tests for messages before listening for user commands. If a message is present, it is displayed (in a popup window) for the user to acknowledge. Depending on the message other actions may be performed, e.g. the message could be turned into a "system appointment/event" and inserted among the usual appointments. Signed-off-by: Lukas Fleischer --- src/calcurse.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/calcurse.c') diff --git a/src/calcurse.c b/src/calcurse.c index 0f6b69a..1b46577 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -619,6 +619,9 @@ int main(int argc, char **argv) io_set_lock(); } + /* System message queue. */ + que_init(); + /* Begin of interactive mode with ncurses interface. */ sigs_init(); /* signal handling init */ initscr(); /* start the curses mode */ @@ -702,6 +705,14 @@ int main(int argc, char **argv) for (;;) { int key; + while (que_ued()) { + que_show(); + que_save(); + do_storage(0); + wins_update(FLAG_ALL); + que_rem(); + } + if (resize) { resize = 0; wins_reset(); @@ -712,7 +723,10 @@ int main(int argc, char **argv) key_generic_reload(); } + /* Check input loop once every minute. */ + wtimeout(win[KEY].p, 60000); key = keys_get(win[KEY].p, &count, ®); + wtimeout(win[KEY].p, -1); switch (key) { HANDLE_KEY(KEY_GENERIC_CHANGE_VIEW, key_generic_change_view); HANDLE_KEY(KEY_GENERIC_OTHER_CMD, key_generic_other_cmd); -- cgit v1.2.3-54-g00ecf