-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>
This commit is contained in:
Fumitoshi UKAI
2002-03-15 18:33:31 +00:00
parent 563cc280e4
commit d2f5a95a9b
7 changed files with 83 additions and 21 deletions
+21 -1
View File
@@ -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> 2002-03-16 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 03132] Re: Reload image * [w3m-dev 03132] Re: Reload image
@@ -3207,4 +3227,4 @@
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.353 2002/03/15 16:35:46 ukai Exp $ $Id: ChangeLog,v 1.354 2002/03/15 18:33:31 ukai Exp $
+1
View File
@@ -1,5 +1,6 @@
w3m 0.4? w3m 0.4?
* -title option: set buffer name to terminal title
* X-Face support: USE_XFACE, require uncompface * X-Face support: USE_XFACE, require uncompface
---------------------------------------------------------------- ----------------------------------------------------------------
+2 -1
View File
@@ -1,4 +1,4 @@
/* $Id: display.c,v 1.21 2002/03/10 15:55:15 ukai Exp $ */ /* $Id: display.c,v 1.22 2002/03/15 18:33:32 ukai Exp $ */
#include <signal.h> #include <signal.h>
#include "fm.h" #include "fm.h"
@@ -383,6 +383,7 @@ displayBuffer(Buffer *buf, int mode)
standout(); standout();
message(msg->ptr, buf->cursorX + buf->rootX, buf->cursorY); message(msg->ptr, buf->cursorX + buf->rootX, buf->cursorY);
standend(); standend();
term_title(buf->buffername);
refresh(); refresh();
#ifdef USE_IMAGE #ifdef USE_IMAGE
if (activeImage && displayImage && buf->img) { if (activeImage && displayImage && buf->img) {
+2 -1
View File
@@ -1,4 +1,4 @@
/* $Id: fm.h,v 1.55 2002/03/14 16:12:07 ukai Exp $ */ /* $Id: fm.h,v 1.56 2002/03/15 18:33:32 ukai Exp $ */
/* /*
* w3m: WWW wo Miru utility * w3m: WWW wo Miru utility
* *
@@ -816,6 +816,7 @@ global int label_topline init(FALSE);
#ifdef NEXTPAGE_TOPLINE #ifdef NEXTPAGE_TOPLINE
global int nextpage_topline init(FALSE); global int nextpage_topline init(FALSE);
#endif #endif
global char *displayTitleTerm init(NULL);
global int displayLink init(FALSE); global int displayLink init(FALSE);
global int retryAsHttp init(TRUE); global int retryAsHttp init(TRUE);
global int showLineNum init(FALSE); global int showLineNum init(FALSE);
+7 -1
View File
@@ -1,4 +1,4 @@
/* $Id: main.c,v 1.88 2002/03/15 16:35:46 ukai Exp $ */ /* $Id: main.c,v 1.89 2002/03/15 18:33:32 ukai Exp $ */
#define MAINPROGRAM #define MAINPROGRAM
#include "fm.h" #include "fm.h"
#include <signal.h> #include <signal.h>
@@ -230,6 +230,7 @@ fusage(FILE * f, int err)
#endif #endif
fprintf(f, " -W toggle wrap search mode\n"); fprintf(f, " -W toggle wrap search mode\n");
fprintf(f, " -X don't use termcap init/deinit\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, " -o opt=value assign value to config option\n");
fprintf(f, " -config file specify config file\n"); fprintf(f, " -config file specify config file\n");
fprintf(f, " -help print this usage message\n"); fprintf(f, " -help print this usage message\n");
@@ -659,6 +660,10 @@ MAIN(int argc, char **argv, char **envp)
squeezeBlankLine = TRUE; squeezeBlankLine = TRUE;
else if (!strcmp("-X", argv[i])) else if (!strcmp("-X", argv[i]))
Do_not_use_ti_te = TRUE; 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])) { else if (!strcmp("-o", argv[i])) {
if (++i >= argc || !strcmp(argv[i], "?")) { if (++i >= argc || !strcmp(argv[i], "?")) {
show_params_p = 1; show_params_p = 1;
@@ -2168,6 +2173,7 @@ qquitfm(void)
void void
quitfm(void) quitfm(void)
{ {
term_title(""); /* XXX */
#ifdef USE_IMAGE #ifdef USE_IMAGE
if (activeImage) if (activeImage)
termImage(); termImage();
+2 -1
View File
@@ -1,4 +1,4 @@
/* $Id: proto.h,v 1.38 2002/03/14 15:41:54 ukai Exp $ */ /* $Id: proto.h,v 1.39 2002/03/15 18:33:32 ukai Exp $ */
/* /*
* This file was automatically generated by version 1.7 of cextract. * This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended. * Manual editing not recommended.
@@ -416,6 +416,7 @@ extern void term_noecho(void);
extern void term_raw(void); extern void term_raw(void);
extern void term_cooked(void); extern void term_cooked(void);
extern void term_cbreak(void); extern void term_cbreak(void);
extern void term_title(char *s);
extern void flush_tty(void); extern void flush_tty(void);
extern void toggle_stand(void); extern void toggle_stand(void);
extern char getch(void); extern char getch(void);
+48 -16
View File
@@ -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 * An original curses library for EUC-kanji by Akinori ITO, December 1989
* revised by Akinori ITO, January 1995 * revised by Akinori ITO, January 1995
@@ -42,6 +42,8 @@ void mouse_init(), mouse_end();
int mouseActive = 0; int mouseActive = 0;
#endif /* USE_MOUSE */ #endif /* USE_MOUSE */
static char *title_str = NULL;
static int tty; static int tty;
#include "terms.h" #include "terms.h"
@@ -474,22 +476,34 @@ writestr(char *s)
#define MOVE(line,column) writestr(tgoto(T_cm,column,line)); #define MOVE(line,column) writestr(tgoto(T_cm,column,line));
#ifdef USE_MOUSE #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; char *term;
int flag; char *title_str;
} xterm_mouse_term[] = { #ifdef USE_MOUSE
{ int mouse_flag;
"xterm", NEED_XTERM_ON | NEED_XTERM_OFF}, { #endif
"kterm", NEED_XTERM_ON | NEED_XTERM_OFF}, { } term_info_list[] = {
"rxvt", NEED_XTERM_ON | NEED_XTERM_OFF}, /* *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__ #ifdef __CYGWIN__
{ {TERM_INFO("cygwin", NULL, NEED_XTERM_ON)},
"cygwin", NEED_XTERM_ON},
#endif #endif
{ {TERM_INFO(NULL, NULL, 0)}
NULL, 0} /* *INDENT-ON * */
}; };
#endif #undef TERM_INFO
int int
set_tty(void) set_tty(void)
@@ -510,13 +524,22 @@ set_tty(void)
init_win32_console_handle(); init_win32_console_handle();
#endif #endif
TerminalGet(tty, &d_ioval); 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 #ifdef USE_MOUSE
{ {
char *term = getenv("TERM"); char *term = getenv("TERM");
struct mouse_term_info *p; struct term_info *p;
for (p = xterm_mouse_term; p->term != NULL; p++) { for (p = term_info_list; p->term != NULL; p++) {
if (!strncmp(term, p->term, strlen(p->term))) { if (!strncmp(term, p->term, strlen(p->term))) {
is_xterm = p->flag; is_xterm = p->mouse_flag;
break; break;
} }
} }
@@ -1837,6 +1860,15 @@ term_cbreak(void)
term_noecho(); term_noecho();
} }
void
term_title(char *s)
{
if (!fmInitialized)
return;
if (title_str != NULL)
fprintf(stderr, title_str, s);
}
char char
getch(void) getch(void)
{ {