From 45e2f9a5c6a8ac29ce9fa1bf2e18343098c4a050 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 14 Jul 2015 03:29:29 +0200 Subject: curses UI: support terminal palette restoration on PDCurses/win32 and xterm * palette changes are persistent on PDCurses/win32, too. Fortunately, on this port we can reliably query the console palette. This is done ONLY on PDcurses/win32 since on other ports (notably ncurses), this can cause more harm than it helps. * support palette restoration on xterm by hardcoding the appropriate escape sequence. $TERM cannot be used to identify xterm, but looking at $XTERM_VERSION is sufficient hopefully. --- src/interface-curses.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/interface-curses.h') diff --git a/src/interface-curses.h b/src/interface-curses.h index ca3ce04..b43069f 100644 --- a/src/interface-curses.h +++ b/src/interface-curses.h @@ -82,6 +82,16 @@ typedef class InterfaceCurses : public Interface { */ gint32 color_table[16]; + /** + * Mapping of the first 16 curses color codes to their + * original values for restoring them on shutdown. + * Unfortunately, this may not be supported on all + * curses ports, so this array may be unused. + */ + struct { + short r, g, b; + } orig_color_table[G_N_ELEMENTS(color_table)]; + int stdout_orig, stderr_orig; SCREEN *screen; FILE *screen_tty; @@ -110,18 +120,7 @@ typedef class InterfaceCurses : public Interface { } popup; public: - InterfaceCurses() : stdout_orig(-1), stderr_orig(-1), - screen(NULL), - screen_tty(NULL), - info_window(NULL), - info_current(NULL), - msg_window(NULL), - cmdline_window(NULL), cmdline_pad(NULL), - cmdline_len(0), cmdline_rubout_len(0) - { - for (guint i = 0; i < G_N_ELEMENTS(color_table); i++) - color_table[i] = -1; - } + InterfaceCurses(); ~InterfaceCurses(); /* implementation of Interface::main() */ @@ -163,6 +162,9 @@ public: void event_loop_impl(void); private: + void init_color_safe(guint color, guint32 rgb); + void restore_colors(void); + void init_screen(void); void init_interactive(void); void restore_batch(void); -- cgit v1.2.3