]> Pileus Git - lackey/blobdiff - src/main.c
Improve calendar debugging
[lackey] / src / main.c
index d3fa34d2c1120d2624e20779e4cb9aca68d59695..7d8d517d5f9772a9d0179563bda550b50e7d5ba2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2012-2013 Andy Spencer <andy753421@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,6 +15,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#define _XOPEN_SOURCE
+
 #include <stdlib.h>
 #include <signal.h>
 #include <locale.h>
@@ -46,6 +48,10 @@ int main(int argc, char **argv)
        /* Misc setup */
        signal(SIGINT, on_sigint);
 
+       /* Set default escape timeout */
+       if (!getenv("ESCDELAY"))
+               putenv("ESCDELAY=25");
+
        /* Setup Curses */
        setlocale(LC_ALL, "");
        initscr();
@@ -54,6 +60,7 @@ int main(int argc, char **argv)
        keypad(stdscr, TRUE);
        start_color();
        curs_set(false);
+       timeout(100);
        use_default_colors();
        mousemask(ALL_MOUSE_EVENTS, NULL);
 
@@ -80,6 +87,7 @@ int main(int argc, char **argv)
        view_init();
 
        /* Draw initial view */
+       date_sync();
        view_draw();
 
        /* Run */
@@ -87,14 +95,13 @@ int main(int argc, char **argv)
                MEVENT btn;
                conf_sync();
                int chr = getch();
+               date_sync();
                if (chr == 'q')
                        break;
                if (chr == KEY_MOUSE)
                        if (getmouse(&btn) != OK)
                                continue;
                switch (chr) {
-                       case ERR:
-                               continue;
                        case KEY_RESIZE:
                                endwin();
                                refresh();
@@ -110,6 +117,8 @@ int main(int argc, char **argv)
                }
                if (view_run(chr, btn.bstate, btn.y, btn.x))
                        continue;
+               if (chr == ERR) // timeout
+                       continue;
                debug("main: Unhandled key - Dec %3d,  Hex %02x,  Oct %03o,  Chr <%c>",
                                chr, chr, chr, chr);
        }