[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>
This commit is contained in:
24
ChangeLog
24
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>
|
2002-04-21 Kiyokazu SUTO <suto@ks-and-ks.ne.jp>
|
||||||
|
|
||||||
* [w3m-dev 03181] KEYBIND_SRC was not passed to scripts/Makefile
|
* [w3m-dev 03181] KEYBIND_SRC was not passed to scripts/Makefile
|
||||||
@@ -3364,4 +3386,4 @@
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-0.2.1
|
* import w3m-0.2.1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.373 2002/04/20 17:50:20 ukai Exp $
|
$Id: ChangeLog,v 1.374 2002/04/24 18:29:35 ukai Exp $
|
||||||
|
|||||||
1
NEWS
1
NEWS
@@ -1,5 +1,6 @@
|
|||||||
w3m 0.4?
|
w3m 0.4?
|
||||||
|
|
||||||
|
* rc: use_dictcommand, dictcommand
|
||||||
* rc: mark_all_pages
|
* rc: mark_all_pages
|
||||||
* configure: -mandir
|
* configure: -mandir
|
||||||
* func: COMMAND
|
* func: COMMAND
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
If you define DICT, you can use dictionary look-up function
|
If you define DICT, you can use dictionary look-up function
|
||||||
in w3m. See README.dict for detail.
|
in w3m. See README.dict for detail.
|
||||||
*/
|
*/
|
||||||
#undef DICT
|
#define DICT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If you want to load and save URL history.
|
If you want to load and save URL history.
|
||||||
|
|||||||
4
configure
vendored
4
configure
vendored
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $Id: configure,v 1.67 2002/04/09 14:45:58 ukai Exp $
|
# $Id: configure,v 1.68 2002/04/24 18:29:35 ukai Exp $
|
||||||
# Configuration.
|
# Configuration.
|
||||||
#
|
#
|
||||||
|
|
||||||
@@ -775,7 +775,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
### only use config.param
|
### only use config.param
|
||||||
def_param use_dict n
|
def_param use_dict y
|
||||||
def_param use_history y
|
def_param use_history y
|
||||||
def_param use_bg_color y
|
def_param use_bg_color y
|
||||||
def_param format_nice n
|
def_param format_nice n
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ w3m
|
|||||||
|
|
||||||
'webster' コマンドなどのように辞書を引くためのコマンドをお持ちの
|
'webster' コマンドなどのように辞書を引くためのコマンドをお持ちの
|
||||||
場合には,w3m の中からそれを使うことができます.この機能は,
|
場合には,w3m の中からそれを使うことができます.この機能は,
|
||||||
るびきちさん(rubikitch@ruby-lang.org)によるものです.
|
るびきちさん(rubikitch@ruby-lang.org)によるものをもとに
|
||||||
|
Tushar Samant (scribble at pobox.com)が修正をくわえました。
|
||||||
|
|
||||||
2. インストール
|
2. インストール
|
||||||
|
|
||||||
@@ -19,17 +20,41 @@ w3m
|
|||||||
#define USE_DICT
|
#define USE_DICT
|
||||||
|
|
||||||
に変更し,w3m をコンパイルしなおしてください.
|
に変更し,w3m をコンパイルしなおしてください.
|
||||||
(dict.c と keybind.c をコンパイルしなおせば良いはずです)
|
w3m/0.3+cvs-1.358以降は、defaultでUSE_DICTがdefineされます。
|
||||||
|
|
||||||
それから,w3mdict というコマンドを用意します.これは,既存の
|
それから,文字列をうけとってその結果をかえすCGIプログラムを
|
||||||
辞書引きコマンドへのリンクです.例えば,webster というコマンド
|
インストールします。
|
||||||
を辞書引きに使いたい場合には,次のようにしてください.
|
|
||||||
|
|
||||||
% cd /usr/local/bin
|
つぎのような方法があります
|
||||||
% ln -s `which webster` w3mdict
|
|
||||||
|
|
||||||
一般に,単語を引数として取って,標準出力に何かを出力するコマンド
|
* もし 'webster'というコマンドがあればいかのような内容の'w3mdict'という
|
||||||
であれば,どんなものでも 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. 使いかた
|
3. 使いかた
|
||||||
|
|
||||||
@@ -39,3 +64,5 @@ ESC w ñ
|
|||||||
|
|
||||||
ESC W バッファ内の現在カーソルがある単語を辞書で引き,表示します.
|
ESC W バッファ内の現在カーソルがある単語を辞書で引き,表示します.
|
||||||
|
|
||||||
|
これらのキーを変更するには、~/.w3m/keymapのDICT_WORDおよびDICT_WORD_AT
|
||||||
|
の行を変更してください。
|
||||||
|
|||||||
@@ -4,36 +4,65 @@ Dictionary look-up hack for w3m
|
|||||||
|
|
||||||
If you have dictionary look-up command (like 'webster'), you can
|
If you have dictionary look-up command (like 'webster'), you can
|
||||||
look a word in a document using w3m. This dictionary-lookup code
|
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
|
To make use of dictionary look-up, you currently must change a
|
||||||
option by hand. After running configure, edit config.h and
|
compile option by hand. After running configure, edit config.h
|
||||||
change
|
and change
|
||||||
|
|
||||||
#undef USE_DICT
|
#undef USE_DICT
|
||||||
|
|
||||||
into
|
to
|
||||||
|
|
||||||
#define USE_DICT
|
#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
|
Then find or install a CGI program which takes a word as a query
|
||||||
to use 'webster' command, do the following:
|
string and prints a response.
|
||||||
|
|
||||||
% cd /usr/local/bin
|
Some ways to do this would be:
|
||||||
% ln -s `which webster` w3mdict
|
|
||||||
|
|
||||||
In general, w3mdict can be any command that takes a word as an
|
* If you have the 'webster' command, put something like this
|
||||||
argument and outputs something onto stdout.
|
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
|
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 Input a word and look it up using w3mdict command.
|
||||||
|
|
||||||
ESC W look up the current word in the buffer.
|
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.
|
||||||
|
|||||||
7
fm.h
7
fm.h
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: fm.h,v 1.58 2002/03/29 16:39:37 ukai Exp $ */
|
/* $Id: fm.h,v 1.59 2002/04/24 18:29:35 ukai Exp $ */
|
||||||
/*
|
/*
|
||||||
* w3m: WWW wo Miru utility
|
* w3m: WWW wo Miru utility
|
||||||
*
|
*
|
||||||
@@ -99,7 +99,6 @@ void bzero(void *, int);
|
|||||||
#define PIPEBUFFERNAME "*stream*"
|
#define PIPEBUFFERNAME "*stream*"
|
||||||
#define CPIPEBUFFERNAME "*stream(closed)*"
|
#define CPIPEBUFFERNAME "*stream(closed)*"
|
||||||
#ifdef USE_DICT
|
#ifdef USE_DICT
|
||||||
#define DICTCMD "w3mdict"
|
|
||||||
#define DICTBUFFERNAME "*dictionary*"
|
#define DICTBUFFERNAME "*dictionary*"
|
||||||
#endif /* USE_DICT */
|
#endif /* USE_DICT */
|
||||||
|
|
||||||
@@ -860,6 +859,10 @@ global char *pauth init(NULL);
|
|||||||
global Str proxy_auth_cookie init(NULL);
|
global Str proxy_auth_cookie init(NULL);
|
||||||
global int UseExternalDirBuffer init(TRUE);
|
global int UseExternalDirBuffer init(TRUE);
|
||||||
global char *DirBufferCommand init("file:///$LIB/dirlist" CGI_EXTENSION);
|
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 ignore_null_img_alt init(TRUE);
|
||||||
global int FoldTextarea init(FALSE);
|
global int FoldTextarea init(FALSE);
|
||||||
#define DEFAULT_URL_EMPTY 0
|
#define DEFAULT_URL_EMPTY 0
|
||||||
|
|||||||
22
main.c
22
main.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: main.c,v 1.97 2002/04/17 02:42:27 ukai Exp $ */
|
/* $Id: main.c,v 1.98 2002/04/24 18:29:35 ukai Exp $ */
|
||||||
#define MAINPROGRAM
|
#define MAINPROGRAM
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -4829,11 +4829,10 @@ GetWord(Buffer *buf)
|
|||||||
static void
|
static void
|
||||||
execdict(char *word)
|
execdict(char *word)
|
||||||
{
|
{
|
||||||
char *w;
|
char *w, *dictcmd;
|
||||||
Buffer *buf;
|
Buffer *buf;
|
||||||
MySignalHandler(*prevtrap) ();
|
|
||||||
|
|
||||||
if (word == NULL || *word == '\0') {
|
if (!UseDictCommand || word == NULL || *word == '\0') {
|
||||||
displayBuffer(Currentbuf, B_NORMAL);
|
displayBuffer(Currentbuf, B_NORMAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4842,22 +4841,17 @@ execdict(char *word)
|
|||||||
displayBuffer(Currentbuf, B_NORMAL);
|
displayBuffer(Currentbuf, B_NORMAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
prevtrap = signal(SIGINT, intTrap);
|
dictcmd = Sprintf("%s?%s", DictCommand, w)->ptr;
|
||||||
crmode();
|
buf = loadGeneralFile(url_quote_conv(dictcmd, Currentbuf->document_code),
|
||||||
buf = getshell(myExtCommand(DICTCMD, shell_quote(w), FALSE)->ptr);
|
baseURL(Currentbuf),
|
||||||
signal(SIGINT, prevtrap);
|
parsedURL2Str(&Currentbuf->currentURL)->ptr,
|
||||||
term_raw();
|
0, NULL);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
disp_message("Execution failed", FALSE);
|
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 {
|
else {
|
||||||
buf->filename = w;
|
buf->filename = w;
|
||||||
buf->buffername = Sprintf("%s %s", DICTBUFFERNAME, word)->ptr;
|
buf->buffername = Sprintf("%s %s", DICTBUFFERNAME, word)->ptr;
|
||||||
buf->bufferprop |= (BP_INTERNAL | BP_NO_URL);
|
|
||||||
if (buf->type == NULL)
|
if (buf->type == NULL)
|
||||||
buf->type = "text/plain";
|
buf->type = "text/plain";
|
||||||
pushBuffer(buf);
|
pushBuffer(buf);
|
||||||
|
|||||||
7
proto.h
7
proto.h
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: proto.h,v 1.40 2002/03/19 16:06:52 ukai Exp $ */
|
/* $Id: proto.h,v 1.41 2002/04/24 18:29:35 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.
|
||||||
@@ -559,11 +559,6 @@ extern void reMark(void);
|
|||||||
#define prevMk nulcmd
|
#define prevMk nulcmd
|
||||||
#define reMark nulcmd
|
#define reMark nulcmd
|
||||||
#endif /* not USE_MARK */
|
#endif /* not USE_MARK */
|
||||||
#ifdef JP_CHARSET
|
|
||||||
extern char *cURLcode(char *url, char code);
|
|
||||||
#else
|
|
||||||
#define cURLcode(url,buf) (url)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_MOUSE
|
#ifdef USE_MOUSE
|
||||||
extern void mouse(void);
|
extern void mouse(void);
|
||||||
|
|||||||
16
rc.c
16
rc.c
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: rc.c,v 1.41 2002/03/29 16:39:37 ukai Exp $ */
|
/* $Id: rc.c,v 1.42 2002/04/24 18:29:35 ukai Exp $ */
|
||||||
/*
|
/*
|
||||||
* Initialization file etc.
|
* Initialization file etc.
|
||||||
*/
|
*/
|
||||||
@@ -148,6 +148,10 @@ static char *config_file = NULL;
|
|||||||
#endif
|
#endif
|
||||||
#define CMT_EXT_DIRLIST "ディレクトリリストに外部コマンドを使う"
|
#define CMT_EXT_DIRLIST "ディレクトリリストに外部コマンドを使う"
|
||||||
#define CMT_DIRLIST_CMD "ディレクトリリスト用コマンド"
|
#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_IGNORE_NULL_IMG_ALT "空のIMG ALT属性の時にリンク名を表示する"
|
||||||
#define CMT_IFILE "各ディレクトリのインデックスファイル"
|
#define CMT_IFILE "各ディレクトリのインデックスファイル"
|
||||||
#define CMT_RETRY_HTTP "URLに自動的に http:// を補う"
|
#define CMT_RETRY_HTTP "URLに自動的に http:// を補う"
|
||||||
@@ -283,6 +287,10 @@ static char *config_file = NULL;
|
|||||||
#endif
|
#endif
|
||||||
#define CMT_EXT_DIRLIST "Use external program for directory listing"
|
#define CMT_EXT_DIRLIST "Use external program for directory listing"
|
||||||
#define CMT_DIRLIST_CMD "Directory listing command"
|
#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_IGNORE_NULL_IMG_ALT "Ignore IMG ALT=\"\" (display link name)"
|
||||||
#define CMT_IFILE "Index file for the directory"
|
#define CMT_IFILE "Index file for the directory"
|
||||||
#define CMT_RETRY_HTTP "Prepend http:// to URL automatically"
|
#define CMT_RETRY_HTTP "Prepend http:// to URL automatically"
|
||||||
@@ -456,6 +464,12 @@ struct param_ptr params1[] = {
|
|||||||
CMT_EXT_DIRLIST, NULL},
|
CMT_EXT_DIRLIST, NULL},
|
||||||
{"dirlist_cmd", P_STRING, PI_TEXT, (void *)&DirBufferCommand,
|
{"dirlist_cmd", P_STRING, PI_TEXT, (void *)&DirBufferCommand,
|
||||||
CMT_DIRLIST_CMD, NULL},
|
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},
|
{"multicol", P_INT, PI_ONOFF, (void *)&multicolList, CMT_MULTICOL, NULL},
|
||||||
{"alt_entity", P_CHARINT, PI_ONOFF, (void *)&UseAltEntity, CMT_ALT_ENTITY,
|
{"alt_entity", P_CHARINT, PI_ONOFF, (void *)&UseAltEntity, CMT_ALT_ENTITY,
|
||||||
NULL},
|
NULL},
|
||||||
|
|||||||
Reference in New Issue
Block a user