1
1

Improving some comments and renaming three variables.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5497 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
Benno Schulenberg 2015-12-18 18:44:40 +00:00
родитель 4fc16848fa
Коммит d63912947a
2 изменённых файлов: 23 добавлений и 18 удалений

Просмотреть файл

@ -1,5 +1,6 @@
2015-12-18 Benno Schulenberg <bensberg@justemail.net> 2015-12-18 Benno Schulenberg <bensberg@justemail.net>
* src/color.c (color_init): Use less #ifdefs, and adjust indentation. * src/color.c (color_init): Use less #ifdefs, and adjust indentation.
* src/color.c (set_colorpairs): Improve comments and rename vars.
2015-12-11 Benno Schulenberg <bensberg@justemail.net> 2015-12-11 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/Makefile.am: Add missing autoconf and nftables syntaxes. * doc/syntax/Makefile.am: Add missing autoconf and nftables syntaxes.

Просмотреть файл

@ -34,31 +34,34 @@
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
/* For each syntax list entry, go through the list of colors and assign /* Initialize the colors for nano's interface, and assign pair numbers
* the color pairs. */ * for the colors in each syntax. */
void set_colorpairs(void) void set_colorpairs(void)
{ {
const syntaxtype *this_syntax = syntaxes; const syntaxtype *this_syntax = syntaxes;
bool defok = FALSE; bool using_defaults = FALSE;
short fg, bg; short foreground, background;
size_t i; size_t i;
/* Tell ncurses to enable colors. */
start_color(); start_color();
#ifdef HAVE_USE_DEFAULT_COLORS #ifdef HAVE_USE_DEFAULT_COLORS
/* Use the default colors, if available. */ /* Allow using the default colors, if available. */
defok = (use_default_colors() != ERR); using_defaults = (use_default_colors() != ERR);
#endif #endif
/* Initialize the color pairs for nano's interface elements. */
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) { for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
bool bright = FALSE; bool bright = FALSE;
if (parse_color_names(specified_color_combo[i], &fg, &bg, &bright)) { if (parse_color_names(specified_color_combo[i],
if (fg == -1 && !defok) &foreground, &background, &bright)) {
fg = COLOR_WHITE; if (foreground == -1 && !using_defaults)
if (bg == -1 && !defok) foreground = COLOR_WHITE;
bg = COLOR_BLACK; if (background == -1 && !using_defaults)
init_pair(i + 1, fg, bg); background = COLOR_BLACK;
init_pair(i + 1, foreground, background);
interface_color_pair[i].bright = bright; interface_color_pair[i].bright = bright;
interface_color_pair[i].pairnum = COLOR_PAIR(i + 1); interface_color_pair[i].pairnum = COLOR_PAIR(i + 1);
} }
@ -74,6 +77,8 @@ void set_colorpairs(void)
specified_color_combo[i] = NULL; specified_color_combo[i] = NULL;
} }
/* For each syntax, go through its list of colors and assign each
* its pair number, giving identical color pairs the same number. */
for (; this_syntax != NULL; this_syntax = this_syntax->next) { for (; this_syntax != NULL; this_syntax = this_syntax->next) {
colortype *this_color = this_syntax->color; colortype *this_color = this_syntax->color;
int clr_pair = NUMBER_OF_ELEMENTS + 1; int clr_pair = NUMBER_OF_ELEMENTS + 1;
@ -81,12 +86,11 @@ void set_colorpairs(void)
for (; this_color != NULL; this_color = this_color->next) { for (; this_color != NULL; this_color = this_color->next) {
const colortype *beforenow = this_syntax->color; const colortype *beforenow = this_syntax->color;
for (; beforenow != this_color && while (beforenow != this_color &&
(beforenow->fg != this_color->fg || (beforenow->fg != this_color->fg ||
beforenow->bg != this_color->bg || beforenow->bg != this_color->bg ||
beforenow->bright != this_color->bright); beforenow->bright != this_color->bright))
beforenow = beforenow->next) beforenow = beforenow->next;
;
if (beforenow != this_color) if (beforenow != this_color)
this_color->pairnum = beforenow->pairnum; this_color->pairnum = beforenow->pairnum;