Moved dir $(srcdir)/syntax into $(srcdir)/misc/syntax
[midnight-commander.git] / src / tty / color-internal.c
blob11a4f43d117a7f860b032cbd85b1fb91005a6537
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 "../../src/tty/color.h" /* colors and attributes */
32 #include "../../src/tty/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 {
43 const char *name;
44 int value;
45 } mc_tty_color_table_t;
47 /*** file scope variables ************************************************************************/
49 mc_tty_color_table_t const color_table[] = {
50 { "black", COLOR_BLACK },
51 { "gray", COLOR_BLACK | A_BOLD },
52 { "red", COLOR_RED },
53 { "brightred", COLOR_RED | A_BOLD },
54 { "green", COLOR_GREEN },
55 { "brightgreen", COLOR_GREEN | A_BOLD },
56 { "brown", COLOR_YELLOW },
57 { "yellow", COLOR_YELLOW | A_BOLD },
58 { "blue", COLOR_BLUE },
59 { "brightblue", COLOR_BLUE | A_BOLD },
60 { "magenta", COLOR_MAGENTA },
61 { "brightmagenta", COLOR_MAGENTA | A_BOLD },
62 { "cyan", COLOR_CYAN },
63 { "brightcyan", COLOR_CYAN | A_BOLD },
64 { "lightgray", COLOR_WHITE },
65 { "white", COLOR_WHITE | A_BOLD },
66 { "default", -1 }, /* default color of the terminal */
67 /* special colors */
68 { "A_REVERSE", SPEC_A_REVERSE },
69 { "A_BOLD", SPEC_A_BOLD},
70 { "A_BOLD_REVERSE", SPEC_A_BOLD_REVERSE },
71 { "A_UNDERLINE", SPEC_A_UNDERLINE },
72 /* End of list */
73 { NULL, 0}
76 /*** file scope functions ************************************************************************/
77 /* --------------------------------------------------------------------------------------------- */
79 /*** public functions ****************************************************************************/
80 /* --------------------------------------------------------------------------------------------- */
82 const char *
83 tty_color_get_valid_name (const char *color_name)
85 int i;
87 if (color_name != NULL)
88 for (i = 0; color_table[i].name != NULL; i++)
89 if (strcmp (color_name, color_table[i].name) == 0)
90 return color_table[i].name;
91 return NULL;
94 /* --------------------------------------------------------------------------------------------- */
96 int
97 tty_color_get_index_by_name (const char *color_name)
99 int i;
101 if (color_name != NULL)
102 for (i = 0; color_table[i].name != NULL; i++)
103 if (strcmp (color_name, color_table[i].name) == 0)
104 return color_table[i].value;
105 return -1;
108 /* --------------------------------------------------------------------------------------------- */