]> code.citadel.org Git - citadel.git/commitdiff
I made some changes that I hope will help the lagging input problem
authorStu Mark <theeverything@citadel.org>
Fri, 15 Feb 2002 00:48:24 +0000 (00:48 +0000)
committerStu Mark <theeverything@citadel.org>
Fri, 15 Feb 2002 00:48:24 +0000 (00:48 +0000)
but since I can't actually make it happen here, you'll have to
try it out to see if it helps. If it doesn't actually help, its
should at least be closer to the way to go. I had to jimmy
some stuff around (made do_keepalive not static) and one or two
other things. TRY THIS OUT BEFORE INSTALLING IT MAKE SURE IT DOESN'T
KILL THE WHOLE THING.

citadel/commands.c
citadel/screen.c
citadel/screen.h

index 4ea818cead701ce3766f91c439ea93266086e5d6..e15270b3a8775b5c29244d017edcaadec43c7ab6 100644 (file)
@@ -380,7 +380,11 @@ static void async_ka_exec(void)
 }
 #endif /* THREADED_CLIENT */
 
-static void do_keepalive(void)
+/* I changed this from static to not because I need to call it from
+   screen.c, either that or make something in screen.c not static.
+   Fix it how you like. Why all the staticness? stu */
+   
+void do_keepalive(void)
 {
        time_t now;
 
@@ -429,16 +433,20 @@ void async_ka_start(void)
 int inkey(void)
 {                              /* get a character from the keyboard, with   */
        int a;                  /* the watchdog timer in effect if necessary */
+#ifndef HAVE_CURSES_H /* avoid compiler warning */
        fd_set rfds;
        struct timeval tv;
-       time_t start_time, now;
+#endif
+       time_t start_time;
 
        scr_flush();
        lines_printed = 0;
        time(&start_time);
 
        do {
-
+#ifdef HAVE_CURSES_H /* IO, maybe you wanna move this to screen.c */
+        a = scr_blockread();
+#else
                /* This loop waits for keyboard input.  If the keepalive
                 * timer expires, it sends a keepalive to the server if
                 * necessary and then waits again.
@@ -451,17 +459,16 @@ int inkey(void)
                        tv.tv_sec = S_KEEPALIVE;
                        tv.tv_usec = 0;
 
-                       time(&now);
                        select(1, &rfds, NULL, NULL, &tv);
                } while (!FD_ISSET(0, &rfds));
 
-
-
-
                /* At this point, there's input, so fetch it.
                 * (There's a hole in the bucket...)
                 */
                a = scr_getc();
+#endif
+
+
                if (a == 127)
                        a = 8;
                if (a > 126)
index 1cfcb9760441bd88973f64c5a999062c42f2997f..202cdd1c6e5230e139a178516736c6cf5903ce4e 100644 (file)
@@ -40,6 +40,8 @@ extern int rc_ansi_color;
 extern void check_screen_dims(void);
 #endif
 
+void do_keepalive(void);
+
 
 /*
  * status_line() is a convenience function for writing a "typical"
@@ -268,12 +270,26 @@ int sln_printf_if(char *fmt, ...)
 int scr_getc(void)
 {
 #ifdef HAVE_CURSES_H
+    /* This looks scary, the program will hang if mainwindow is null */
        if (mainwindow)
                return wgetch(mainwindow);
 #endif
        return getchar();
 }
-
+int scr_blockread(void)
+  {
+    int a;
+    wtimeout(mainwindow, S_KEEPALIVE); 
+    while (1)
+      {
+        do_keepalive();
+        a = wgetch(mainwindow); /* will block for food */
+        if (a != ERR)
+          break;
+        /* a = scr_getc(); */
+      }
+    return a;
+  }
 
 /*
  * scr_putc() outputs a single character
index c7dfc8ea48262269580c49d1d7b9a293593aa502..2254b96cc817c8e2cdb9095f59c3b95b30ed145e 100644 (file)
@@ -20,3 +20,4 @@ void sln_flush(void);
 int scr_set_windowsize(void);
 void windows_new(void);
 void windows_delete(void);
+int scr_blockread(void);