w3m

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

commit f90abbabd22c50e7a728a7995b7bd5db7ff4e9bc
parent bc44d30148916d755e5cfde8272dddf9335f711b
Author: ukai <ukai>
Date:   Thu, 24 Jan 2002 17:29:45 +0000

[w3m-dev 02901] Default URL for GOTO*
* fm.h (DEFAULT_URL_*): added
* fm.h (DefaultURLString): added
* main.c (cmd_loadURL): add arg "referer"
* main.c (goURL0): 2nd arg is "relative" flag
		check DefaultURLString
		if relative, then current and referer is set
* main.c (ldhelp): cmd_loadURL arg changes
* main.c (deletePrevBuf): ditto
* main.c (cmd_loadBuffer): ditto
* main.c (adBmark): ditto
* main.c (follow_map): ditto
* rc.c (CMT_DEFAULT_URL): added
* rc.c (defaulturls): added
* rc.c (params9): add "default_url"

Diffstat:
MChangeLog | 18++++++++++++++++++
Mfm.h | 4++++
Mmain.c | 51+++++++++++++++++++++++++++++++++++----------------
Mrc.c | 17+++++++++++++++++
4 files changed, 74 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,5 +1,23 @@ 2002-01-25 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 02901] Default URL for GOTO* + * fm.h (DEFAULT_URL_*): added + * fm.h (DefaultURLString): added + * main.c (cmd_loadURL): add arg `referer' + * main.c (goURL0): 2nd arg is `relative' flag + check DefaultURLString + if relative, then current and referer is set + * main.c (ldhelp): cmd_loadURL arg changes + * main.c (deletePrevBuf): ditto + * main.c (cmd_loadBuffer): ditto + * main.c (adBmark): ditto + * main.c (follow_map): ditto + * rc.c (CMT_DEFAULT_URL): added + * rc.c (defaulturls): added + * rc.c (params9): add "default_url" + +2002-01-25 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 02901] DNS_ORDER_* * fm.h (DNS_ORDER_*): added * rc.c (dnsorders): use N_S(DNS_ORDER_*) diff --git a/fm.h b/fm.h @@ -775,6 +775,10 @@ global int UseExternalDirBuffer init(TRUE); global char *DirBufferCommand init("file:///$LIB/dirlist" CGI_EXTENSION); global int ignore_null_img_alt init(TRUE); global int FoldTextarea init(FALSE); +#define DEFAULT_URL_EMPTY 0 +#define DEFAULT_URL_CURRENT 1 +#define DEFAULT_URL_LINK 2 +global int DefaultURLString init(DEFAULT_URL_EMPTY); #ifdef USE_MIGEMO global int use_migemo init(FALSE); diff --git a/main.c b/main.c @@ -67,7 +67,7 @@ int (*searchRoutine) (Buffer *, char *); JMP_BUF IntReturn; static void cmd_loadfile(char *path); -static void cmd_loadURL(char *url, ParsedURL *current); +static void cmd_loadURL(char *url, ParsedURL *current, char *referer); static void cmd_loadBuffer(Buffer *buf, int prop, int linkid); static void keyPressEventProc(int c); #ifdef USE_MARK @@ -1833,9 +1833,9 @@ ldhelp(void) "?version=%s&lang=%s", Str_form_quote(Strnew_charp(w3m_version))->ptr, Str_form_quote(Strnew_charp_n(lang, n))->ptr)->ptr, - NULL); + NULL, NO_REFERER); #else - cmd_loadURL(helpFile(HELP_FILE), NULL); + cmd_loadURL(helpFile(HELP_FILE), NULL, NO_REFERER); #endif } @@ -3573,7 +3573,7 @@ deletePrevBuf() } static void -cmd_loadURL(char *url, ParsedURL *current) +cmd_loadURL(char *url, ParsedURL *current, char *referer) { Buffer *buf; @@ -3597,7 +3597,7 @@ cmd_loadURL(char *url, ParsedURL *current) #endif /* USE_NNTP */ refresh(); - buf = loadGeneralFile(url, current, NO_REFERER, 0, NULL); + buf = loadGeneralFile(url, current, referer, 0, NULL); if (buf == NULL) { char *emsg = Sprintf("Can't load %s", conv_from_system(url))->ptr; disp_err_message(emsg, FALSE); @@ -3613,16 +3613,26 @@ cmd_loadURL(char *url, ParsedURL *current) /* go to specified URL */ static void -goURL0(char *prompt, ParsedURL *current) +goURL0(char *prompt, int relative) { - char *url; - ParsedURL p_url; + char *url, *referer; + ParsedURL p_url, *current; Buffer *cur_buf = Currentbuf; url = searchKeyData(); if (url == NULL) { - if (current) - url = parsedURL2Str(current)->ptr; + if (DefaultURLString == DEFAULT_URL_CURRENT) { + current = baseURL(Currentbuf); + if (current) + url = parsedURL2Str(current)->ptr; + } + else if (DefaultURLString == DEFAULT_URL_LINK) { + Anchor *a = retrieveCurrentAnchor(Currentbuf); + if (a) { + parseURL2(a->url, &p_url, baseURL(Currentbuf)); + url = parsedURL2Str(&p_url)->ptr; + } + } url = inputLineHist(prompt, url, IN_URL, URLHist); if (url != NULL) SKIP_BLANKS(url); @@ -3643,9 +3653,17 @@ goURL0(char *prompt, ParsedURL *current) gotoLabel(url + 1); return; } + if (relative) { + current = baseURL(Currentbuf); + referer = parsedURL2Str(&Currentbuf->currentURL)->ptr; + } + else { + current = NULL; + referer = NULL; + } parseURL2(url, &p_url, current); pushHashHist(URLHist, parsedURL2Str(&p_url)->ptr); - cmd_loadURL(url, current); + cmd_loadURL(url, current, referer); if (Currentbuf != cur_buf) /* success */ pushHashHist(URLHist, parsedURL2Str(&Currentbuf->currentURL)->ptr); } @@ -3653,13 +3671,13 @@ goURL0(char *prompt, ParsedURL *current) void goURL(void) { - goURL0("Goto URL: ", NULL); + goURL0("Goto URL: ", FALSE); } void gorURL(void) { - goURL0("Goto relative URL: ", baseURL(Currentbuf)); + goURL0("Goto relative URL: ", TRUE); } static void @@ -3685,7 +3703,7 @@ cmd_loadBuffer(Buffer *buf, int prop, int linkid) void ldBmark(void) { - cmd_loadURL(BookmarkFile, NULL); + cmd_loadURL(BookmarkFile, NULL, NO_REFERER); } @@ -3702,7 +3720,7 @@ adBmark(void) (Str_form_quote(parsedURL2Str(&Currentbuf->currentURL)))-> ptr, (Str_form_quote(Strnew_charp(Currentbuf->buffername)))->ptr); - cmd_loadURL(tmp->ptr, NULL); + cmd_loadURL(tmp->ptr, NULL, NO_REFERER); } /* option setting */ @@ -3788,7 +3806,8 @@ follow_map(struct parsed_tagarg *arg) } parseURL2(url, &p_url, baseURL(Currentbuf)); pushHashHist(URLHist, parsedURL2Str(&p_url)->ptr); - cmd_loadURL(url, baseURL(Currentbuf)); + cmd_loadURL(url, baseURL(Currentbuf), + parsedURL2Str(&Currentbuf->currentURL)->ptr); #else Buffer *buf; diff --git a/rc.c b/rc.c @@ -139,6 +139,7 @@ static char *config_file = NULL; #define CMT_IGNORE_NULL_IMG_ALT "空のIMG ALT属性の時にリンク名を表示する" #define CMT_IFILE "各ディレクトリのインデックスファイル" #define CMT_RETRY_HTTP "URLに自動的に http:// を補う" +#define CMT_DEFAULT_URL "URLを開く時のデフォルト文字列" #define CMT_DECODE_CTE "保存時に Content-Transfer-Encoding をデコードする" #ifdef USE_MOUSE #define CMT_MOUSE "マウスを使う" @@ -262,6 +263,7 @@ static char *config_file = NULL; #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" +#define CMT_DEFAULT_URL "Default string when opening URL" #define CMT_DECODE_CTE "Decode Content-Transfer-Encoding when saving" #ifdef USE_MOUSE #define CMT_MOUSE "Use mouse" @@ -369,6 +371,18 @@ static char n_s[][2] = { }; #define N_S(x) (x), n_s[(x)] +static struct sel_c defaulturls[] = { +#if LANG == JA + {N_S(DEFAULT_URL_EMPTY), "無し"}, + {N_S(DEFAULT_URL_CURRENT), "現在のURL"}, + {N_S(DEFAULT_URL_LINK), "リンク先のURL"}, +#else + {N_S(DEFAULT_URL_EMPTY), "empty"}, + {N_S(DEFAULT_URL_CURRENT), "current URL"}, + {N_S(DEFAULT_URL_LINK), "link URL"}, +#endif + {0, NULL, NULL} +}; #ifdef INET6 static struct sel_c dnsorders[] = { {N_S(DNS_ORDER_UNSPEC), "unspec"}, @@ -605,6 +619,9 @@ struct param_ptr params9[] = { NULL}, {"retry_http", P_INT, PI_ONOFF, (void *)&retryAsHttp, CMT_RETRY_HTTP, NULL}, + {"default_url", P_INT, PI_SEL_C, (void *)&DefaultURLString, + CMT_DEFAULT_URL, + defaulturls}, {"follow_redirection", P_INT, PI_TEXT, &FollowRedirection, CMT_FOLLOW_REDIRECTION, NULL}, {"meta_refresh", P_CHARINT, PI_ONOFF, (void *)&MetaRefresh,