w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit a0c2bd23b22a2dd47e976dab270faa3590006d2e
parent 71b070f3682f6b3df00915b4aef4cc5f4df26897
Author: ukai <ukai>
Date:   Fri, 15 Mar 2002 18:33:31 +0000

-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:
MChangeLog | 20++++++++++++++++++++
MNEWS | 1+
Mdisplay.c | 1+
Mfm.h | 1+
Mmain.c | 6++++++
Mproto.h | 1+
Mterms.c | 62+++++++++++++++++++++++++++++++++++++++++++++++---------------
7 files changed, 77 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,23 @@ +2002-03-16 Fumitoshi UKAI <ukai@debian.or.jp> + + * -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 + 2002-03-16 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03132] Re: Reload image diff --git a/NEWS b/NEWS @@ -1,5 +1,6 @@ w3m 0.4? +* -title option: set buffer name to terminal title * X-Face support: USE_XFACE, require uncompface ---------------------------------------------------------------- diff --git a/display.c b/display.c @@ -383,6 +383,7 @@ displayBuffer(Buffer *buf, int mode) standout(); message(msg->ptr, buf->cursorX + buf->rootX, buf->cursorY); standend(); + term_title(buf->buffername); refresh(); #ifdef USE_IMAGE if (activeImage && displayImage && buf->img) { diff --git a/fm.h b/fm.h @@ -816,6 +816,7 @@ global int label_topline init(FALSE); #ifdef NEXTPAGE_TOPLINE global int nextpage_topline init(FALSE); #endif +global char *displayTitleTerm init(NULL); global int displayLink init(FALSE); global int retryAsHttp init(TRUE); global int showLineNum init(FALSE); diff --git a/main.c b/main.c @@ -230,6 +230,7 @@ fusage(FILE * f, int err) #endif fprintf(f, " -W toggle wrap search mode\n"); fprintf(f, " -X don't use termcap init/deinit\n"); + fprintf(f, " -title[=TERM] set buffer name to terminal title string\n"); fprintf(f, " -o opt=value assign value to config option\n"); fprintf(f, " -config file specify config file\n"); fprintf(f, " -help print this usage message\n"); @@ -659,6 +660,10 @@ MAIN(int argc, char **argv, char **envp) squeezeBlankLine = TRUE; else if (!strcmp("-X", argv[i])) Do_not_use_ti_te = TRUE; + else if (!strcmp("-title", argv[i])) + displayTitleTerm = getenv("TERM"); + else if (!strncmp("-title=", argv[i], 7)) + displayTitleTerm = argv[i]+7; else if (!strcmp("-o", argv[i])) { if (++i >= argc || !strcmp(argv[i], "?")) { show_params_p = 1; @@ -2168,6 +2173,7 @@ qquitfm(void) void quitfm(void) { + term_title(""); /* XXX */ #ifdef USE_IMAGE if (activeImage) termImage(); diff --git a/proto.h b/proto.h @@ -416,6 +416,7 @@ extern void term_noecho(void); extern void term_raw(void); extern void term_cooked(void); extern void term_cbreak(void); +extern void term_title(char *s); extern void flush_tty(void); extern void toggle_stand(void); extern char getch(void); diff --git a/terms.c b/terms.c @@ -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) {