Ignore:
Timestamp:
Nov 14, 2006, 12:42:43 AM (13 years ago)
Author:
Sam Hocevar
Message:
  • Factored terminal title setting code.
  • Do not try to set the terminal title if TERM=linux.
Location:
libcaca/trunk/caca
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/caca_internals.h

    r1208 r1392  
    157157#endif
    158158
     159/* Internal window functions */
     160extern void _caca_set_term_title(char const *);
     161
    159162#endif /* __CACA_INTERNALS_H__ */
  • libcaca/trunk/caca/driver_ncurses.c

    r1391 r1392  
    6060static void ncurses_check_terminal(void);
    6161#endif
    62 static void ncurses_set_title(char const *);
    6362static void ncurses_write_utf32(uint32_t);
    6463
     
    111110#endif
    112111
    113     ncurses_set_title("caca for ncurses");
     112    _caca_set_term_title("caca for ncurses");
    114113
    115114    initscr();
     
    170169static int ncurses_end_graphics(caca_display_t *dp)
    171170{
    172     ncurses_set_title("");
     171    _caca_set_term_title("");
    173172    mousemask(dp->drv.p->oldmask, NULL);
    174173    curs_set(1);
     
    183182static int ncurses_set_display_title(caca_display_t *dp, char const *title)
    184183{
    185     ncurses_set_title(title);
     184    _caca_set_term_title(title);
    186185
    187186    return 0;
     
    436435#endif
    437436
    438 static void ncurses_set_title(char const *str)
    439 {
    440     fprintf(stdout, "\x1b]0;%s\x07\n", str);
    441     fflush(stdout);
    442 }
    443 
    444437static void ncurses_write_utf32(uint32_t ch)
    445438{
  • libcaca/trunk/caca/driver_slang.c

    r1391 r1392  
    104104 */
    105105static void slang_init_palette(void);
    106 static void slang_set_title(char const *);
    107106static void slang_write_utf32(uint32_t);
    108107
     
    126125#endif
    127126
    128     slang_set_title("caca for S-Lang");
     127    _caca_set_term_title("caca for S-Lang");
    129128
    130129    /* Initialise slang library */
     
    176175static int slang_end_graphics(caca_display_t *dp)
    177176{
    178     slang_set_title("");
     177    _caca_set_term_title("");
    179178    SLtt_set_mouse_mode(0, 0);
    180179    SLtt_set_cursor_visibility(1);
     
    187186static int slang_set_display_title(caca_display_t *dp, char const *title)
    188187{
    189     slang_set_title(title);
     188    _caca_set_term_title(title);
    190189
    191190    return 0;
     
    448447}
    449448
    450 static void slang_set_title(char const *str)
    451 {
    452     fprintf(stdout, "\x1b]0;%s\x07\n", str);
    453     fflush(stdout);
    454 }
    455 
    456449static void slang_write_utf32(uint32_t ch)
    457450{
  • libcaca/trunk/caca/graphics.c

    r1391 r1392  
    1818#include "config.h"
    1919#include "common.h"
     20
     21#if !defined(__KERNEL__)
     22#   include <stdio.h>
     23#   include <stdlib.h>
     24#   include <string.h>
     25#endif
    2026
    2127#include "caca.h"
     
    209215}
    210216
     217void _caca_set_term_title(char const *str)
     218{
     219#if defined(HAVE_GETENV)
     220    char *term;
     221
     222    term = getenv("TERM");
     223
     224    if(!term || !strcmp(term, "linux"))
     225        return;
     226#endif
     227
     228    fprintf(stdout, "\x1b]0;%s\x07", str);
     229    fflush(stdout);
     230}
     231
Note: See TracChangeset for help on using the changeset viewer.