Index: doc/asterisk.8 =================================================================== --- doc/asterisk.8 (revision 137850) +++ doc/asterisk.8 (working copy) @@ -157,6 +157,10 @@ \fB-V\fR Display version information and exit immediately. .TP +\fB-W\fR +Change the terminal colors to compensate for a white background, +rather than black, as is the default. +.TP \fB-x \fIcommand\fB\fR Connect to a running Asterisk process and execute a command on a command line, passing any output through to standard out and Index: Makefile =================================================================== --- Makefile (revision 137850) +++ Makefile (working copy) @@ -684,6 +684,7 @@ echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \ echo ";runuser = asterisk ; The user to run as" ; \ echo ";rungroup = asterisk ; The group to run as" ; \ + echo ";whitebackground = yes ; If your terminal is set for black on white" ; \ echo "dahdichanname = yes ; Set channel name as DAHDI" ; \ echo "" ; \ echo "; Changing the following lines may compromise your security." ; \ Index: include/asterisk/options.h =================================================================== --- include/asterisk/options.h (revision 137850) +++ include/asterisk/options.h (working copy) @@ -82,6 +82,8 @@ AST_OPT_FLAG_DEBUG_FILE = (1 << 23), /*! There is a per-file verbose setting */ AST_OPT_FLAG_VERBOSE_FILE = (1 << 24), + /*! Terminal colors should be adjusted for a white background */ + AST_OPT_FLAG_WHITE_BACKGROUND = (1 << 25), }; /*! These are the options that set by default when Asterisk starts */ @@ -111,6 +113,7 @@ #define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE) #define ast_opt_dbg_file ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_FILE) #define ast_opt_verb_file ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_FILE) +#define ast_opt_white_background ast_test_flag(&ast_options, AST_OPT_FLAG_WHITE_BACKGROUND) extern struct ast_flags ast_options; Index: main/loader.c =================================================================== --- main/loader.c (revision 137850) +++ main/loader.c (working copy) @@ -696,7 +696,7 @@ switch (res) { case AST_MODULE_LOAD_SUCCESS: if (!ast_fully_booted) { - ast_verb(1, "%s => (%s)\n", resource_name, term_color(tmp, mod->info->description, COLOR_BROWN, COLOR_BLACK, sizeof(tmp))); + ast_verb(1, "%s => (%s)\n", resource_name, term_color(tmp, mod->info->description, COLOR_BROWN, 0, sizeof(tmp))); if (ast_opt_console && !option_verbose) ast_verbose( "."); } else { Index: main/term.c =================================================================== --- main/term.c (revision 137850) +++ main/term.c (working copy) @@ -50,6 +50,22 @@ NULL }; +static int opposite(int color) +{ + switch (color) { + case COLOR_BLACK: + return COLOR_WHITE; + case COLOR_WHITE: + return COLOR_BLACK; + case COLOR_GRAY: + return COLOR_BRWHITE; + case COLOR_BRWHITE: + return COLOR_GRAY; + default: + return color ^ 128; + } +} + /* Ripped off from Ross Ridge, but it's public domain code (libmytinfo) */ static short convshort(char *s) { @@ -134,9 +150,15 @@ if (vt100compat) { /* Make commands show up in nice colors */ - snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); - snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); - snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); + if (ast_opt_white_background) { + snprintf(prepdata, sizeof(prepdata), "%c[%d;%dm", ESC, COLOR_BROWN, COLOR_WHITE + 10); + snprintf(enddata, sizeof(enddata), "%c[%d;%dm", ESC, COLOR_BLACK, COLOR_WHITE + 10); + snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); + } else { + snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10); + snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10); + snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC); + } } return 0; } @@ -145,6 +167,9 @@ { int attr = 0; char tmp[40]; + int normal_fgcolor = ast_opt_white_background ? COLOR_BLACK : COLOR_WHITE; + int normal_bgcolor = ast_opt_white_background ? COLOR_WHITE : COLOR_BLACK; + if (!vt100compat) { ast_copy_string(outbuf, inbuf, maxout); return outbuf; @@ -158,9 +183,17 @@ ast_copy_string(outbuf, inbuf, maxout); return outbuf; } - if (!bgcolor) - bgcolor = COLOR_BLACK; + if (ast_opt_white_background) { + fgcolor = opposite(fgcolor); + bgcolor = opposite(bgcolor); + } + + /* If we change the colors from the default, avoid blanking the text */ + if (bgcolor == COLOR_WHITE && (fgcolor & 127) == COLOR_WHITE) { + fgcolor = COLOR_BLACK | (fgcolor & 128); + } + if (bgcolor) { bgcolor &= ~128; bgcolor += 10; @@ -177,9 +210,9 @@ snprintf(tmp, sizeof(tmp), "%d", fgcolor); } if (attr) { - snprintf(outbuf, maxout, "%c[%d;%sm%s%c[0;%d;%dm", ESC, attr, tmp, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10); + snprintf(outbuf, maxout, "%c[%d;%sm%s%c[0;%d;%dm", ESC, attr, tmp, inbuf, ESC, normal_fgcolor, normal_bgcolor + 10); } else { - snprintf(outbuf, maxout, "%c[%sm%s%c[0;%d;%dm", ESC, tmp, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10); + snprintf(outbuf, maxout, "%c[%sm%s%c[0;%d;%dm", ESC, tmp, inbuf, ESC, normal_fgcolor, normal_bgcolor + 10); } return outbuf; } @@ -250,11 +283,19 @@ ast_copy_string(outbuf, inbuf, maxout); return outbuf; } - snprintf(outbuf, maxout, "%c[%d;%d;%dm%c%c[%d;%d;%dm%s", - ESC, ATTR_BRIGHT, COLOR_BLUE, COLOR_BLACK + 10, - inbuf[0], - ESC, 0, COLOR_WHITE, COLOR_BLACK + 10, - inbuf + 1); + if (ast_opt_white_background) { + snprintf(outbuf, maxout, "%c[%d;%dm%c%c[%d;%dm%s", + ESC, COLOR_BLUE, COLOR_WHITE + 10, + inbuf[0], + ESC, COLOR_BLACK, COLOR_WHITE + 10, + inbuf + 1); + } else { + snprintf(outbuf, maxout, "%c[%d;%d;%dm%c%c[%d;%d;%dm%s", + ESC, ATTR_BRIGHT, COLOR_BLUE, COLOR_BLACK + 10, + inbuf[0], + ESC, 0, COLOR_WHITE, COLOR_BLACK + 10, + inbuf + 1); + } return outbuf; } Index: main/translate.c =================================================================== --- main/translate.c (revision 137850) +++ main/translate.c (working copy) @@ -671,7 +671,7 @@ calc_cost(t, 1); ast_verb(2, "Registered translator '%s' from format %s to %s, cost %d\n", - term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), + term_color(tmp, t->name, COLOR_MAGENTA, 0, sizeof(tmp)), ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt), t->cost); if (!added_cli) { Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 137850) +++ main/asterisk.c (working copy) @@ -2570,13 +2570,14 @@ printf(" -q Quiet mode (suppress output)\n"); printf(" -r Connect to Asterisk on this machine\n"); printf(" -R Same as -r, except attempt to reconnect if disconnected\n"); + printf(" -s Connect to Asterisk via socket (only valid with -r)\n"); printf(" -t Record soundfiles in /var/tmp and move them where they\n"); printf(" belong after they are done\n"); printf(" -T Display the time in [Mmm dd hh:mm:ss] format for each line\n"); printf(" of output to the CLI\n"); printf(" -v Increase verbosity (multiple v's = more verbose)\n"); printf(" -x Execute command (only valid with -r)\n"); - printf(" -s Connect to Asterisk via socket (only valid with -r)\n"); + printf(" -W Adjust terminal colors to compensate for a white background\n"); printf("\n"); return 0; } @@ -2789,6 +2790,8 @@ g_eid = tmp_eid; } else ast_verbose("Invalid Entity ID '%s' provided\n", v->value); + } else if (!strcasecmp(v->name, "whitebackground")) { + ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_WHITE_BACKGROUND); } } for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) { @@ -2928,7 +2931,7 @@ if (getenv("HOME")) snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME")); /* Check for options */ - while ((c = getopt(argc, argv, "mtThfFdvVqprRgciInx:U:G:C:L:M:e:s:")) != -1) { + while ((c = getopt(argc, argv, "mtThfFdvVqprRgciInx:U:G:C:L:M:e:s:W")) != -1) { switch (c) { #if defined(HAVE_SYSINFO) case 'e': @@ -3020,6 +3023,9 @@ case 's': remotesock = ast_strdupa(optarg); break; + case 'W': /* White background */ + ast_set_flag(&ast_options, AST_OPT_FLAG_WHITE_BACKGROUND); + break; case '?': exit(1); }