diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-18 16:20:49 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-18 16:20:49 +0000 |
commit | 6189d68a7864a2ce5e2943ea13e79cbb241342a5 (patch) | |
tree | 66d09fdcf121e1b714dbdc849537680949d9b324 | |
parent | [w3m-dev 03577] incorrect table width (diff) | |
download | w3m-6189d68a7864a2ce5e2943ea13e79cbb241342a5.tar.gz w3m-6189d68a7864a2ce5e2943ea13e79cbb241342a5.zip |
[w3m-dev 03578] meta refresh
* file.c (getMetaRefreshParam): do nothing if refresh_interval < 0
(HTMLtagproc1): rewrite refresh
(HTMLlineproc2body): add HTML_META
* fm.h (BP_RELOAD): deleted
(Buffer): add event
(AL_IMPLICIT_DONE): deleted
(AL_ONCE): deleted
(AL_RESTORE): deleted
(AlarmEvent): added
* main.c (AlarmEvent): deleted
(PrevAlarm): deleted
(DefaultAlarm): added
(CurrentAlarm): point to DefaultAlarm
(main): CurrentKeyData, CurrentCmdData
handle Currentbuf->event
(SigAlarm): CurrentAlarm is pointer
(copyAlarmEvent): deleted
(setAlarm): setAlarmEvent pass &DefaultAlarm
(setAlarmEvent): arg event
(ldDL): no BP_RELOAD
* proto.h (setAlarmEvent): arg event
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | file.c | 85 | ||||
-rw-r--r-- | fm.h | 18 | ||||
-rw-r--r-- | main.c | 132 | ||||
-rw-r--r-- | proto.h | 5 |
5 files changed, 145 insertions, 122 deletions
@@ -1,3 +1,28 @@ +2002-12-19 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03578] meta refresh + * file.c (getMetaRefreshParam): do nothing if refresh_interval < 0 + (HTMLtagproc1): rewrite refresh + (HTMLlineproc2body): add HTML_META + * fm.h (BP_RELOAD): deleted + (Buffer): add event + (AL_IMPLICIT_DONE): deleted + (AL_ONCE): deleted + (AL_RESTORE): deleted + (AlarmEvent): added + * main.c (AlarmEvent): deleted + (PrevAlarm): deleted + (DefaultAlarm): added + (CurrentAlarm): point to DefaultAlarm + (main): CurrentKeyData, CurrentCmdData + handle Currentbuf->event + (SigAlarm): CurrentAlarm is pointer + (copyAlarmEvent): deleted + (setAlarm): setAlarmEvent pass &DefaultAlarm + (setAlarmEvent): arg event + (ldDL): no BP_RELOAD + * proto.h (setAlarmEvent): arg event + 2002-12-18 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03577] incorrect table width @@ -5897,4 +5922,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.627 2002/12/17 16:17:28 ukai Exp $ +$Id: ChangeLog,v 1.628 2002/12/18 16:20:49 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.162 2002/12/14 15:26:44 ukai Exp $ */ +/* $Id: file.c,v 1.163 2002/12/18 16:20:51 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -3999,6 +3999,8 @@ getMetaRefreshParam(char *q, Str *refresh_uri) return 0; refresh_interval = atoi(q); + if (refresh_interval < 0) + return 0; while (*q) { if (!strncasecmp(q, "url=", 4)) { @@ -4726,41 +4728,26 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) else #endif if (p && q && !strcasecmp(p, "refresh")) { - Str s_tmp = NULL; - int refresh_interval = getMetaRefreshParam(q, &s_tmp); - if (s_tmp) { - q = html_quote(s_tmp->ptr); - tmp = - Sprintf - ("Refresh (%d sec) <a hseq=\"%d\" href=\"%s\">%s</a>", - refresh_interval, cur_hseq++, q, q); - push_str(obuf, s_tmp->length, tmp, PC_ASCII); - flushline(h_env, obuf, envs[h_env->envc].indent, 0, - h_env->limit); - if (!is_redisplay && refresh_interval == 0 && MetaRefresh && - !((obuf->flag & RB_NOFRAMES) && RenderFrame)) { - pushEvent(FUNCNAME_gorURL, s_tmp->ptr); - /* pushEvent(deletePrevBuf,NULL); */ - } -#ifdef USE_ALARM - else if (!is_redisplay && refresh_interval > 0 && MetaRefresh - && !((obuf->flag & RB_NOFRAMES) && RenderFrame)) { - setAlarmEvent(refresh_interval, AL_IMPLICIT_ONCE, - FUNCNAME_gorURL, s_tmp->ptr); - } -#endif + int refresh_interval; + tmp = NULL; + refresh_interval = getMetaRefreshParam(q, &tmp); + if (tmp) { + q = html_quote(tmp->ptr); + tmp = Sprintf("Refresh (%d sec) <a href=\"%s\">%s</a>", + refresh_interval, q, q); } -#ifdef USE_ALARM - else if (!is_redisplay && refresh_interval > 0 && MetaRefresh && - !((obuf->flag & RB_NOFRAMES) && RenderFrame)) { + else if (refresh_interval > 0) tmp = Sprintf("Refresh (%d sec)", refresh_interval); - push_str(obuf, 0, tmp, PC_ASCII); - flushline(h_env, obuf, envs[h_env->envc].indent, 0, - h_env->limit); - setAlarmEvent(refresh_interval, AL_IMPLICIT, FUNCNAME_reload, - NULL); + if (tmp) { + HTMLlineproc1(tmp->ptr, h_env); + do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, + h_env->limit); + if (!is_redisplay && + !((obuf->flag & RB_NOFRAMES) && RenderFrame)) { + tag->need_reconstruct = TRUE; + return 0; + } } -#endif } return 1; case HTML_BASE: @@ -5315,6 +5302,38 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) buf->baseTarget = url_quote_conv(p, buf->document_code); break; + case HTML_META: + p = q = NULL; + parsedtag_get_value(tag, ATTR_HTTP_EQUIV, &p); + parsedtag_get_value(tag, ATTR_CONTENT, &q); + if (p && q && !strcasecmp(p, "refresh") && MetaRefresh) { + Str tmp = NULL; + int refresh_interval = getMetaRefreshParam(q, &tmp); +#ifdef USE_ALARM + if (tmp) { + p = url_quote_conv(remove_space(tmp->ptr), + buf->document_code); + buf->event = setAlarmEvent(buf->event, + refresh_interval, + AL_IMPLICIT_ONCE, + FUNCNAME_gorURL, + p); + } + else if (refresh_interval > 0) + buf->event = setAlarmEvent(buf->event, + refresh_interval, + AL_IMPLICIT, + FUNCNAME_reload, + NULL); +#else + if (tmp && refresh_interval == 0) { + p = url_quote_conv(remove_space(tmp->ptr), + buf->document_code); + pushEvent(FUNCNAME_gorURL, p); + } +#endif + } + break; case HTML_INTERNAL: internal = HTML_INTERNAL; break; @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.97 2002/12/14 15:24:04 ukai Exp $ */ +/* $Id: fm.h,v 1.98 2002/12/18 16:20:52 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -177,7 +177,6 @@ void bzero(void *, int); #define BP_NO_URL 0x10 #define BP_REDIRECTED 0x20 #define BP_CLOSE 0x40 -#define BP_RELOAD 0x80 /* Link Buffer */ #define LB_NOLINK -1 @@ -462,6 +461,9 @@ typedef struct _Buffer { char need_reshape; Anchor *submit; struct _BufferPos *undo; +#ifdef USE_ALARM + struct _AlarmEvent *event; +#endif } Buffer; typedef struct _BufferPos { @@ -1116,10 +1118,14 @@ void w3m_exit(int i); #define AL_UNSET 0 #define AL_EXPLICIT 1 #define AL_IMPLICIT 2 -#define AL_IMPLICIT_DONE 4 -#define AL_ONCE 8 -#define AL_IMPLICIT_ONCE (AL_IMPLICIT|AL_ONCE) -#define AL_RESTORE 16 +#define AL_IMPLICIT_ONCE 3 + +typedef struct _AlarmEvent { + int sec; + short status; + int cmd; + void *data; +} AlarmEvent; #endif /* @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.170 2002/12/16 15:41:35 ukai Exp $ */ +/* $Id: main.c,v 1.171 2002/12/18 16:20:53 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -42,19 +42,10 @@ static Event eventQueue[N_EVENT_QUEUE]; static int n_event_queue; #ifdef USE_ALARM -typedef struct { - int sec; - int cmd; - void *data; - short status; - Buffer *buffer; -} AlarmEvent; -static AlarmEvent CurrentAlarm = { - 0, FUNCNAME_nulcmd, NULL, AL_UNSET, NULL -}; -static AlarmEvent PrevAlarm = { - 0, FUNCNAME_nulcmd, NULL, AL_UNSET, NULL +static AlarmEvent DefaultAlarm = { + 0, FUNCNAME_nulcmd, NULL, AL_UNSET, }; +static AlarmEvent *CurrentAlarm = &DefaultAlarm; static MySignalHandler SigAlarm(SIGNAL_ARG); #endif @@ -1000,34 +991,42 @@ main(int argc, char **argv, char **envp) if (n_event_queue > 0) { for (i = 0; i < n_event_queue; i++) { CurrentKey = -1; - CurrentKeyData = eventQueue[i].user_data; - CurrentCmdData = NULL; + CurrentKeyData = NULL; + CurrentCmdData = (char *)eventQueue[i].user_data; w3mFuncList[eventQueue[i].cmd].func(); } + CurrentCmdData = NULL; n_event_queue = 0; } - CurrentKeyData = NULL; /* get keypress event */ +#ifdef USE_ALARM + if (Currentbuf->event) { + if (Currentbuf->event->status != AL_UNSET) { + CurrentAlarm = Currentbuf->event; + if (CurrentAlarm->sec == 0) { /* refresh (0sec) */ + Currentbuf->event = NULL; + CurrentKey = -1; + CurrentKeyData = NULL; + CurrentCmdData = (char *)CurrentAlarm->data; + w3mFuncList[CurrentAlarm->cmd].func(); + CurrentCmdData = NULL; + } + } + else + Currentbuf->event = NULL; + } + if (!Currentbuf->event) + CurrentAlarm = &DefaultAlarm; +#endif #ifdef USE_MOUSE mouse_action.in_action = FALSE; if (use_mouse) mouse_active(); #endif /* USE_MOUSE */ #ifdef USE_ALARM - if (Currentbuf->bufferprop & BP_RELOAD) - setAlarmEvent(1, AL_IMPLICIT, FUNCNAME_reload, NULL); - if (CurrentAlarm.status & AL_IMPLICIT) { - CurrentAlarm.buffer = Currentbuf; - CurrentAlarm.status = AL_IMPLICIT_DONE - | (CurrentAlarm.status & AL_ONCE); - } - else if (CurrentAlarm.status & AL_IMPLICIT_DONE && - CurrentAlarm.buffer != Currentbuf) { - setAlarmEvent(0, AL_RESTORE, FUNCNAME_nulcmd, NULL); - } - if (CurrentAlarm.sec > 0) { + if (CurrentAlarm->sec > 0) { signal(SIGALRM, SigAlarm); - alarm(CurrentAlarm.sec); + alarm(CurrentAlarm->sec); } #endif #ifdef SIGWINCH @@ -1050,7 +1049,7 @@ main(int argc, char **argv, char **envp) signal(SIGWINCH, resize_hook); #endif #ifdef USE_ALARM - if (CurrentAlarm.sec > 0) { + if (CurrentAlarm->sec > 0) { alarm(0); } #endif @@ -1077,6 +1076,7 @@ main(int argc, char **argv, char **envp) } prev_key = CurrentKey; CurrentKey = -1; + CurrentKeyData = NULL; } } @@ -5496,51 +5496,32 @@ SigAlarm(SIGNAL_ARG) { char *data; - if (CurrentAlarm.sec > 0) { + if (CurrentAlarm->sec > 0) { CurrentKey = -1; CurrentKeyData = NULL; - CurrentCmdData = data = (char *)CurrentAlarm.data; + CurrentCmdData = data = (char *)CurrentAlarm->data; #ifdef USE_MOUSE if (use_mouse) mouse_inactive(); #endif - w3mFuncList[CurrentAlarm.cmd].func(); - displayBuffer(Currentbuf, B_NORMAL); + w3mFuncList[CurrentAlarm->cmd].func(); #ifdef USE_MOUSE if (use_mouse) mouse_active(); #endif CurrentCmdData = NULL; - if (CurrentAlarm.status & AL_IMPLICIT) { - CurrentAlarm.buffer = Currentbuf; - CurrentAlarm.status = AL_IMPLICIT_DONE - | (CurrentAlarm.status & AL_ONCE); - } - else if (CurrentAlarm.status & AL_IMPLICIT_DONE - && (CurrentAlarm.buffer != Currentbuf || - CurrentAlarm.status & AL_ONCE)) { - setAlarmEvent(0, AL_RESTORE, FUNCNAME_nulcmd, NULL); + if (CurrentAlarm->status == AL_IMPLICIT_ONCE) { + CurrentAlarm->sec = 0; + CurrentAlarm->status = AL_UNSET; } - if (CurrentAlarm.sec > 0) { + if (CurrentAlarm->sec > 0) { signal(SIGALRM, SigAlarm); - alarm(CurrentAlarm.sec); + alarm(CurrentAlarm->sec); } } SIGNAL_RETURN; } -static void -copyAlarmEvent(AlarmEvent * src, AlarmEvent * dst) -{ - if (!src || !dst) - return; - dst->sec = src->sec; - dst->cmd = src->cmd; - dst->data = src->data; - dst->status = src->status; - dst->buffer = src->buffer; -} - void setAlarm(void) { @@ -5563,33 +5544,26 @@ setAlarm(void) } if (cmd >= 0) { data = getQWord(&data); - setAlarmEvent(sec, AL_EXPLICIT, cmd, data); + setAlarmEvent(&DefaultAlarm, sec, AL_EXPLICIT, cmd, data); disp_message_nsec(Sprintf("%dsec %s %s", sec, w3mFuncList[cmd].id, data)->ptr, FALSE, 1, FALSE, TRUE); } else { - setAlarmEvent(0, AL_UNSET, FUNCNAME_nulcmd, NULL); + setAlarmEvent(&DefaultAlarm, 0, AL_UNSET, FUNCNAME_nulcmd, NULL); } displayBuffer(Currentbuf, B_NORMAL); } -void -setAlarmEvent(int sec, short status, int cmd, void *data) +AlarmEvent * +setAlarmEvent(AlarmEvent *event, int sec, short status, int cmd, void *data) { - if (status == AL_RESTORE) { - copyAlarmEvent(&PrevAlarm, &CurrentAlarm); - PrevAlarm.sec = 0; - PrevAlarm.status = AL_UNSET; - return; - } - if (CurrentAlarm.status == AL_EXPLICIT && - (status == AL_IMPLICIT || status == AL_IMPLICIT_ONCE)) - copyAlarmEvent(&CurrentAlarm, &PrevAlarm); - CurrentAlarm.sec = sec; - CurrentAlarm.cmd = cmd; - CurrentAlarm.data = data; - CurrentAlarm.status = status; - CurrentAlarm.buffer = NULL; + if (event == NULL) + event = New(AlarmEvent); + event->sec = sec; + event->status = status; + event->cmd = cmd; + event->data = data; + return event; } #endif @@ -6257,7 +6231,6 @@ ldDL(void) delete = TRUE; if (!FirstDL) { if (delete) { - Currentbuf->bufferprop &= ~BP_RELOAD; if (Currentbuf == Firstbuf && Currentbuf->nextBuffer == NULL) { if (nTab > 1) deleteTab(CurrentTab); @@ -6287,10 +6260,9 @@ ldDL(void) if (delete) deletePrevBuf(); #ifdef USE_ALARM - if (reload) { - Currentbuf->bufferprop |= BP_RELOAD; - setAlarmEvent(1, AL_IMPLICIT, FUNCNAME_reload, NULL); - } + if (reload) + Currentbuf->event = setAlarmEvent(Currentbuf->event, 1, AL_IMPLICIT, + FUNCNAME_reload, NULL); #endif } @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.72 2002/12/14 15:18:38 ukai Exp $ */ +/* $Id: proto.h,v 1.73 2002/12/18 16:20:54 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -115,7 +115,8 @@ extern void stopI(void); #endif #ifdef USE_ALARM extern void setAlarm(void); -extern void setAlarmEvent(int sec, short status, int cmd, void *data); +extern AlarmEvent *setAlarmEvent(AlarmEvent *event, int sec, short status, + int cmd, void *data); #else #define setAlarm nulcmd #endif |