w3m

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

commit d1b6aceba2ab3ca7ff4a6122559239044364b115
parent 5a96f60a4130820be2fbbe1f06ffbb13a3714a40
Author: ukai <ukai>
Date:   Wed, 24 Apr 2002 18:29:35 +0000

[w3m-dev-en 00730] Re: Patch for a more flexible dictionary lookup
* NEWS: rc: use_dictcommand, dictcommand
* main.c (execdict): use url_quote_conv() instead of cURLcode()
* proto.h (cURLcode): deleted
* doc-jp/README.dict: updated
From: Fumitoshi UKAI  <ukai@debian.or.jp>

[w3m-dev-en 00729] Re: Patch for a more flexible dictionary lookup
* config.h.dist (DICT): define
* configure (use_dict): default y
* fm.h (DICTCMD): deleted
	(UseDictCommand): added
	(DictCommand): added
* main.c (execdict): rewrite to use DictCommand, loadGeneralFile()
* rc.c (CMT_USE_DICTCOMMAND): added
	(CMT_DICTCOMMAND): added
	(params1): use_dictcommand, dictcommand added
* doc/README.dict: updated
From:  Tushar Samant <scribble@pobox.com>

Diffstat:
MChangeLog | 22++++++++++++++++++++++
MNEWS | 1+
Mconfig.h.dist | 2+-
Mconfigure | 2+-
Mdoc-jp/README.dict | 45++++++++++++++++++++++++++++++++++++---------
Mdoc/README.dict | 57+++++++++++++++++++++++++++++++++++++++++++--------------
Mfm.h | 5++++-
Mmain.c | 20+++++++-------------
Mproto.h | 5-----
Mrc.c | 14++++++++++++++
10 files changed, 129 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,25 @@ +2002-04-25 Fumitoshi UKAI <ukai@debian.or.jp> + + * [w3m-dev-en 00730] Re: Patch for a more flexible dictionary lookup + * NEWS: rc: use_dictcommand, dictcommand + * main.c (execdict): use url_quote_conv() instead of cURLcode() + * proto.h (cURLcode): deleted + * doc-jp/README.dict: updated + +2002-04-25 Tushar Samant <scribble@pobox.com> + + * [w3m-dev-en 00729] Re: Patch for a more flexible dictionary lookup + * config.h.dist (DICT): define + * configure (use_dict): default y + * fm.h (DICTCMD): deleted + (UseDictCommand): added + (DictCommand): added + * main.c (execdict): rewrite to use DictCommand, loadGeneralFile() + * rc.c (CMT_USE_DICTCOMMAND): added + (CMT_DICTCOMMAND): added + (params1): use_dictcommand, dictcommand added + * doc/README.dict: updated + 2002-04-21 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> * [w3m-dev 03181] KEYBIND_SRC was not passed to scripts/Makefile diff --git a/NEWS b/NEWS @@ -1,5 +1,6 @@ w3m 0.4? +* rc: use_dictcommand, dictcommand * rc: mark_all_pages * configure: -mandir * func: COMMAND diff --git a/config.h.dist b/config.h.dist @@ -12,7 +12,7 @@ If you define DICT, you can use dictionary look-up function in w3m. See README.dict for detail. */ -#undef DICT +#define DICT /* If you want to load and save URL history. diff --git a/configure b/configure @@ -775,7 +775,7 @@ else fi ### only use config.param -def_param use_dict n +def_param use_dict y def_param use_history y def_param use_bg_color y def_param format_nice n diff --git a/doc-jp/README.dict b/doc-jp/README.dict @@ -4,7 +4,8 @@ w3m 'webster' ���ޥ�ɤʤɤΤ褦�˼�����������Υ��ޥ�ɤ򤪻����� ���ˤϡ�w3m ���椫�餽���Ȥ����Ȥ��Ǥ��ޤ������ε�ǽ�ϡ� -��Ӥ�������(rubikitch@ruby-lang.org)�ˤ���ΤǤ��� +��Ӥ�������(rubikitch@ruby-lang.org)�ˤ���Τ��Ȥ� +Tushar Samant (scribble at pobox.com)�������򤯤廊�ޤ����� 2. ���󥹥ȡ��� @@ -19,17 +20,41 @@ w3m #define USE_DICT ���ѹ�����w3m �򥳥�ѥ��뤷�ʤ����Ƥ��������� -(dict.c �� keybind.c �򥳥�ѥ��뤷�ʤ������ɤ��Ϥ��Ǥ�) +w3m/0.3+cvs-1.358�ʹߤϡ�default��USE_DICT��define����ޤ��� -���줫�顤w3mdict �Ȥ������ޥ�ɤ��Ѱդ��ޤ�������ϡ���¸�� -����������ޥ�ɤؤΥ�󥯤Ǥ����㤨�С�webster �Ȥ������ޥ�� -�򼭽�����˻Ȥ��������ˤϡ����Τ褦�ˤ��Ƥ��������� +���줫�顤ʸ����򤦤��ȤäƤ��η�̤򤫤���CGI�ץ������� +���󥹥ȡ��뤷�ޤ��� -% cd /usr/local/bin -% ln -s `which webster` w3mdict +�Ĥ��Τ褦����ˡ������ޤ� -���̤ˡ�ñ�������Ȥ��Ƽ�äơ�ɸ����Ϥ˲�������Ϥ��륳�ޥ�� -�Ǥ���С��ɤ�ʤ�ΤǤ� w3mdict �Ȥ��ƻȤ����Ȥ��Ǥ��ޤ��� + * �⤷ 'webster'�Ȥ������ޥ�ɤ�����Ф����Τ褦�����Ƥ�'w3mdict'�Ȥ��� + ������ץȤ�Ĥ���ޤ��� + + #!/bin/sh + + echo Content-type: text/plain + echo + webster $QUERY_STRING + + ����� lcoal CGI�Ȥ��ƥ��󥹥ȡ��뤷�ޤ� (w3m�ޥ˥奢��� local CGI + �Υ���������ߤƤ�������) ������ w3m�Υ��ץ����ڡ����� + ������������ꤷ�Ƥ��������� + + * �⤷ʸ�����Google�Ǹ������뵡ǽ���Ĥ���������硢 + �ʲ��Τ褦�� local CGI������ץȤ��Ĥ����ޤ��� + + #!/bin/sh + + google_q='http://google.com/search?btnG=Google&q' + + cat <<_END_ + Content-type: text/plain + W3m-control: GOTO $google_q=$QUERY_STRING + W3m-control: DELETE_PREVBUF + + _END_ + + ����Υѥ��򼭽�������ޥ�ɤ�URL�Ȥ������ꤷ�Ƥ��������� 3. �Ȥ����� @@ -39,3 +64,5 @@ ESC w ñ ESC W �Хåե���θ��ߥ������뤬����ñ��򼭽�ǰ�����ɽ�����ޤ��� +�����Υ������ѹ�����ˤϡ�~/.w3m/keymap��DICT_WORD�����DICT_WORD_AT +�ιԤ��ѹ����Ƥ��������� diff --git a/doc/README.dict b/doc/README.dict @@ -4,36 +4,65 @@ Dictionary look-up hack for w3m If you have dictionary look-up command (like 'webster'), you can look a word in a document using w3m. This dictionary-lookup code -was contributed by `Rubikitch' (rubikitch@ruby-lang.org). +was contributed by `Rubikitch' (rubikitch@ruby-lang.org), and +further modifed by Tushar Samant (scribble at pobox.com). -2. INSTALL +2. INSTALLATION -To make use of dictionary look-up, you have to change compile -option by hand. After running configure, edit config.h and -change +To make use of dictionary look-up, you currently must change a +compile option by hand. After running configure, edit config.h +and change #undef USE_DICT -into +to #define USE_DICT -and recompile w3m. (You have to recompile dict.c and keybind.c.) +and recompile w3me (i.e. type "make install"). +Note that w3m/0.3+cvs-1.358 or later, USE_DICT is defined by default. -Then prepare a command named 'w3mdict.' For example, if you want -to use 'webster' command, do the following: +Then find or install a CGI program which takes a word as a query +string and prints a response. -% cd /usr/local/bin -% ln -s `which webster` w3mdict +Some ways to do this would be: -In general, w3mdict can be any command that takes a word as an -argument and outputs something onto stdout. + * If you have the 'webster' command, put something like this + in a script called 'w3mdict': + + #!/bin/sh + + echo Content-type: text/plain + echo + webster $QUERY_STRING + + Then install w3mdict as a local CGI (see the local CGI section + of the w3m manual), and set your dictionary options from the + options page of w3m (usually invoked with "o"). + + * If you want this function to look a word up on Google instead, + write a local CGI script like this: + + #!/bin/sh + + google_q='http://google.com/search?btnG=Google&q' + + cat <<_END_ + Content-type: text/plain + W3m-control: GOTO $google_q=$QUERY_STRING + W3m-control: DELETE_PREVBUF + + _END_ + + and set its path as your dictionary-lookup URL option. 3. USAGE -You can use the following two commands. +You can use the following two commands: ESC w Input a word and look it up using w3mdict command. ESC W look up the current word in the buffer. +To change these keys, edit ~/.w3m/keymap and edit lines for the +functions DICT_WORD and DICT_WORD_AT respectively. diff --git a/fm.h b/fm.h @@ -99,7 +99,6 @@ void bzero(void *, int); #define PIPEBUFFERNAME "*stream*" #define CPIPEBUFFERNAME "*stream(closed)*" #ifdef USE_DICT -#define DICTCMD "w3mdict" #define DICTBUFFERNAME "*dictionary*" #endif /* USE_DICT */ @@ -860,6 +859,10 @@ global char *pauth init(NULL); global Str proxy_auth_cookie init(NULL); global int UseExternalDirBuffer init(TRUE); global char *DirBufferCommand init("file:///$LIB/dirlist" CGI_EXTENSION); +#ifdef USE_DICT +global int UseDictCommand init(FALSE); +global char *DictCommand init("file:///$LIB/w3mdict" CGI_EXTENSION); +#endif /* USE_DICT */ global int ignore_null_img_alt init(TRUE); global int FoldTextarea init(FALSE); #define DEFAULT_URL_EMPTY 0 diff --git a/main.c b/main.c @@ -4829,11 +4829,10 @@ GetWord(Buffer *buf) static void execdict(char *word) { - char *w; + char *w, *dictcmd; Buffer *buf; - MySignalHandler(*prevtrap) (); - if (word == NULL || *word == '\0') { + if (!UseDictCommand || word == NULL || *word == '\0') { displayBuffer(Currentbuf, B_NORMAL); return; } @@ -4842,22 +4841,17 @@ execdict(char *word) displayBuffer(Currentbuf, B_NORMAL); return; } - prevtrap = signal(SIGINT, intTrap); - crmode(); - buf = getshell(myExtCommand(DICTCMD, shell_quote(w), FALSE)->ptr); - signal(SIGINT, prevtrap); - term_raw(); + dictcmd = Sprintf("%s?%s", DictCommand, w)->ptr; + buf = loadGeneralFile(url_quote_conv(dictcmd, Currentbuf->document_code), + baseURL(Currentbuf), + parsedURL2Str(&Currentbuf->currentURL)->ptr, + 0, NULL); if (buf == NULL) { disp_message("Execution failed", FALSE); } - else if (buf->firstLine == NULL) { - /* if the dictionary doesn't describe the word. */ - disp_message(Sprintf("Word \"%s\" Not Found", word)->ptr, FALSE); - } else { buf->filename = w; buf->buffername = Sprintf("%s %s", DICTBUFFERNAME, word)->ptr; - buf->bufferprop |= (BP_INTERNAL | BP_NO_URL); if (buf->type == NULL) buf->type = "text/plain"; pushBuffer(buf); diff --git a/proto.h b/proto.h @@ -559,11 +559,6 @@ extern void reMark(void); #define prevMk nulcmd #define reMark nulcmd #endif /* not USE_MARK */ -#ifdef JP_CHARSET -extern char *cURLcode(char *url, char code); -#else -#define cURLcode(url,buf) (url) -#endif #ifdef USE_MOUSE extern void mouse(void); diff --git a/rc.c b/rc.c @@ -148,6 +148,10 @@ static char *config_file = NULL; #endif #define CMT_EXT_DIRLIST "�ǥ��쥯�ȥ�ꥹ�Ȥ˳������ޥ�ɤ�Ȥ�" #define CMT_DIRLIST_CMD "�ǥ��쥯�ȥ�ꥹ���ѥ��ޥ��" +#ifdef USE_DICT +#define CMT_USE_DICTCOMMAND "���������CGI��ͳ�Ǥ����ʤ�" +#define CMT_DICTCOMMAND "����������ޥ�ɤ�URL" +#endif /* USE_DICT */ #define CMT_IGNORE_NULL_IMG_ALT "����IMG ALT°���λ��˥��̾��ɽ������" #define CMT_IFILE "�ƥǥ��쥯�ȥ�Υ���ǥå����ե�����" #define CMT_RETRY_HTTP "URL�˼�ưŪ�� http:// ���䤦" @@ -283,6 +287,10 @@ static char *config_file = NULL; #endif #define CMT_EXT_DIRLIST "Use external program for directory listing" #define CMT_DIRLIST_CMD "Directory listing command" +#ifdef USE_DICT +#define CMT_USE_DICTCOMMAND "Enable dictionary lookup through CGI" +#define CMT_DICTCOMMAND "URL of dictionary lookup command" +#endif /* USE_DICT */ #define CMT_IGNORE_NULL_IMG_ALT "Ignore IMG ALT=\"\" (display link name)" #define CMT_IFILE "Index file for the directory" #define CMT_RETRY_HTTP "Prepend http:// to URL automatically" @@ -456,6 +464,12 @@ struct param_ptr params1[] = { CMT_EXT_DIRLIST, NULL}, {"dirlist_cmd", P_STRING, PI_TEXT, (void *)&DirBufferCommand, CMT_DIRLIST_CMD, NULL}, +#ifdef USE_DICT + {"use_dictcommand", P_INT, PI_ONOFF, (void *)&UseDictCommand, + CMT_USE_DICTCOMMAND, NULL}, + {"dictcommand", P_STRING, PI_TEXT, (void *)&DictCommand, + CMT_DICTCOMMAND, NULL}, +#endif /* USE_DICT */ {"multicol", P_INT, PI_ONOFF, (void *)&multicolList, CMT_MULTICOL, NULL}, {"alt_entity", P_CHARINT, PI_ONOFF, (void *)&UseAltEntity, CMT_ALT_ENTITY, NULL},