]> code.citadel.org Git - citadel.git/blobdiff - citadel/screen.c
* Variable names, comments, documentation, etc... removed the acronym 'BBS'
[citadel.git] / citadel / screen.c
index 0e15cc441a16658cdf7808a040e77b8453ac9d38..7a5bdcced0593bcd32d4d2e99d7d7a57e35ded99 100644 (file)
@@ -4,14 +4,14 @@
  * Handle full-screen curses stuff
  */
 
-#include "sysdep.h"
-#include "screen.h"
+#include <stdlib.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <signal.h>
 #include <string.h>
 #include <stdarg.h>
-#include <unistd.h>
 #include <sys/types.h>
+#include "sysdep.h"
 #ifdef HAVE_VW_PRINTW
 #define _vwprintw vw_printw
 #else
@@ -25,6 +25,7 @@
 #include "citadel_ipc.h"
 #include "citadel_decls.h"
 #include "commands.h"
+#include "screen.h"
 
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
 static SCREEN *myscreen = NULL;
@@ -55,7 +56,7 @@ int is_curses_enabled(void) {
  * status_line() is a convenience function for writing a "typical"
  * status line to the window.
  */
-void status_line(const char *humannode, const char *bbs_city,
+void status_line(const char *humannode, const char *site_location,
                 const char *room_name, int secure, int newmailcount)
 {
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
@@ -83,16 +84,27 @@ void status_line(const char *humannode, const char *bbs_city,
  * Display a 3270-style "wait" indicator at the bottom of the screen
  */
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
-void wait_indicator(int onoff) {
-       if (statuswindow) {
+void wait_indicator(int state) {
 
-               mvwinch(statuswindow, 0, 78);
-               if (onoff) {
-                       waddch(statuswindow, 'X');
-               }
-               else {
+       if (!isendwin() && statuswindow) {
+
+               mvwinch(statuswindow, 0, screenwidth - 2);
+               switch (state) {
+               default:
+               case 0:         /* Idle */
                        waddch(statuswindow, ' ');
+                       break;
+               case 1:         /* Waiting */
+                       waddch(statuswindow, 'X');
+                       break;
+               case 2:         /* Receiving */
+                       waddch(statuswindow, '<');
+                       break;
+               case 3:         /* Sending */
+                       waddch(statuswindow, '>');
+                       break;
                }
+               waddch(statuswindow, '\r');
                wrefresh(statuswindow);
                wrefresh(mainwindow);   /* this puts the cursor back */
        }
@@ -130,9 +142,6 @@ void screen_new(void)
 
                if (COLOR_PAIRS > 8)
                        init_pair(8, COLOR_WHITE, COLOR_BLUE);
-
-               setLockHook(wait_indicator);
-
        } else
 #endif /* HAVE_CURSES_H */
        {
@@ -155,12 +164,26 @@ void screen_delete(void)
        windows_delete();
        screen_reset();
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
-       if (myscreen)
+       if (myscreen) {
                delscreen(myscreen);
+       }
        myscreen = NULL;
 #endif
 }
 
+/*
+ * Beep.
+ */
+void ctdl_beep(void) {
+#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
+       if (myscreen)
+               beep();
+       else
+#endif
+       putc(7, stdout);
+}
+       
+
 
 /*
  * Set screen/IO parameters, e.g. at start of program or return from external
@@ -186,7 +209,7 @@ int screen_reset(void)
 {
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
        if (myscreen) {
-               endwin();
+               if (!isendwin()) endwin();
                return 1;
        }
 #endif /* HAVE_CURSES_H */
@@ -313,7 +336,8 @@ int scr_getc(int delay)
 #endif
 
        buf = '\0';
-       read (0, &buf, 1);
+       if (!read (0, &buf, 1))
+               logoff(NULL, 3);
        return buf;
 }
 
@@ -348,10 +372,14 @@ int scr_putc(int c)
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
        if (mainwindow) {
                if (c == 7) beep();
-               return ((waddch(mainwindow, c) == OK) ? c : EOF);
+               if (waddch(mainwindow, c) != OK)
+                       logoff(NULL, 3);
+               return c;
        }
 #endif
-       return putc(c, stdout);
+       if (putc(c, stdout) == EOF)
+               logoff(NULL, 3);
+       return c;
 }
 
 
@@ -436,7 +464,7 @@ static volatile int caught_sigwinch = 0;
 /*
  * this is not supposed to be called from a signal handler.
  */
-int scr_set_windowsize()
+int scr_set_windowsize(CtdlIPC* ipc)
 {
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
        if (mainwindow && caught_sigwinch) {
@@ -449,8 +477,8 @@ int scr_set_windowsize()
                wresize(statuswindow, 1, screenwidth);
 #endif
                mvwin(statuswindow, screenheight, 0);
-               status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
-                            room_name, secure, -1);
+               status_line(ipc->ServInfo.humannode, ipc->ServInfo.site_location,
+                               room_name, secure, -1);
                wnoutrefresh(mainwindow);
                wnoutrefresh(statuswindow);
                doupdate();