Updated the boilerplate on each file
[citadel.git] / textclient / screen.c
index cd1d5263272491861e7621c6c11a6c55cd649131..eac342f4b0352cc25b42f6500959dbf4918fde80 100644 (file)
@@ -1,20 +1,17 @@
-/*
- * Screen output handling
- *
- * Copyright (c) 1987-2018 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// Screen output handling
+//
+// Copyright (c) 1987-2021 by the citadel.org team
+//
+// This program is open source software.  Use, duplication, and/or
+// disclosure are subject to the GNU General Purpose License version 3.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 
 #include "textclient.h"
 
-
 int enable_status_line = 0;
 char status_line[1024] = "     ";
 
@@ -34,8 +31,7 @@ void do_keepalive(void);
  * Attempt to discover the screen dimensions. 
  * WARNING: This is sometimes called from a signal handler.
  */
-void check_screen_dims(void)
-{
+void check_screen_dims(void) {
 #ifdef TIOCGWINSZ
        struct {
                unsigned short height;  /* rows */
@@ -57,8 +53,7 @@ void check_screen_dims(void)
 /*
  * Initialize the screen
  */
-void screen_new(void)
-{
+void screen_new(void) {
        send_ansi_detect();
        look_for_ansi();
        cls(0);
@@ -66,22 +61,18 @@ void screen_new(void)
 }
 
 
-
 /*
  * Beep.
  */
 void ctdl_beep(void) {
        putc(7, stdout);
 }
-       
-
 
 
 /*
  * scr_printf() outputs to the terminal
  */
-int scr_printf(char *fmt, ...)
-{
+int scr_printf(char *fmt, ...) {
        static char outbuf[4096];       /* static for performance -- not re-entrant -- change if needed */
        va_list ap;
        int retval;
@@ -92,7 +83,7 @@ int scr_printf(char *fmt, ...)
        va_end(ap);
 
        len = strlen(outbuf);
-       for (i=0; i<len; ++i) {
+       for (i = 0; i < len; ++i) {
                scr_putc(outbuf[i]);
        }
        return retval;
@@ -102,20 +93,20 @@ int scr_printf(char *fmt, ...)
 /*
  * Read one character from the terminal
  */
-int scr_getc(int delay)
-{
+int scr_getc(int delay) {
        unsigned char buf;
 
        scr_flush();
 
        buf = '\0';
-       if (!read (0, &buf, 1))
+       if (!read(0, &buf, 1))
                logoff(NULL, 3);
 
        lines_printed = 0;
        return buf;
 }
 
+
 /*
  * Issue the paginator prompt (more / hit any key to continue)
  */
@@ -126,13 +117,13 @@ void hit_any_key(void) {
        color(DIM_RED);
        scr_printf("%s\r", moreprompt);
        color(COLOR_POP);
-       b=inkey();
-       for (a=0; a<screenwidth; ++a) {
+       b = inkey();
+       for (a = 0; a < screenwidth; ++a) {
                scr_putc(' ');
        }
        scr_printf("\r");
 
-       if ( (rc_prompt_control == 1) || ((rc_prompt_control == 3) && (userflags & US_PROMPTCTL)) ) {
+       if ((rc_prompt_control == 1) || ((rc_prompt_control == 3) && (userflags & US_PROMPTCTL))) {
                if (b == 'q' || b == 'Q' || b == 's' || b == 'S') {
                        b = STOP_KEY;
                }
@@ -141,22 +132,23 @@ void hit_any_key(void) {
                }
        }
 
-       if (b==NEXT_KEY) sigcaught = SIGINT;
-       if (b==STOP_KEY) sigcaught = SIGQUIT;
+       if (b == NEXT_KEY)
+               sigcaught = SIGINT;
+       if (b == STOP_KEY)
+               sigcaught = SIGQUIT;
 }
 
 
 /*
  * Output one character to the terminal
  */
-int scr_putc(int c)
-{
+int scr_putc(int c) {
        /* handle tabs normally */
        if (c == '\t') {
                do {
                        scr_putc(' ');
                } while ((cols_printed % 8) != 0);
-               return(c);
+               return (c);
        }
 
        /* Output the character... */
@@ -182,10 +174,10 @@ int scr_putc(int c)
        /* 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) && (enable_status_line)) ? (3) : (2) ) ;
+       int height_offset = (((enable_color) && (screenwidth > 0) && (enable_status_line)) ? (3) : (2));
 
        /* Ok, go check it.  Stop and display the paginator prompt if necessary. */
-       if ((screenheight > 0) && (lines_printed > (screenheight-height_offset))) {
+       if ((screenheight > 0) && (lines_printed > (screenheight - height_offset))) {
                lines_printed = 0;
                hit_any_key();
                lines_printed = 0;
@@ -195,8 +187,8 @@ int scr_putc(int c)
        return c;
 }
 
-void scr_flush(void)
-{
+
+void scr_flush(void) {
        if ((enable_color) && (screenwidth > 0) && (enable_status_line)) {
                if (strlen(status_line) < screenwidth) {
                        memset(&status_line[strlen(status_line)], 32, screenwidth - strlen(status_line));
@@ -216,8 +208,7 @@ static volatile int caught_sigwinch = 0;
  * scr_winch() handles window size changes from SIGWINCH
  * resizes all our windows for us
  */
-sighandler_t scr_winch(int signum)
-{
+sighandler_t scr_winch(int signum) {
        /* if we receive this signal, we must be running
         * in a terminal that supports resizing.
         */
@@ -227,32 +218,31 @@ sighandler_t scr_winch(int signum)
 }
 
 
-
 /*
  * Display a 3270-style "wait" indicator at the bottom of the screen
  */
 void scr_wait_indicator(int state) {
        int sp = (screenwidth - 2);
 
-       if (!enable_status_line) return;
+       if (!enable_status_line)
+               return;
 
        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;
+               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();
        }
 }
-