]> code.citadel.org Git - citadel.git/commitdiff
* Fixed minor bugs with color handling; added explicit support for handling
authorMichael Hampton <io_error@uncensored.citadel.org>
Mon, 11 Nov 2002 06:21:55 +0000 (06:21 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Mon, 11 Nov 2002 06:21:55 +0000 (06:21 +0000)
  the background color e.g. for transparent terminals

citadel/ChangeLog
citadel/citadel.c
citadel/citadel.rc
citadel/commands.c

index 84d729305dc399ae80fcdf2bd4adf7cd9ef0be0f..162b05ab7466646757143f1f7db768afd42bfd52 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 601.65  2002/11/11 06:21:55  error
+ * Fixed minor bugs with color handling; added explicit support for handling
+   the background color e.g. for transparent terminals
+
  Revision 601.64  2002/11/11 04:17:24  ajc
  * More work on reply to meeting invitation
 
@@ -4206,3 +4210,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index b6ca61a53bc833956a3167d614cda49a04444467..60be1602a0a255f4440cf805ab16a286f953b8c3 100644 (file)
@@ -1194,12 +1194,13 @@ NEWUSR: if (strlen(rc_password) == 0) {
                        enable_color = 0;
        }
 
-       scr_printf("%s\nAccess level: %d (%s)\n"
+       color(BRIGHT_WHITE);
+       scr_printf("\n%s\nAccess level: %d (%s)\n"
                   "User #%ld / Login #%d",
                   fullname, axlevel, axdefs[(int) axlevel],
                   usernum, timescalled);
        if (lastcall > 0L) {
-               scr_printf(" / Last login: %s\n",
+               scr_printf(" / Last login: %s",
                           asctime(localtime(&lastcall)));
        }
        scr_printf("\n");
@@ -1691,7 +1692,9 @@ NEWUSR:   if (strlen(rc_password) == 0) {
                        }       /* end switch */
        } while (termn8 == 0);
 
- TERMN8:       scr_printf("%s logged out.\n", fullname);
+TERMN8:        scr_printf("%s logged out.", fullname);
+       color(ORIGINAL_PAIR);
+       scr_printf("\n");
        while (march != NULL) {
                remove_march(march->march_name, 0);
        }
index 1809a895b4f72f1a341e2c37291a2202e8589e96..dc1efd238a33af80f7cbadc957ad195a62bd3e39 100644 (file)
@@ -53,6 +53,13 @@ local_screen_dimensions=1
 #
 ansi_color=user
 
+# USE_BACKGROUND controls Citadel's use of the background.  If it is turned
+# off, then Citadel will set the background to black.  When it is turned on,
+# the background will be unchanged.  This is most useful with "transparent"
+# terminals.  Color must be on (see above) or this option has no effect.
+#
+use_background=off
+
 # PROMPT_CONTROL should be set to on/off/user to control whether the <N>ext
 # and <S>top keys are active when displaying the paginator prompt.  If it
 # is set to "user" then it's a user-configurable option.
index 0eab4581771640a5615dd964dc76fe203dd45b5c..a20f67d2621606b95ad6097ba930f55a3bdfa6d0 100644 (file)
@@ -75,6 +75,7 @@ int rc_display_message_numbers;
 int rc_force_mail_prompts;
 int rc_remember_passwords;
 int rc_ansi_color;
+int rc_color_use_bg;
 int num_urls = 0;
 int rc_prompt_control = 0;
 time_t rc_idle_threshold = (time_t)900;
@@ -738,6 +739,7 @@ void load_command_set(void)
        rc_display_message_numbers = 0;
        rc_force_mail_prompts = 0;
        rc_ansi_color = 0;
+       rc_color_use_bg = 0;
        strcpy(rc_url_cmd, "");
        strcpy(rc_gotmail_cmd, "");
 #ifdef HAVE_OPENSSL
@@ -847,6 +849,10 @@ void load_command_set(void)
                        if (!strncasecmp(&buf[11], "user", 4))
                                rc_ansi_color = 3;      /* user config */
                }
+               if (!strncasecmp(buf, "use_background=", 15)) {
+                       if (!strncasecmp(&buf[15], "on", 2))
+                               rc_color_use_bg = 9;
+               }
                if (!strncasecmp(buf, "prompt_control=", 15)) {
                        if (!strncasecmp(&buf[15], "on", 2))
                                rc_prompt_control = 1;
@@ -1423,8 +1429,8 @@ FMTEND:
  */
 void color(int colornum)
 {
-       static int is_bold = 0;
-       static int hold_color, current_color;
+       static int hold_color;
+       static int current_color;
 
        if (colornum == COLOR_PUSH) {
                hold_color = current_color;
@@ -1449,17 +1455,13 @@ void color(int colornum)
                 * to mention transparent terminals.
                 */
                if (colornum == ORIGINAL_PAIR)
-                       printf("\033[39;49m");
+                       printf("\033[0;39;49m");
                else
-                       printf("\033[3%d;40m", (colornum & 7));
-
-               if ((colornum >= 8) && (is_bold == 0)) {
-                       printf("\033[1m");
-                       is_bold = 1;
-               } else if ((colornum < 8) && (is_bold == 1)) {
-                       printf("\033[0m");
-                       is_bold = 0;
-               }
+                       printf("\033[%d;3%d;4%dm", 
+                                       (colornum & 8) ? 1 : 0,
+                                       (colornum & 7),
+                                       rc_color_use_bg);
+
                scr_flush();
        }
 }
@@ -1467,7 +1469,8 @@ void color(int colornum)
 void cls(int colornum)
 {
        if (enable_color) {
-               printf("\033[4%dm\033[2J\033[H\033[0m", colornum);
+               printf("\033[4%dm\033[2J\033[H\033[0m",
+                               colornum ? colornum : rc_color_use_bg);
                scr_flush();
        }
 }