* edit.h (struct key_word): Remove unused "bg" field, rename

"fg" to	"color", since it keeps all color information.
* syntax.c (edit_get_syntax_color): Replace "fg" and "bg"
arguments with a single argument "color".
Adjust all dependencies.
This commit is contained in:
Pavel Roskin 2002-07-14 17:56:47 +00:00
parent 5f771b594e
commit a23618b2ef
6 changed files with 25 additions and 26 deletions

View File

@ -1,5 +1,11 @@
2002-07-14 Pavel Roskin <proski@gnu.org>
* edit.h (struct key_word): Remove unused "bg" field, rename
"fg" to "color", since it keeps all color information.
* syntax.c (edit_get_syntax_color): Replace "fg" and "bg"
arguments with a single argument "color".
Adjust all dependencies.
* editdraw.c (edit_draw_this_line): Fix setting MOD_ABNORMAL
attribute.
(print_to_widget): Fix displaying non-printable characters with

View File

@ -565,8 +565,8 @@ WEdit *edit_init (WEdit * edit, int lines, int columns, const char *filename, co
edit->modified = 0;
edit_load_syntax (edit, 0, 0);
{
int fg, bg;
edit_get_syntax_color (edit, -1, &fg, &bg);
int color;
edit_get_syntax_color (edit, -1, &color);
}
return edit;
}

View File

@ -168,8 +168,7 @@ struct key_word {
#define NO_COLOR 0x7FFFFFFF
#define SPELLING_ERROR 0x7EFEFEFE
int line_start;
int bg;
int fg;
int color;
};
struct context_rule {
@ -310,7 +309,7 @@ void edit_split_filename (WEdit * edit, const char *name);
void edit_set_syntax_change_callback (void (*callback) (CWidget *));
void edit_load_syntax (WEdit * edit, char **names, char *type);
void edit_free_syntax_rules (WEdit * edit);
void edit_get_syntax_color (WEdit * edit, long byte_index, int *fg, int *bg);
void edit_get_syntax_color (WEdit * edit, long byte_index, int *color);
int edit_check_spelling (WEdit * edit);

View File

@ -155,8 +155,8 @@ void edit_refresh_cmd (WEdit * edit)
do_refresh();
#else
{
int fg, bg;
edit_get_syntax_color (edit, -1, &fg, &bg);
int color;
edit_get_syntax_color (edit, -1, &color);
}
touchwin(stdscr);
#endif /* !HAVE_SLANG */

View File

@ -243,7 +243,7 @@ static void edit_draw_this_line (WEdit * edit, long b, long row, long start_col,
long m1 = 0, m2 = 0, q, c1, c2;
int col, start_col_real;
unsigned int c;
int fg, bg;
int color;
int i, book_mark = -1;
#if 0
@ -251,7 +251,7 @@ static void edit_draw_this_line (WEdit * edit, long b, long row, long start_col,
book_mark = -1;
#endif
edit_get_syntax_color (edit, b - 1, &fg, &bg);
edit_get_syntax_color (edit, b - 1, &color);
q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
start_col_real = (col = (int) edit_move_forward3 (edit, b, 0, q)) + edit->start_col;
c1 = min (edit->column1, edit->column2);
@ -281,8 +281,8 @@ static void edit_draw_this_line (WEdit * edit, long b, long row, long start_col,
c = edit_get_byte (edit, q);
/* we don't use bg for mc - fg contains both */
if (book_mark == -1) {
edit_get_syntax_color (edit, q, &fg, &bg);
*p |= fg << 16;
edit_get_syntax_color (edit, q, &color);
*p |= color << 16;
} else {
*p |= book_mark << 16;
}

View File

@ -45,11 +45,6 @@
int option_syntax_highlighting = 1;
int option_auto_spellcheck = 1;
/* these three functions are called from the outside */
void edit_load_syntax (WEdit * edit, char **names, char *type);
void edit_free_syntax_rules (WEdit * edit);
void edit_get_syntax_color (WEdit * edit, long byte_index, int *fg, int *bg);
#ifdef HAVE_MAD
static void *mad_syntax_malloc (size_t x, char *file, int line)
#define syntax_malloc(x) mad_syntax_malloc (x, __FILE__, __LINE__)
@ -363,23 +358,22 @@ static struct syntax_rule edit_get_rule (WEdit * edit, long byte_index)
return edit->rule;
}
static void translate_rule_to_color (WEdit * edit, struct syntax_rule rule, int *fg, int *bg)
static void translate_rule_to_color (WEdit * edit, struct syntax_rule rule, int *color)
{
struct key_word *k;
k = edit->rules[rule.context]->keyword[rule.keyword];
*bg = k->bg;
*fg = k->fg;
*color = k->color;
}
extern int use_colors;
void edit_get_syntax_color (WEdit * edit, long byte_index, int *fg, int *bg)
void edit_get_syntax_color (WEdit * edit, long byte_index, int *color)
{
if (edit->rules && byte_index < edit->last_byte &&
option_syntax_highlighting && use_colors) {
translate_rule_to_color (edit, edit_get_rule (edit, byte_index), fg, bg);
translate_rule_to_color (edit, edit_get_rule (edit, byte_index), color);
} else {
*fg = EDITOR_NORMAL_COLOR;
*color = EDITOR_NORMAL_COLOR;
}
}
@ -712,7 +706,7 @@ static int edit_read_syntax_rules (WEdit * edit, FILE * f)
a++;
strcpy (last_fg, fg ? fg : "");
strcpy (last_bg, bg ? bg : "");
c->keyword[0]->fg = this_try_alloc_color_pair (fg, bg);
c->keyword[0]->color = this_try_alloc_color_pair (fg, bg);
c->keyword[0]->keyword = (char *) strdup (" ");
check_not_a;
num_contexts++;
@ -760,7 +754,7 @@ static int edit_read_syntax_rules (WEdit * edit, FILE * f)
fg = last_fg;
if (!bg)
bg = last_bg;
k->fg = this_try_alloc_color_pair (fg, bg);
k->color = this_try_alloc_color_pair (fg, bg);
check_not_a;
num_words++;
} else if (!strncmp (args[0], "#", 1)) {
@ -1021,9 +1015,9 @@ void edit_free_syntax_rules (WEdit * edit)
return;
}
void edit_get_syntax_color (WEdit * edit, long byte_index, int *fg, int *bg)
void edit_get_syntax_color (WEdit * edit, long byte_index, int *color)
{
*fg = EDITOR_NORMAL_COLOR;
*color = EDITOR_NORMAL_COLOR;
}
int edit_check_spelling (WEdit * edit)