
Go to the source code of this file.
Defines | |
| #define | AST_TERM_MAX_ESCAPE_CHARS 23 |
| Maximum number of characters needed for a color escape sequence, plus a null char. | |
| #define | ESC 0x1b |
Terminal Attributes | |
| #define | ATTR_BLINK 5 |
| #define | ATTR_BRIGHT 1 |
| #define | ATTR_DIM 2 |
| #define | ATTR_HIDDEN 8 |
| #define | ATTR_RESET 0 |
| #define | ATTR_REVER 7 |
| #define | ATTR_UNDER 4 |
Terminal Colors | |
| #define | COLOR_BLACK 30 |
| #define | COLOR_BLUE 34 |
| #define | COLOR_BRBLUE (34 | 128) |
| #define | COLOR_BRCYAN (36 | 128) |
| #define | COLOR_BRGREEN (32 | 128) |
| #define | COLOR_BRMAGENTA (35 | 128) |
| #define | COLOR_BROWN 33 |
| #define | COLOR_BRRED (31 | 128) |
| #define | COLOR_BRWHITE (37 | 128) |
| #define | COLOR_CYAN 36 |
| #define | COLOR_GRAY (30 | 128) |
| #define | COLOR_GREEN 32 |
| #define | COLOR_MAGENTA 35 |
| #define | COLOR_RED 31 |
| #define | COLOR_WHITE 37 |
| #define | COLOR_YELLOW (33 | 128) |
Functions | |
| int | ast_term_color_code (struct ast_str **str, int fgcolor, int bgcolor) |
| Append a color sequence to an ast_str. | |
| char * | term_color (char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout) |
| char * | term_color_code (char *outbuf, int fgcolor, int bgcolor, int maxout) |
| Write a color sequence to a string. | |
| char * | term_end (void) |
| void | term_filter_escapes (char *line) |
| char * | term_prep (void) |
| char * | term_prompt (char *outbuf, const char *inbuf, int maxout) |
| char * | term_quit (void) |
| char * | term_strip (char *outbuf, char *inbuf, int maxout) |
Definition in file term.h.
| #define AST_TERM_MAX_ESCAPE_CHARS 23 |
Maximum number of characters needed for a color escape sequence, plus a null char.
Definition at line 67 of file term.h.
Referenced by handle_cli_agi_show(), handle_show_function(), and print_app_docs().
| #define ATTR_BRIGHT 1 |
Definition at line 36 of file term.h.
Referenced by ast_term_init(), check_fgcolor(), term_color(), and term_prompt().
| #define ATTR_RESET 0 |
| #define COLOR_BLACK 30 |
Definition at line 47 of file term.h.
Referenced by __ast_register_translator(), ast_frame_dump(), ast_term_color_code(), ast_term_init(), ast_unregister_translator(), cli_prompt(), handle_dahdi_show_cadences(), main(), opposite(), start_resource(), term_color(), term_color_code(), and term_prompt().
| #define COLOR_BLUE 34 |
| #define COLOR_BRCYAN (36 | 128) |
Definition at line 60 of file term.h.
Referenced by __ast_custom_function_register(), ast_frame_dump(), ast_register_application2(), lua_pbx_exec(), pbx_extension_helper(), and realtime_exec().
| #define COLOR_BRGREEN (32 | 128) |
| #define COLOR_BRMAGENTA (35 | 128) |
Definition at line 58 of file term.h.
Referenced by ast_frame_dump(), lua_pbx_exec(), pbx_extension_helper(), and realtime_exec().
| #define COLOR_BROWN 33 |
Definition at line 53 of file term.h.
Referenced by ast_term_init(), opposite(), and start_resource().
| #define COLOR_BRRED (31 | 128) |
| #define COLOR_BRWHITE (37 | 128) |
Definition at line 62 of file term.h.
Referenced by logger_print_normal(), main(), and show_config_description().
| #define COLOR_CYAN 36 |
Definition at line 59 of file term.h.
Referenced by ast_xmldoc_printable(), handle_cli_agi_show(), handle_show_function(), opposite(), and print_app_docs().
| #define COLOR_GRAY (30 | 128) |
| #define COLOR_GREEN 32 |
| #define COLOR_MAGENTA 35 |
Definition at line 57 of file term.h.
Referenced by __ast_register_translator(), ast_unregister_translator(), handle_cli_agi_show(), handle_dahdi_show_cadences(), handle_show_function(), opposite(), and print_app_docs().
| #define COLOR_RED 31 |
| #define COLOR_WHITE 37 |
Definition at line 61 of file term.h.
Referenced by ast_term_init(), cli_prompt(), term_color(), and term_prompt().
| #define COLOR_YELLOW (33 | 128) |
Definition at line 54 of file term.h.
Referenced by ast_frame_dump(), and show_config_description().
| #define ESC 0x1b |
Definition at line 30 of file term.h.
Referenced by ast_term_color_code(), ast_term_init(), term_color(), term_color_code(), term_filter_escapes(), term_prompt(), term_strip(), xmldoc_string_wrap(), and xmldoc_wait_nextspace().
| int ast_term_color_code | ( | struct ast_str ** | str, | |
| int | fgcolor, | |||
| int | bgcolor | |||
| ) |
Append a color sequence to an ast_str.
| str | The string to append to | |
| fgcolor | foreground color | |
| bgcolor | background color |
| 0 | success | |
| -1 | failure |
Definition at line 236 of file term.c.
References ast_opt_force_black_background, ast_str_append(), check_bgcolor(), check_colors_allowed(), check_fgcolor(), COLOR_BLACK, and ESC.
Referenced by ast_xmldoc_printable().
00237 { 00238 int attr = 0; 00239 00240 if (!check_colors_allowed(fgcolor)) { 00241 return -1; 00242 } 00243 00244 check_fgcolor(&fgcolor, &attr); 00245 check_bgcolor(&bgcolor); 00246 00247 if (ast_opt_force_black_background) { 00248 ast_str_append(str, 0, "%c[%d;%d;%dm", ESC, attr, fgcolor, COLOR_BLACK + 10); 00249 } else if (bgcolor) { 00250 ast_str_append(str, 0, "%c[%d;%d;%dm", ESC, attr, fgcolor, bgcolor + 10); 00251 } else { 00252 ast_str_append(str, 0, "%c[%d;%dm", ESC, attr, fgcolor); 00253 } 00254 00255 return 0; 00256 }
| char* term_color | ( | char * | outbuf, | |
| const char * | inbuf, | |||
| int | fgcolor, | |||
| int | bgcolor, | |||
| int | maxout | |||
| ) |
Definition at line 178 of file term.c.
References ast_copy_string(), ast_opt_force_black_background, ast_opt_light_background, ATTR_BRIGHT, COLOR_BLACK, COLOR_WHITE, ESC, and opposite().
Referenced by __ast_custom_function_register(), __ast_register_translator(), ast_frame_dump(), ast_register_application2(), ast_unregister_translator(), fix_header(), handle_cli_agi_show(), handle_dahdi_show_cadences(), handle_show_function(), logger_print_normal(), lua_pbx_exec(), main(), pbx_extension_helper(), print_app_docs(), realtime_exec(), show_config_description(), and start_resource().
00179 { 00180 int attr = 0; 00181 00182 if (!vt100compat) { 00183 ast_copy_string(outbuf, inbuf, maxout); 00184 return outbuf; 00185 } 00186 if (!fgcolor) { 00187 ast_copy_string(outbuf, inbuf, maxout); 00188 return outbuf; 00189 } 00190 00191 if (fgcolor & 128) { 00192 attr = ast_opt_light_background ? 0 : ATTR_BRIGHT; 00193 fgcolor &= ~128; 00194 } 00195 00196 if (bgcolor) { 00197 bgcolor &= ~128; 00198 } 00199 00200 if (ast_opt_light_background) { 00201 fgcolor = opposite(fgcolor); 00202 } 00203 00204 if (ast_opt_force_black_background) { 00205 snprintf(outbuf, maxout, "%c[%d;%d;%dm%s%c[%d;%dm", ESC, attr, fgcolor, bgcolor + 10, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10); 00206 } else { 00207 snprintf(outbuf, maxout, "%c[%d;%dm%s%c[0m", ESC, attr, fgcolor, inbuf, ESC); 00208 } 00209 return outbuf; 00210 }
| char* term_color_code | ( | char * | outbuf, | |
| int | fgcolor, | |||
| int | bgcolor, | |||
| int | maxout | |||
| ) |
Write a color sequence to a string.
| outbuf | the location to write to | |
| fgcolor | foreground color | |
| bgcolor | background color | |
| maxout | maximum number of characters to write |
Definition at line 258 of file term.c.
References ast_opt_force_black_background, check_bgcolor(), check_colors_allowed(), check_fgcolor(), COLOR_BLACK, and ESC.
Referenced by cli_prompt().
00259 { 00260 int attr = 0; 00261 00262 if (!check_colors_allowed(fgcolor)) { 00263 *outbuf = '\0'; 00264 return outbuf; 00265 } 00266 00267 check_fgcolor(&fgcolor, &attr); 00268 check_bgcolor(&bgcolor); 00269 00270 if (ast_opt_force_black_background) { 00271 snprintf(outbuf, maxout, "%c[%d;%d;%dm", ESC, attr, fgcolor, COLOR_BLACK + 10); 00272 } else if (bgcolor) { 00273 snprintf(outbuf, maxout, "%c[%d;%d;%dm", ESC, attr, fgcolor, bgcolor + 10); 00274 } else { 00275 snprintf(outbuf, maxout, "%c[%d;%dm", ESC, attr, fgcolor); 00276 } 00277 00278 return outbuf; 00279 }
| char* term_end | ( | void | ) |
Definition at line 358 of file term.c.
Referenced by ast_xmldoc_printable(), consolehandler(), and main().
00359 { 00360 return enddata; 00361 }
| void term_filter_escapes | ( | char * | line | ) |
Definition at line 331 of file term.c.
Referenced by ast_log().
00332 { 00333 int i; 00334 int len = strlen(line); 00335 00336 for (i = 0; i < len; i++) { 00337 if (line[i] != ESC) 00338 continue; 00339 if ((i < (len - 2)) && 00340 (line[i + 1] == 0x5B)) { 00341 switch (line[i + 2]) { 00342 case 0x30: 00343 case 0x31: 00344 case 0x33: 00345 continue; 00346 } 00347 } 00348 /* replace ESC with a space */ 00349 line[i] = ' '; 00350 } 00351 }
| char* term_prep | ( | void | ) |
| char* term_prompt | ( | char * | outbuf, | |
| const char * | inbuf, | |||
| int | maxout | |||
| ) |
Definition at line 302 of file term.c.
References ast_copy_string(), ast_opt_force_black_background, ast_opt_light_background, ATTR_BRIGHT, COLOR_BLACK, COLOR_BLUE, COLOR_WHITE, and ESC.
00303 { 00304 if (!vt100compat) { 00305 ast_copy_string(outbuf, inbuf, maxout); 00306 return outbuf; 00307 } 00308 if (ast_opt_force_black_background) { 00309 snprintf(outbuf, maxout, "%c[%d;%dm%c%c[%d;%dm%s", 00310 ESC, COLOR_BLUE, COLOR_BLACK + 10, 00311 inbuf[0], 00312 ESC, COLOR_WHITE, COLOR_BLACK + 10, 00313 inbuf + 1); 00314 } else if (ast_opt_light_background) { 00315 snprintf(outbuf, maxout, "%c[%d;0m%c%c[%d;0m%s", 00316 ESC, COLOR_BLUE, 00317 inbuf[0], 00318 ESC, COLOR_BLACK, 00319 inbuf + 1); 00320 } else { 00321 snprintf(outbuf, maxout, "%c[%d;%d;0m%c%c[%d;%d;0m%s", 00322 ESC, ATTR_BRIGHT, COLOR_BLUE, 00323 inbuf[0], 00324 ESC, 0, COLOR_WHITE, 00325 inbuf + 1); 00326 } 00327 return outbuf; 00328 }
| char* term_quit | ( | void | ) |
Definition at line 363 of file term.c.
Referenced by ast_el_read_char(), main(), and quit_handler().
00364 { 00365 return quitdata; 00366 }
| char* term_strip | ( | char * | outbuf, | |
| char * | inbuf, | |||
| int | maxout | |||
| ) |
Definition at line 281 of file term.c.
References ESC.
Referenced by __verboser(), action_command(), ast_log_vsyslog(), and logger_print_normal().
00282 { 00283 char *outbuf_ptr = outbuf, *inbuf_ptr = inbuf; 00284 00285 while (outbuf_ptr < outbuf + maxout) { 00286 switch (*inbuf_ptr) { 00287 case ESC: 00288 while (*inbuf_ptr && (*inbuf_ptr != 'm')) 00289 inbuf_ptr++; 00290 break; 00291 default: 00292 *outbuf_ptr = *inbuf_ptr; 00293 outbuf_ptr++; 00294 } 00295 if (! *inbuf_ptr) 00296 break; 00297 inbuf_ptr++; 00298 } 00299 return outbuf; 00300 }
1.5.9