* Do not try to set the terminal title if TERM=linux.tags/v0.99.beta14
| @@ -156,4 +156,7 @@ extern void _push_event(caca_display_t *, caca_event_t *); | |||||
| extern int _pop_event(caca_display_t *, caca_event_t *); | extern int _pop_event(caca_display_t *, caca_event_t *); | ||||
| #endif | #endif | ||||
| /* Internal window functions */ | |||||
| extern void _caca_set_term_title(char const *); | |||||
| #endif /* __CACA_INTERNALS_H__ */ | #endif /* __CACA_INTERNALS_H__ */ | ||||
| @@ -59,7 +59,6 @@ static caca_display_t *sigwinch_d; /* FIXME: we ought to get rid of this */ | |||||
| #if defined HAVE_GETENV && defined HAVE_PUTENV | #if defined HAVE_GETENV && defined HAVE_PUTENV | ||||
| static void ncurses_check_terminal(void); | static void ncurses_check_terminal(void); | ||||
| #endif | #endif | ||||
| static void ncurses_set_title(char const *); | |||||
| static void ncurses_write_utf32(uint32_t); | static void ncurses_write_utf32(uint32_t); | ||||
| struct driver_private | struct driver_private | ||||
| @@ -110,7 +109,7 @@ static int ncurses_init_graphics(caca_display_t *dp) | |||||
| setlocale(LC_ALL, ""); | setlocale(LC_ALL, ""); | ||||
| #endif | #endif | ||||
| ncurses_set_title("caca for ncurses"); | |||||
| _caca_set_term_title("caca for ncurses"); | |||||
| initscr(); | initscr(); | ||||
| keypad(stdscr, TRUE); | keypad(stdscr, TRUE); | ||||
| @@ -169,7 +168,7 @@ static int ncurses_init_graphics(caca_display_t *dp) | |||||
| static int ncurses_end_graphics(caca_display_t *dp) | static int ncurses_end_graphics(caca_display_t *dp) | ||||
| { | { | ||||
| ncurses_set_title(""); | |||||
| _caca_set_term_title(""); | |||||
| mousemask(dp->drv.p->oldmask, NULL); | mousemask(dp->drv.p->oldmask, NULL); | ||||
| curs_set(1); | curs_set(1); | ||||
| noraw(); | noraw(); | ||||
| @@ -182,7 +181,7 @@ static int ncurses_end_graphics(caca_display_t *dp) | |||||
| static int ncurses_set_display_title(caca_display_t *dp, char const *title) | static int ncurses_set_display_title(caca_display_t *dp, char const *title) | ||||
| { | { | ||||
| ncurses_set_title(title); | |||||
| _caca_set_term_title(title); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -435,12 +434,6 @@ static void ncurses_check_terminal(void) | |||||
| } | } | ||||
| #endif | #endif | ||||
| static void ncurses_set_title(char const *str) | |||||
| { | |||||
| fprintf(stdout, "\x1b]0;%s\x07\n", str); | |||||
| fflush(stdout); | |||||
| } | |||||
| static void ncurses_write_utf32(uint32_t ch) | static void ncurses_write_utf32(uint32_t ch) | ||||
| { | { | ||||
| #if defined HAVE_NCURSESW_NCURSES_H | #if defined HAVE_NCURSESW_NCURSES_H | ||||
| @@ -103,7 +103,6 @@ static int const slang_assoc[16*16] = | |||||
| * Local functions | * Local functions | ||||
| */ | */ | ||||
| static void slang_init_palette(void); | static void slang_init_palette(void); | ||||
| static void slang_set_title(char const *); | |||||
| static void slang_write_utf32(uint32_t); | static void slang_write_utf32(uint32_t); | ||||
| #if defined(HAVE_SIGNAL) | #if defined(HAVE_SIGNAL) | ||||
| @@ -125,7 +124,7 @@ static int slang_init_graphics(caca_display_t *dp) | |||||
| signal(SIGWINCH, sigwinch_handler); | signal(SIGWINCH, sigwinch_handler); | ||||
| #endif | #endif | ||||
| slang_set_title("caca for S-Lang"); | |||||
| _caca_set_term_title("caca for S-Lang"); | |||||
| /* Initialise slang library */ | /* Initialise slang library */ | ||||
| SLsig_block_signals(); | SLsig_block_signals(); | ||||
| @@ -175,7 +174,7 @@ static int slang_init_graphics(caca_display_t *dp) | |||||
| static int slang_end_graphics(caca_display_t *dp) | static int slang_end_graphics(caca_display_t *dp) | ||||
| { | { | ||||
| slang_set_title(""); | |||||
| _caca_set_term_title(""); | |||||
| SLtt_set_mouse_mode(0, 0); | SLtt_set_mouse_mode(0, 0); | ||||
| SLtt_set_cursor_visibility(1); | SLtt_set_cursor_visibility(1); | ||||
| SLang_reset_tty(); | SLang_reset_tty(); | ||||
| @@ -186,7 +185,7 @@ static int slang_end_graphics(caca_display_t *dp) | |||||
| static int slang_set_display_title(caca_display_t *dp, char const *title) | static int slang_set_display_title(caca_display_t *dp, char const *title) | ||||
| { | { | ||||
| slang_set_title(title); | |||||
| _caca_set_term_title(title); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -447,12 +446,6 @@ static void slang_init_palette(void) | |||||
| #endif | #endif | ||||
| } | } | ||||
| static void slang_set_title(char const *str) | |||||
| { | |||||
| fprintf(stdout, "\x1b]0;%s\x07\n", str); | |||||
| fflush(stdout); | |||||
| } | |||||
| static void slang_write_utf32(uint32_t ch) | static void slang_write_utf32(uint32_t ch) | ||||
| { | { | ||||
| #ifdef HAVE_SLSMG_UTF8_ENABLE | #ifdef HAVE_SLSMG_UTF8_ENABLE | ||||
| @@ -18,6 +18,12 @@ | |||||
| #include "config.h" | #include "config.h" | ||||
| #include "common.h" | #include "common.h" | ||||
| #if !defined(__KERNEL__) | |||||
| # include <stdio.h> | |||||
| # include <stdlib.h> | |||||
| # include <string.h> | |||||
| #endif | |||||
| #include "caca.h" | #include "caca.h" | ||||
| #include "caca_internals.h" | #include "caca_internals.h" | ||||
| #include "cucul.h" | #include "cucul.h" | ||||
| @@ -208,3 +214,18 @@ void _caca_handle_resize(caca_display_t *dp) | |||||
| _cucul_set_canvas_size(dp->cv, dp->resize.w, dp->resize.h); | _cucul_set_canvas_size(dp->cv, dp->resize.w, dp->resize.h); | ||||
| } | } | ||||
| void _caca_set_term_title(char const *str) | |||||
| { | |||||
| #if defined(HAVE_GETENV) | |||||
| char *term; | |||||
| term = getenv("TERM"); | |||||
| if(!term || !strcmp(term, "linux")) | |||||
| return; | |||||
| #endif | |||||
| fprintf(stdout, "\x1b]0;%s\x07", str); | |||||
| fflush(stdout); | |||||
| } | |||||