diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-07-14 03:29:29 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-07-14 03:29:29 +0200 |
commit | 45e2f9a5c6a8ac29ce9fa1bf2e18343098c4a050 (patch) | |
tree | f153a392222863bfdec8f1b8b79da28710aa5790 /src/interface-curses.h | |
parent | c39b54543c81fefdf30a67caac9a86f9f8ecd215 (diff) | |
download | sciteco-45e2f9a5c6a8ac29ce9fa1bf2e18343098c4a050.tar.gz |
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.
Diffstat (limited to 'src/interface-curses.h')
-rw-r--r-- | src/interface-curses.h | 26 |
1 files changed, 14 insertions, 12 deletions
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<InterfaceCurses, ViewCurses> { */ 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<InterfaceCurses, ViewCurses> { } 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); |