From 83e5268937fee4890275ac061e645624d9657402 Mon Sep 17 00:00:00 2001 From: Michael Hampton Date: Mon, 11 Nov 2002 06:21:55 +0000 Subject: [PATCH] * Fixed minor bugs with color handling; added explicit support for handling the background color e.g. for transparent terminals --- citadel/ChangeLog | 5 +++++ citadel/citadel.c | 9 ++++++--- citadel/citadel.rc | 7 +++++++ citadel/commands.c | 29 ++++++++++++++++------------- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 84d729305..162b05ab7 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citadel.c b/citadel/citadel.c index b6ca61a53..60be1602a 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -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); } diff --git a/citadel/citadel.rc b/citadel/citadel.rc index 1809a895b..dc1efd238 100644 --- a/citadel/citadel.rc +++ b/citadel/citadel.rc @@ -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 ext # and top keys are active when displaying the paginator prompt. If it # is set to "user" then it's a user-configurable option. diff --git a/citadel/commands.c b/citadel/commands.c index 0eab45817..a20f67d26 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -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(); } } -- 2.39.2