aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-04-24 18:29:35 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-04-24 18:29:35 +0000
commit4e8c85a7fa218fc538aaf3a4e08ffa9fd6017a3d (patch)
treec4b80e2b654ac6a89ac9abececae7ba701b15fac
parent[w3m-dev 03181] KEYBIND_SRC was not passed to scripts/Makefile (diff)
downloadw3m-4e8c85a7fa218fc538aaf3a4e08ffa9fd6017a3d.tar.gz
w3m-4e8c85a7fa218fc538aaf3a4e08ffa9fd6017a3d.zip
[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>
-rw-r--r--ChangeLog24
-rw-r--r--NEWS1
-rw-r--r--config.h.dist2
-rwxr-xr-xconfigure4
-rw-r--r--doc-jp/README.dict45
-rw-r--r--doc/README.dict57
-rw-r--r--fm.h7
-rw-r--r--main.c22
-rw-r--r--proto.h7
-rw-r--r--rc.c16
10 files changed, 135 insertions, 50 deletions
diff --git a/ChangeLog b/ChangeLog
index 83c48c6..8015d9d 100644
--- 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
@@ -3364,4 +3386,4 @@
* release-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 $
diff --git a/NEWS b/NEWS
index c9406f2..4cdece3 100644
--- 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
index 16d82c6..2d37c0c 100644
--- 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
index 0d8dbbf..b4cc689 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#!/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.
#
@@ -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
index 4f8c80d..55da29f 100644
--- 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
index ecb32be..ec4f44d 100644
--- 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
index d3f7e78..274e8b0 100644
--- a/fm.h
+++ b/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
*
@@ -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
index f947e97..fb0f35c 100644
--- a/main.c
+++ b/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
#include "fm.h"
#include <signal.h>
@@ -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
index 84366e7..91d7e82 100644
--- a/proto.h
+++ b/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.
* Manual editing not recommended.
@@ -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
index bf559a0..6d3b860 100644
--- a/rc.c
+++ b/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.
*/
@@ -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},