The status line is back! Reused the callbacks from IO ERROR's
authorArt Cancro <ajc@citadel.org>
Sat, 4 Sep 2010 05:52:27 +0000 (01:52 -0400)
committerArt Cancro <ajc@citadel.org>
Sat, 4 Sep 2010 05:52:27 +0000 (01:52 -0400)
implementation but reimplemented the display in a way that does
not require using curses.

citadel/textclient/citadel.c
citadel/textclient/screen.c
citadel/textclient/screen.h

index 9f458f62c3a313ab534154f2ec5cf4f704c3e30b..105f2d9f695af083e698c6754b96e797948796f1 100644 (file)
@@ -531,6 +531,14 @@ void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto)
                }
        }
        free(room);
+
+       if (screenwidth>5) snprintf(&status_line[1], screenwidth-1, "%s  |  %s  |  %s  |  %s  |  %d new mail  |",
+               (secure ? "Encrypted" : "Unencrypted"),
+               ipc->ServInfo.humannode,
+               ipc->ServInfo.site_location,
+               room_name,
+               newmailcount
+       );
 }
 
 /* Goto next room having unread messages.
@@ -1550,6 +1558,8 @@ int main(int argc, char **argv)
                logoff(NULL, 3);
        }
 
+       CtdlIPC_SetNetworkStatusCallback(ipc, scr_wait_indicator);
+
        if (!(ipc->isLocal)) {
                scr_printf("Connected to %s [%s].\n", ipc->ip_hostname, ipc->ip_address);
        }
index c8d9d56f20c485d22d124cef551f1122c6fdb4c6..607381079b46e77dadc99b13a15f0b849ce1de72 100644 (file)
@@ -20,7 +20,7 @@
 #include "commands.h"
 #include "screen.h"
 
-char arg_screen;
+char status_line[1024] = "     ";
 
 /* the default paginator prompt will be replaced by the server's prompt when we learn it */
 char *moreprompt = " -- more -- ";
@@ -161,7 +161,13 @@ int scr_putc(int c)
                }
        }
 
-       if ((screenheight > 0) && (lines_printed > (screenheight-2))) { /* -3 if we add status line */
+       /* How many lines output before stopping for the paginator?
+        * Depends on whether we are displaying a status line.
+        */
+       int height_offset = ( ((enable_color) && (screenwidth > 0)) ? (3) : (2) ) ;
+
+       /* Ok, go check it.  Stop and display the paginator prompt if necessary. */
+       if ((screenheight > 0) && (lines_printed > (screenheight-height_offset))) {
                lines_printed = 0;
                hit_any_key();
                lines_printed = 0;
@@ -171,36 +177,16 @@ int scr_putc(int c)
        return c;
 }
 
-/*
-char status_line[1024] =
-       " This is the status line, status line, status line, this is "
-       "the status line, all day long. *****************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************"
-       "************************************************************";
-*/
-
 void scr_flush(void)
 {
-       /*
        if ((enable_color) && (screenwidth > 0)) {
+               if (strlen(status_line) < screenwidth) {
+                       memset(&status_line[strlen(status_line)], 32, screenwidth - strlen(status_line));
+               }
                printf("\033[s\033[1;1H\033[K\033[7m");
                fwrite(status_line, screenwidth, 1, stdout);
                printf("\033[27m\033[u");
        }
-       */
        fflush(stdout);
 }
 
@@ -222,3 +208,32 @@ RETSIGTYPE scr_winch(int signum)
        check_screen_dims();
        signal(SIGWINCH, scr_winch);
 }
+
+
+
+/*
+ * Display a 3270-style "wait" indicator at the bottom of the screen
+ */
+void scr_wait_indicator(int state) {
+       int sp = (screenwidth - 2);
+
+       if (screenwidth > 0) {
+               switch (state) {
+                       default:
+                       case 0:  /* Idle */
+                               status_line[sp] = ' ';
+                               break;
+                       case 1:  /* Waiting */
+                               status_line[sp] = 'X';
+                               break;
+                       case 2:  /* Receiving */
+                               status_line[sp] = '<';
+                               break;
+                       case 3:  /* Sending */
+                               status_line[sp] = '>';
+                               break;
+               }
+               scr_flush();
+       }
+}
+
index 4599705f59b0d6036baa308d372103d16612da52..7ed7f66dd240c8ab4a265fd864342cc8a33ad9a1 100644 (file)
@@ -3,14 +3,14 @@
 
 void screen_new(void);
 int scr_printf(char *fmt, ...);
-
 #define SCR_NOBLOCK 0
 #define SCR_BLOCK -1
 int scr_getc(int delay);
-
 int scr_putc(int c);
 void scr_flush(void);
 int scr_blockread(void);
 RETSIGTYPE scr_winch(int signum);
 void wait_indicator(int state);
 void ctdl_beep(void);
+void scr_wait_indicator(int);
+extern char status_line[];