Browse Source

- fixed color-output for dark terminals

- Hint: colorizations needs a fix to escape characters which will destroy terminal
tags/v0.1.1-beta
andreas.romeyke@slub-dresden.de 4 years ago
parent
commit
56242c364d
1 changed files with 49 additions and 26 deletions
  1. +49
    -26
      src/helper/check_renderer.c

+ 49
- 26
src/helper/check_renderer.c View File

@@ -18,24 +18,47 @@
#define DEBUG
*/

#define ANSI_RED "\033[22;31m"
#define ANSI_RED_BOLD "\033[01;31m"
#define ANSI_GREEN "\033[22;32m"
/* color definitions, using ISO 6429 as listed in 'man (5) dir_colors'
0 to restore default color
1 for brighter colors
4 for underlined text
5 for flashing text
30 for black foreground
31 for red foreground
32 for green foreground
33 for yellow (or brown) foreground
34 for blue foreground
35 for purple foreground
36 for cyan foreground
37 for white (or gray) foreground
40 for black background
41 for red background
42 for green background
43 for yellow (or brown) background
44 for blue background
45 for purple background
46 for cyan background
47 for white (or gray) background
*/
#define ANSI_NORMAL "\033[0m"
#define ANSI_BOLD "\033[1m"
#define ANSI_RED "\033[00;31m"
#define ANSI_RED_BOLD "\033[01;31m"
#define ANSI_GREEN "\033[00;32m"
#define ANSI_GREEN_BOLD "\033[01;32m"
#define ANSI_RESET "\033[22;30m"
#define ANSI_BLACK "\033[22;30m"
#define ANSI_RESET "\033[0m"
#define ANSI_BLACK "\033[00;30m"
#define ANSI_BLACK_BOLD "\033[01;30m"
#define ANSI_BROWN "\033[22;33m"
#define ANSI_BLUE "\033[22;34m"
#define ANSI_BLUE_BOLD "\033[01;34m"
#define ANSI_PURPLE "\033[22;35m"
#define ANSI_CYAN "\033[22;36m"
#define ANSI_GREY "\033[22;37m"
#define ANSI_DARK_GREY "\033[01;30m"
#define ANSI_YELLOW "\033[01;33m"
#define ANSI_WHITE "\033[01;37m"
#define ANSI_INVERSE "\033[7m"

#define ANSI_BROWN "\033[00;33m"
#define ANSI_BLUE "\033[00;34m"
#define ANSI_BLUE_BOLD "\033[01;34m"
#define ANSI_PURPLE "\033[00;35m"
#define ANSI_CYAN "\033[00;36m"
#define ANSI_GREY "\033[00;37m"
#define ANSI_DARK_GREY "\033[01;30m"
#define ANSI_YELLOW "\033[01;33m"
#define ANSI_WHITE "\033[01;37m"
#define ANSI_INVERSE "\033[7m"

render_type render_engine=render_default;

@@ -45,9 +68,6 @@ void set_renderer_to_ansi() {
}
}




const char * renderer_debug ( ret_t ret ) {
char res[1024] = "";
if (0 == ret.returncode) {
@@ -61,15 +81,15 @@ const char * renderer_debug ( ret_t ret ) {
int c = 0;
while (NULL != startp && c < ret.count) {
switch (startp->rm_type) {
case rm_rule: secstrcat( res, ANSI_RESET , 1024); break;
case rm_tag: secstrcat( res, ANSI_RED_BOLD , 1024); break;
case rm_rule: secstrcat( res, ANSI_NORMAL , 1024); break;
case rm_tag: secstrcat( res, ANSI_BOLD , 1024); break;
case rm_value: secstrcat( res, ANSI_BLUE , 1024); break;
case rm_expected: secstrcat( res, ANSI_RED , 1024); break;
case rm_hard_error: secstrcat( res, ANSI_RED_BOLD , 1024); break;
case rm_error: secstrcat( res, ANSI_RED , 1024); break;
case rm_warning: secstrcat( res, ANSI_YELLOW , 1024); break;
case rm_file: secstrcat( res, ANSI_BLUE_BOLD, 1024); break;
default: secstrcat( res, ANSI_INVERSE , 1024);
default: secstrcat( res, ANSI_INVERSE , 1024);
}
secstrcat(res, startp->rm_msg, 1024);
startp++;
@@ -111,21 +131,24 @@ const char * renderer_ansi ( ret_t ret ) {
int c = 0;
while (NULL != startp && c < ret.count) {
switch (startp->rm_type) {
case rm_rule: secstrcat( res, ANSI_RESET , 1024); break;
case rm_tag: secstrcat( res, ANSI_BLACK_BOLD, 1024); break;
case rm_rule: secstrcat( res, ANSI_NORMAL , 1024); break;
case rm_tag: secstrcat( res, ANSI_BOLD , 1024); break;
case rm_value: secstrcat( res, ANSI_BLUE , 1024); break;
case rm_expected: secstrcat( res, ANSI_RED , 1024); break;
case rm_hard_error: secstrcat( res, ANSI_RED_BOLD , 1024); break;
case rm_error: secstrcat( res, ANSI_RED , 1024); break;
case rm_warning: secstrcat( res, ANSI_YELLOW , 1024); break;
case rm_file: secstrcat( res, ANSI_BLUE_BOLD, 1024); break;
default: secstrcat( res, ANSI_RESET , 1024);
default: secstrcat( res, ANSI_NORMAL , 1024);
}
/* FIXME: replace all occurrences of a space, backslash, caret, or
any control character anywhere in the string, as well as a hash mark as
the first character. */
secstrcat(res, startp->rm_msg, 1024);
startp++;
c++;
}
secstrcat(res, ANSI_RESET, 1024);
secstrcat(res, ANSI_NORMAL, 1024);
secstrcat(res, "\n", 1024);
return strdup( res );
}


Loading…
Cancel
Save