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},