diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-03-15 18:33:31 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-03-15 18:33:31 +0000 |
commit | d2f5a95a9b6212c7f6ba462131b9d3e6aec94db5 (patch) | |
tree | be32bbac734f3ab34bb1f0dd46f83ba1dc9426cc /terms.c | |
parent | [w3m-dev 03132] Re: Reload image (diff) | |
download | w3m-d2f5a95a9b6212c7f6ba462131b9d3e6aec94db5.tar.gz w3m-d2f5a95a9b6212c7f6ba462131b9d3e6aec94db5.zip |
-title support
modified [w3m-dev-en 00710] contrib: unofficial "xterm title" patch, updated for w3m-0.3
by Moritz Barsnick <barsnick@gmx.net>
* NEWS: -title
* fm.h (displayTitleTerm): added
* proto.h (term_title): added
* main.c (fusage): add -title
(MAIN): add -title
(quitfm): term_title("")
* display.c (displayBuffer): term_title()
* terms.c (title_str): added
(TERM_INFO): added
(term_info): modified from mouse_term_info
(term_info_list): modified from xterm_mouse_term
add "screen"
(set_tty): check displayTitleTerm
(term_title): added
From: Fumitoshi UKAI <ukai@debian.or.jp>
Diffstat (limited to '')
-rw-r--r-- | terms.c | 64 |
1 files changed, 48 insertions, 16 deletions
@@ -1,4 +1,4 @@ -/* $Id: terms.c,v 1.28 2002/01/31 17:54:56 ukai Exp $ */ +/* $Id: terms.c,v 1.29 2002/03/15 18:33:32 ukai Exp $ */ /* * An original curses library for EUC-kanji by Akinori ITO, December 1989 * revised by Akinori ITO, January 1995 @@ -42,6 +42,8 @@ void mouse_init(), mouse_end(); int mouseActive = 0; #endif /* USE_MOUSE */ +static char *title_str = NULL; + static int tty; #include "terms.h" @@ -474,22 +476,34 @@ writestr(char *s) #define MOVE(line,column) writestr(tgoto(T_cm,column,line)); #ifdef USE_MOUSE -static struct mouse_term_info { +#define TERM_INFO(name, title, mouse) name, title, mouse +#else +#define TERM_INFO(name, title, mouse) name, title +#endif + +#define XTERM_TITLE "\033]0;w3m: %s\007" +#define SCREEN_TITLE "\033k%s\033\134" + +static struct term_info { char *term; - int flag; -} xterm_mouse_term[] = { - { - "xterm", NEED_XTERM_ON | NEED_XTERM_OFF}, { - "kterm", NEED_XTERM_ON | NEED_XTERM_OFF}, { - "rxvt", NEED_XTERM_ON | NEED_XTERM_OFF}, + char *title_str; +#ifdef USE_MOUSE + int mouse_flag; +#endif +} term_info_list[] = { + /* *INDENT-OFF* */ + {TERM_INFO("xterm", XTERM_TITLE, (NEED_XTERM_ON|NEED_XTERM_OFF))}, + {TERM_INFO("kterm", XTERM_TITLE, (NEED_XTERM_ON|NEED_XTERM_OFF))}, + {TERM_INFO("rxvt", XTERM_TITLE, (NEED_XTERM_ON|NEED_XTERM_OFF))}, + {TERM_INFO("Eterm", XTERM_TITLE, (NEED_XTERM_ON|NEED_XTERM_OFF))}, + {TERM_INFO("screen", SCREEN_TITLE, 0)}, #ifdef __CYGWIN__ - { - "cygwin", NEED_XTERM_ON}, + {TERM_INFO("cygwin", NULL, NEED_XTERM_ON)}, #endif - { - NULL, 0} + {TERM_INFO(NULL, NULL, 0)} + /* *INDENT-ON * */ }; -#endif +#undef TERM_INFO int set_tty(void) @@ -510,13 +524,22 @@ set_tty(void) init_win32_console_handle(); #endif TerminalGet(tty, &d_ioval); + if (displayTitleTerm != NULL) { + struct term_info *p; + for (p = term_info_list; p->term != NULL; p++) { + if (!strncmp(displayTitleTerm, p->term, strlen(p->term))) { + title_str = p->title_str; + break; + } + } + } #ifdef USE_MOUSE { char *term = getenv("TERM"); - struct mouse_term_info *p; - for (p = xterm_mouse_term; p->term != NULL; p++) { + struct term_info *p; + for (p = term_info_list; p->term != NULL; p++) { if (!strncmp(term, p->term, strlen(p->term))) { - is_xterm = p->flag; + is_xterm = p->mouse_flag; break; } } @@ -1837,6 +1860,15 @@ term_cbreak(void) term_noecho(); } +void +term_title(char *s) +{ + if (!fmInitialized) + return; + if (title_str != NULL) + fprintf(stderr, title_str, s); +} + char getch(void) { |