mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Allow people to select the old console behavior of white text on a black
background, by using the startup flag '-B'. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@147262 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -77,6 +77,13 @@ Core:
|
|||||||
had any significance). Since this violates the Principle of Least Surprise,
|
had any significance). Since this violates the Principle of Least Surprise,
|
||||||
it has been changed.
|
it has been changed.
|
||||||
|
|
||||||
|
* The default console now will use colors according to the default background
|
||||||
|
color, instead of forcing the background color to black. If you are using a
|
||||||
|
light colored background for your console, you may wish to use the option
|
||||||
|
flag '-W' to present better color choices for the various messages. However,
|
||||||
|
if you'd prefer the old method of forcing colors to white text on a black
|
||||||
|
background, the compatiblity option -B is provided for this purpose.
|
||||||
|
|
||||||
Voicemail:
|
Voicemail:
|
||||||
|
|
||||||
* The voicemail configuration values 'maxmessage' and 'minmessage' have
|
* The voicemail configuration values 'maxmessage' and 'minmessage' have
|
||||||
|
@@ -86,6 +86,8 @@ enum ast_option_flags {
|
|||||||
AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25),
|
AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25),
|
||||||
/*! Count Initiated seconds in CDR's */
|
/*! Count Initiated seconds in CDR's */
|
||||||
AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26),
|
AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26),
|
||||||
|
/*! Force black background */
|
||||||
|
AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27),
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! These are the options that set by default when Asterisk starts */
|
/*! These are the options that set by default when Asterisk starts */
|
||||||
@@ -116,6 +118,7 @@ enum ast_option_flags {
|
|||||||
#define ast_opt_dbg_file ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_FILE)
|
#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_verb_file ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_FILE)
|
||||||
#define ast_opt_light_background ast_test_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND)
|
#define ast_opt_light_background ast_test_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND)
|
||||||
|
#define ast_opt_force_black_background ast_test_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND)
|
||||||
|
|
||||||
extern struct ast_flags ast_options;
|
extern struct ast_flags ast_options;
|
||||||
|
|
||||||
|
@@ -2795,6 +2795,8 @@ static void ast_readconfig(void)
|
|||||||
ast_verbose("Invalid Entity ID '%s' provided\n", v->value);
|
ast_verbose("Invalid Entity ID '%s' provided\n", v->value);
|
||||||
} else if (!strcasecmp(v->name, "lightbackground")) {
|
} else if (!strcasecmp(v->name, "lightbackground")) {
|
||||||
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LIGHT_BACKGROUND);
|
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_LIGHT_BACKGROUND);
|
||||||
|
} else if (!strcasecmp(v->name, "forceblackbackground")) {
|
||||||
|
ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) {
|
for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) {
|
||||||
@@ -2937,7 +2939,7 @@ int main(int argc, char *argv[])
|
|||||||
if (getenv("HOME"))
|
if (getenv("HOME"))
|
||||||
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
|
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
|
||||||
/* Check for options */
|
/* Check for options */
|
||||||
while ((c = getopt(argc, argv, "mtThfFdvVqprRgciInx:U:G:C:L:M:e:s:W")) != -1) {
|
while ((c = getopt(argc, argv, "mtThfFdvVqprRgciInx:U:G:C:L:M:e:s:WB")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
#if defined(HAVE_SYSINFO)
|
#if defined(HAVE_SYSINFO)
|
||||||
case 'e':
|
case 'e':
|
||||||
@@ -3031,6 +3033,11 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
case 'W': /* White background */
|
case 'W': /* White background */
|
||||||
ast_set_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
|
ast_set_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
|
||||||
|
ast_clear_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
|
||||||
|
break;
|
||||||
|
case 'B': /* Force black background */
|
||||||
|
ast_set_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND);
|
||||||
|
ast_clear_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND);
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
exit(1);
|
exit(1);
|
||||||
|
32
main/term.c
32
main/term.c
@@ -152,6 +152,10 @@ int ast_term_init(void)
|
|||||||
snprintf(prepdata, sizeof(prepdata), "%c[%dm", ESC, COLOR_BROWN);
|
snprintf(prepdata, sizeof(prepdata), "%c[%dm", ESC, COLOR_BROWN);
|
||||||
snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK);
|
snprintf(enddata, sizeof(enddata), "%c[%dm", ESC, COLOR_BLACK);
|
||||||
snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
|
snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
|
||||||
|
} else if (ast_opt_force_black_background) {
|
||||||
|
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);
|
||||||
} else {
|
} else {
|
||||||
snprintf(prepdata, sizeof(prepdata), "%c[%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN);
|
snprintf(prepdata, sizeof(prepdata), "%c[%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN);
|
||||||
snprintf(enddata, sizeof(enddata), "%c[%d;%dm", ESC, ATTR_RESET, COLOR_WHITE);
|
snprintf(enddata, sizeof(enddata), "%c[%d;%dm", ESC, ATTR_RESET, COLOR_WHITE);
|
||||||
@@ -179,11 +183,19 @@ char *term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int
|
|||||||
fgcolor &= ~128;
|
fgcolor &= ~128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bgcolor) {
|
||||||
|
bgcolor &= ~128;
|
||||||
|
}
|
||||||
|
|
||||||
if (ast_opt_light_background) {
|
if (ast_opt_light_background) {
|
||||||
fgcolor = opposite(fgcolor);
|
fgcolor = opposite(fgcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(outbuf, maxout, "%c[%d;%dm%s%c[0m", ESC, attr, fgcolor, inbuf, ESC);
|
if (ast_opt_force_black_background) {
|
||||||
|
snprintf(outbuf, maxout, "%c[%d;%d;%dm%s%c[%d;%dm", ESC, attr, fgcolor, bgcolor + 10, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10);
|
||||||
|
} else {
|
||||||
|
snprintf(outbuf, maxout, "%c[%d;%dm%s%c[0m", ESC, attr, fgcolor, inbuf, ESC);
|
||||||
|
}
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +216,15 @@ char *term_color_code(char *outbuf, int fgcolor, int bgcolor, int maxout)
|
|||||||
fgcolor = opposite(fgcolor);
|
fgcolor = opposite(fgcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(outbuf, maxout, "%c[%d;%dm", ESC, attr, fgcolor);
|
if (bgcolor) {
|
||||||
|
bgcolor &= ~128;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ast_opt_force_black_background) {
|
||||||
|
snprintf(outbuf, maxout, "%c[%d;%d;%dm", ESC, attr, fgcolor, bgcolor + 10);
|
||||||
|
} else {
|
||||||
|
snprintf(outbuf, maxout, "%c[%d;%dm", ESC, attr, fgcolor);
|
||||||
|
}
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +255,13 @@ char *term_prompt(char *outbuf, const char *inbuf, int maxout)
|
|||||||
ast_copy_string(outbuf, inbuf, maxout);
|
ast_copy_string(outbuf, inbuf, maxout);
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
if (ast_opt_light_background) {
|
if (ast_opt_force_black_background) {
|
||||||
|
snprintf(outbuf, maxout, "%c[%d;%dm%c%c[%d;%dm%s",
|
||||||
|
ESC, COLOR_BLUE, COLOR_BLACK + 10,
|
||||||
|
inbuf[0],
|
||||||
|
ESC, COLOR_WHITE, COLOR_BLACK + 10,
|
||||||
|
inbuf + 1);
|
||||||
|
} else if (ast_opt_light_background) {
|
||||||
snprintf(outbuf, maxout, "%c[%d;0m%c%c[%d;0m%s",
|
snprintf(outbuf, maxout, "%c[%d;0m%c%c[%d;0m%s",
|
||||||
ESC, COLOR_BLUE,
|
ESC, COLOR_BLUE,
|
||||||
inbuf[0],
|
inbuf[0],
|
||||||
|
Reference in New Issue
Block a user