[vlc-commits] commit: ncurses: Use a table to store color pairs ( Rafaël Carré )
git at videolan.org
git at videolan.org
Tue Oct 26 14:03:37 CEST 2010
vlc | branch: master | Rafaël Carré <rafael.carre at gmail.com> | Mon Oct 25 22:52:01 2010 +0200| [1b61f9b44dc56b13f3a5103ecc49b228a069e41f] | committer: Rafaël Carré
ncurses: Use a table to store color pairs
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1b61f9b44dc56b13f3a5103ecc49b228a069e41f
---
modules/gui/ncurses.c | 72 ++++++++++++++++++++++++++----------------------
1 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c
index ac433a1..e23e3c2 100644
--- a/modules/gui/ncurses.c
+++ b/modules/gui/ncurses.c
@@ -119,13 +119,49 @@ enum
C_PLAYLIST_3,
C_BOX,
C_STATUS,
+#if 0
C_INFO,
C_ERROR,
C_WARNING,
C_DEBUG,
+#endif
C_CATEGORY,
- C_FOLDER
+ C_FOLDER,
+ /* new elements here ! */
+
+ C_MAX
};
+
+
+/* Available colors: BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE */
+static const struct { short f; short b; } color_pairs[] =
+{
+ /* element */ /* foreground*/ /* background*/
+ [C_TITLE] = { COLOR_YELLOW, COLOR_BLACK },
+
+ /* jamaican playlist */
+ [C_PLAYLIST_1] = { COLOR_GREEN, COLOR_BLACK },
+ [C_PLAYLIST_2] = { COLOR_YELLOW, COLOR_BLACK },
+ [C_PLAYLIST_3] = { COLOR_RED, COLOR_BLACK },
+
+ /* used in DrawBox() */
+ [C_BOX] = { COLOR_CYAN, COLOR_BLACK },
+ /* Source: State, Position, Volume, Chapters, etc...*/
+ [C_STATUS] = { COLOR_BLUE, COLOR_BLACK },
+
+#if 0
+ /* VLC messages, keep the order from highest priority to lowest */
+ [C_INFO] = { COLOR_BLACK, COLOR_WHITE },
+ [C_ERROR] = { COLOR_RED, COLOR_BLACK },
+ [C_WARNING] = { COLOR_YELLOW, COLOR_BLACK },
+ [C_DEBUG] = { COLOR_WHITE, COLOR_BLACK },
+#endif
+ /* Category title: help, info, metadata */
+ [C_CATEGORY] = { COLOR_MAGENTA, COLOR_BLACK },
+ /* Folder (BOX_BROWSE) */
+ [C_FOLDER] = { COLOR_RED, COLOR_BLACK },
+};
+
enum
{
VIEW_CATEGORY,
@@ -493,43 +529,13 @@ static void start_color_and_pairs(intf_thread_t *p_intf)
}
start_color();
-
- /* Available colors: BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE */
+ for(int i = C_DEFAULT + 1; i < C_MAX; i++)
+ init_pair(i, color_pairs[i].f, color_pairs[i].b);
/* untested, in all my terminals, !can_change_color() --funman */
if (can_change_color())
init_color(COLOR_YELLOW, 960, 500, 0); /* YELLOW -> ORANGE */
- /* title */
- init_pair(C_TITLE, COLOR_YELLOW, COLOR_BLACK);
-
- /* jamaican playlist */
- init_pair(C_PLAYLIST_1, COLOR_GREEN, COLOR_BLACK);
- init_pair(C_PLAYLIST_2, COLOR_YELLOW, COLOR_BLACK);
- init_pair(C_PLAYLIST_3, COLOR_RED, COLOR_BLACK);
-
- /* used in DrawBox() */
- init_pair(C_BOX, COLOR_CYAN, COLOR_BLACK);
- /* Source, State, Position, Volume, Chapters, etc...*/
- init_pair(C_STATUS, COLOR_BLUE, COLOR_BLACK);
-
- /* VLC messages, keep the order from highest priority to lowest */
-
- /* infos */
- init_pair(C_INFO, COLOR_BLACK, COLOR_WHITE);
- /* errors */
- init_pair(C_ERROR, COLOR_RED, COLOR_BLACK);
- /* warnings */
- init_pair(C_WARNING, COLOR_YELLOW, COLOR_BLACK);
-/* debug */
- init_pair(C_DEBUG, COLOR_WHITE, COLOR_BLACK);
-
- /* Category title (help, info, metadata) */
- init_pair(C_CATEGORY, COLOR_MAGENTA, COLOR_BLACK);
-
- /* Folder (BOX_BROWSE) */
- init_pair(C_FOLDER, COLOR_RED, COLOR_BLACK);
-
p_intf->p_sys->b_color_started = true;
}
More information about the vlc-commits
mailing list