w3m

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

commit 7d33d926121ba2fc758cad036ef39b73bac91f41
parent dc04506187dfd588905f8244d9769039cf7d317c
Author: ukai <ukai>
Date:   Mon,  9 Dec 2002 15:21:12 +0000

[w3m-dev 03541] Re: W3M_LINE_NO / W3M_CURRENT_COLUMN
* main.c (goLine): check searchKeyData()
	(set_buffer_environ): W3M_CURRENT_*
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 6++++++
Mmain.c | 88+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
2 files changed, 59 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +2002-12-10 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03541] Re: W3M_LINE_NO / W3M_CURRENT_COLUMN + * main.c (goLine): check searchKeyData() + (set_buffer_environ): W3M_CURRENT_* + 2002-12-07 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03536] <del>, <s> diff --git a/main.c b/main.c @@ -2392,8 +2392,12 @@ _goLine(char *l) void goLine(void) { + + char *str = searchKeyData(); if (prec_num) _goLine("^"); + else if (str) + _goLine(str); else _goLine(inputStr("Goto line: ", "")); } @@ -5358,50 +5362,64 @@ dictwordat(void) void set_buffer_environ(Buffer *buf) { - Anchor *a; - Str s; - ParsedURL pu; + static Buffer *prev_buf = NULL; + static Line *prev_line = NULL; + static short prev_col = -1, prev_pos = -1; + Line *l; if (buf == NULL) return; - set_environ("W3M_SOURCEFILE", buf->sourcefile); - set_environ("W3M_FILENAME", buf->filename); - set_environ("W3M_CURRENT_WORD", GetWord(buf)); - set_environ("W3M_TITLE", buf->buffername); - set_environ("W3M_URL", parsedURL2Str(&buf->currentURL)->ptr); - if (buf->real_type) - set_environ("W3M_TYPE", buf->real_type); - else - set_environ("W3M_TYPE", "unknown"); + if (buf != prev_buf) { + set_environ("W3M_SOURCEFILE", buf->sourcefile); + set_environ("W3M_FILENAME", buf->filename); + set_environ("W3M_TITLE", buf->buffername); + set_environ("W3M_URL", parsedURL2Str(&buf->currentURL)->ptr); + set_environ("W3M_TYPE", buf->real_type ? buf->real_type : "unknown"); #ifdef JP_CHARSET - set_environ("W3M_CHARSET", code_to_str(buf->document_code)); + set_environ("W3M_CHARSET", code_to_str(buf->document_code)); #endif /* JP_CHARSET */ - a = retrieveCurrentAnchor(buf); - if (a == NULL) { - set_environ("W3M_CURRENT_LINK", ""); } - else { - parseURL2(a->url, &pu, baseURL(buf)); - s = parsedURL2Str(&pu); - set_environ("W3M_CURRENT_LINK", s->ptr); - } - a = retrieveCurrentImg(buf); - if (a == NULL) { + l = buf->currentLine; + if (l && (buf != prev_buf || l != prev_line || buf->pos != prev_pos)) { + Anchor *a; + ParsedURL pu; + char *s = GetWord(buf); + set_environ("W3M_CURRENT_WORD", s ? s : ""); + a = retrieveCurrentAnchor(buf); + if (a) { + parseURL2(a->url, &pu, baseURL(buf)); + set_environ("W3M_CURRENT_LINK", parsedURL2Str(&pu)->ptr); + } + else + set_environ("W3M_CURRENT_LINK", ""); + a = retrieveCurrentImg(buf); + if (a) { + parseURL2(a->url, &pu, baseURL(buf)); + set_environ("W3M_CURRENT_IMG", parsedURL2Str(&pu)->ptr); + } + else + set_environ("W3M_CURRENT_IMG", ""); + a = retrieveCurrentForm(buf); + if (a) + set_environ("W3M_CURRENT_FORM", form2str((FormItemList *)a->url)); + else + set_environ("W3M_CURRENT_FORM", ""); + set_environ("W3M_CURRENT_LINE", Sprintf("%d", + l->real_linenumber)->ptr); + set_environ("W3M_CURRENT_COLUMN", Sprintf("%d", + buf->currentColumn + buf->cursorX + 1)->ptr); + } + else if (!l) { + set_environ("W3M_CURRENT_WORD", ""); + set_environ("W3M_CURRENT_LINK", ""); set_environ("W3M_CURRENT_IMG", ""); - } - else { - parseURL2(a->url, &pu, baseURL(buf)); - s = parsedURL2Str(&pu); - set_environ("W3M_CURRENT_IMG", s->ptr); - } - a = retrieveCurrentForm(buf); - if (a == NULL) { set_environ("W3M_CURRENT_FORM", ""); + set_environ("W3M_CURRENT_LINE", "0"); + set_environ("W3M_CURRENT_COLUMN", "0"); } - else { - s = Strnew_charp(form2str((FormItemList *)a->url)); - set_environ("W3M_CURRENT_FORM", s->ptr); - } + prev_buf = buf; + prev_line = l; + prev_pos = buf->pos; } char *