[vlc-commits] Restore ncurses colors on exit

Marc Aldorasi git at videolan.org
Sun Dec 29 23:01:50 CET 2013


vlc | branch: master | Marc Aldorasi <m101010a at gmail.com> | Sun Dec 29 13:33:22 2013 -0500| [497ce0b9ab35650fbfa8b9c850b1e925c139733d] | committer: Rafaël Carré

Restore ncurses colors on exit

If the terminal colors are not manually restored they will not change
back when vlc exits, causing other applications to use the wrong colors

Signed-off-by: Rafaël Carré <funman at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=497ce0b9ab35650fbfa8b9c850b1e925c139733d
---

 modules/gui/ncurses.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c
index bd59a60..f5a742b 100644
--- a/modules/gui/ncurses.c
+++ b/modules/gui/ncurses.c
@@ -185,6 +185,11 @@ struct intf_sys_t
     bool            color;
     bool            exit;
 
+    /* rgb values for the color yellow */
+    short           yellow_r;
+    short           yellow_g;
+    short           yellow_b;
+
     int             box_type;
     int             box_y;            // start of box content
     int             box_height;
@@ -529,8 +534,10 @@ static void FindIndex(intf_sys_t *sys, playlist_t *p_playlist)
 
 static void start_color_and_pairs(intf_thread_t *intf)
 {
+    intf_sys_t *sys = intf->p_sys;
+
     if (!has_colors()) {
-        intf->p_sys->color = false;
+        sys->color = false;
         msg_Warn(intf, "Terminal doesn't support colors");
         return;
     }
@@ -540,8 +547,10 @@ static void start_color_and_pairs(intf_thread_t *intf)
         init_pair(i, color_pairs[i].f, color_pairs[i].b);
 
     /* untested, in all my terminals, !can_change_color() --funman */
-    if (can_change_color())
+    if (can_change_color()) {
+        color_content(COLOR_YELLOW, &sys->yellow_r, &sys->yellow_g, &sys->yellow_b);
         init_color(COLOR_YELLOW, 960, 500, 0); /* YELLOW -> ORANGE */
+    }
 }
 
 static void DrawBox(int y, int h, bool color, const char *title)
@@ -1885,6 +1894,10 @@ static void Close(vlc_object_t *p_this)
     if (sys->p_input)
         vlc_object_release(sys->p_input);
 
+    if (can_change_color())
+        /* Restore yellow to its original color */
+        init_color(COLOR_YELLOW, sys->yellow_r, sys->yellow_g, sys->yellow_b);
+
     endwin();   /* Close the ncurses interface */
 
     vlc_LogSet(p_this->p_libvlc, NULL, NULL);



More information about the vlc-commits mailing list