po/ru.po: fixed plural forms.
[midnight-commander.git] / lib / tty / color-internal.c
blobd1ebe2e24dbe0e04d25ace27de194140401856ba
1 /* Internal stuff of color setup
2 Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2007, 2008, 2009 Free Software Foundation, Inc.
5 Written by:
6 Andrew Borodin <aborodin@vmail.ru>, 2009.
7 Slava Zanko <slavazanko@gmail.com>, 2009.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
23 /** \file color-internal.c
24 * \brief Source: Internal stuff of color setup
27 #include <config.h>
29 #include <string.h> /* strcmp */
31 #include "color.h" /* colors and attributes */
32 #include "color-internal.h"
34 /*** global variables ****************************************************************************/
36 gboolean mc_tty_color_disable;
38 /*** file scope macro definitions ****************************************************************/
40 /*** file scope type declarations ****************************************************************/
42 typedef struct mc_tty_color_table_struct
44 const char *name;
45 int value;
46 } mc_tty_color_table_t;
48 /*** file scope variables ************************************************************************/
50 mc_tty_color_table_t const color_table[] = {
51 {"black", COLOR_BLACK},
52 {"gray", COLOR_BLACK | A_BOLD},
53 {"red", COLOR_RED},
54 {"brightred", COLOR_RED | A_BOLD},
55 {"green", COLOR_GREEN},
56 {"brightgreen", COLOR_GREEN | A_BOLD},
57 {"brown", COLOR_YELLOW},
58 {"yellow", COLOR_YELLOW | A_BOLD},
59 {"blue", COLOR_BLUE},
60 {"brightblue", COLOR_BLUE | A_BOLD},
61 {"magenta", COLOR_MAGENTA},
62 {"brightmagenta", COLOR_MAGENTA | A_BOLD},
63 {"cyan", COLOR_CYAN},
64 {"brightcyan", COLOR_CYAN | A_BOLD},
65 {"lightgray", COLOR_WHITE},
66 {"white", COLOR_WHITE | A_BOLD},
67 {"default", -1}, /* default color of the terminal */
68 /* special colors */
69 {"A_REVERSE", SPEC_A_REVERSE},
70 {"A_BOLD", SPEC_A_BOLD},
71 {"A_BOLD_REVERSE", SPEC_A_BOLD_REVERSE},
72 {"A_UNDERLINE", SPEC_A_UNDERLINE},
73 /* End of list */
74 {NULL, 0}
77 /*** file scope functions ************************************************************************/
78 /* --------------------------------------------------------------------------------------------- */
80 /*** public functions ****************************************************************************/
81 /* --------------------------------------------------------------------------------------------- */
83 const char *
84 tty_color_get_valid_name (const char *color_name)
87 if (color_name != NULL)
89 size_t i;
90 for (i = 0; color_table[i].name != NULL; i++)
91 if (strcmp (color_name, color_table[i].name) == 0)
92 return color_table[i].name;
94 return NULL;
97 /* --------------------------------------------------------------------------------------------- */
99 int
100 tty_color_get_index_by_name (const char *color_name)
103 if (color_name != NULL)
105 size_t i;
106 for (i = 0; color_table[i].name != NULL; i++)
107 if (strcmp (color_name, color_table[i].name) == 0)
108 return color_table[i].value;
110 return -1;
113 /* --------------------------------------------------------------------------------------------- */