diff options
Diffstat (limited to 'contrib/dialog/rc.c')
-rw-r--r-- | contrib/dialog/rc.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/contrib/dialog/rc.c b/contrib/dialog/rc.c index 2e2c7e6..cc6af29 100644 --- a/contrib/dialog/rc.c +++ b/contrib/dialog/rc.c @@ -1,5 +1,5 @@ /* - * $Id: rc.c,v 1.47 2011/06/20 22:30:04 tom Exp $ + * $Id: rc.c,v 1.49 2011/10/15 00:56:44 tom Exp $ * * rc.c -- routines for processing the configuration file * @@ -203,9 +203,10 @@ attr_to_str(char *str, int fg, int bg, int hl) /* * Extract the foreground, background and highlight values from an attribute - * represented as a string in this form: + * represented as a string in one of two forms: * * "(foreground,background,highlight)" + " "xxxx_color" */ static int str_to_attr(char *str, int *fg, int *bg, int *hl) @@ -214,8 +215,15 @@ str_to_attr(char *str, int *fg, int *bg, int *hl) unsigned j; char tempstr[MAX_LEN + 1], *part; - if (str[0] != '(' || lastch(str) != ')') + if (str[0] != '(' || lastch(str) != ')') { + if ((i = find_color(str)) >= 0) { + *fg = dlg_color_table[i].fg; + *bg = dlg_color_table[i].bg; + *hl = dlg_color_table[i].hilite; + return 0; + } return -1; /* invalid representation */ + } /* remove the parenthesis */ strcpy(tempstr, str + 1); @@ -424,13 +432,29 @@ dlg_create_rc(const char *filename) #ifdef HAVE_COLOR for (i = 0; i < (unsigned) dlg_color_count(); ++i) { char buffer[MAX_LEN + 1]; + unsigned j; + bool repeat = FALSE; fprintf(rc_file, "\n# %s\n", dlg_color_table[i].comment); - fprintf(rc_file, "%s = %s\n", dlg_color_table[i].name, - attr_to_str(buffer, - dlg_color_table[i].fg, - dlg_color_table[i].bg, - dlg_color_table[i].hilite)); + for (j = 0; j != i; ++j) { + if (dlg_color_table[i].fg == dlg_color_table[j].fg + && dlg_color_table[i].bg == dlg_color_table[j].bg + && dlg_color_table[i].hilite == dlg_color_table[j].hilite) { + fprintf(rc_file, "%s = %s\n", + dlg_color_table[i].name, + dlg_color_table[j].name); + repeat = TRUE; + break; + } + } + + if (!repeat) { + fprintf(rc_file, "%s = %s\n", dlg_color_table[i].name, + attr_to_str(buffer, + dlg_color_table[i].fg, + dlg_color_table[i].bg, + dlg_color_table[i].hilite)); + } } #endif /* HAVE_COLOR */ dlg_dump_keys(rc_file); @@ -507,7 +531,10 @@ dlg_parse_rc(void) lastch(str) = '\0'; if (begins_with(str, "bindkey", ¶ms)) { - dlg_parse_bindkey(params); + if (!dlg_parse_bindkey(params)) { + fprintf(stderr, "\nParse error: line %d of configuration\n", l); + result = -1; + } continue; } parse = parse_line(str, &var, &value); /* parse current line */ |