w3m

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

commit 6c4c594c2addd60648d120e2c34d73550d2c65c6
parent 8dadb5fe84af0862bca2e88f4638189bf9f97f40
Author: ukai <ukai>
Date:   Tue, 20 Nov 2001 08:20:56 +0000

[w3m-dev 02449] reimplemented meta refresh support
From: Tsutomu Okada <okada@furuno.co.jp>

Diffstat:
MChangeLog | 21+++++++++++++++++++++
Mfile.c | 13+++++++++----
Mfm.h | 11++++-------
Mmain.c | 48+++++++++++++++++++++++++++++++++++++++---------
Mproto.h | 1+
5 files changed, 74 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,24 @@ +2001-11-20 Tsutomu Okada <okada@furuno.co.jp> + + * file.c (HTMLtagproc1): reimplement meta refresh with + setAlarmEvent() + + * fm.h: put back alarm related variables to main.c + add alarm related status flags + + * main.c: put back alarm related variables from fm.h + alarm_once was renamed alarm_status + add alarm_buffer and setAlarmEvent() + + * main.c (MAIN): cancel the alarm event if the buffer was + changed + + * main.c (SigAlarm): ditto + + * main.c (setAlarm): use setAlarmEvent() + + * proto.h: add setAlarmEvent() + 2001-11-20 Fumitoshi UKAI <ukai@debian.or.jp> * w3mhelperpanel.c (extractMailcapEntry): remove unused variables diff --git a/file.c b/file.c @@ -3579,13 +3579,18 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) } #ifdef USE_ALARM else if (!is_redisplay && refresh > 0 && MetaRefresh) { - alarm_sec = refresh; - alarm_once = TRUE; - alarm_event.cmd = FUNCNAME_goURL; - alarm_event.user_data = s_tmp->ptr; + setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_goURL, s_tmp->ptr); } #endif } +#ifdef USE_ALARM + else if (!is_redisplay && refresh > 0 && MetaRefresh) { + tmp = Sprintf("Refresh (%d sec)", refresh); + push_str(obuf, 0, tmp, PC_ASCII); + flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); + setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_reload, NULL); + } +#endif } return 1; case HTML_BASE: diff --git a/fm.h b/fm.h @@ -849,14 +849,11 @@ int backend( void ); extern void deleteFiles(void); void w3m_exit( int i ); -typedef struct { - int cmd; - void *user_data; -} Event; #ifdef USE_ALARM -global int alarm_sec init(0); -global short alarm_once init(0); -global Event alarm_event; +#define AL_UNSET 0 +#define AL_EXPLICIT 1 +#define AL_IMPLICIT 2 +#define AL_IMPLICIT_DONE 3 #endif /* diff --git a/main.c b/main.c @@ -32,11 +32,19 @@ Hist *URLHist; Hist *ShellHist; Hist *TextHist; +typedef struct { + int cmd; + void *user_data; +} Event; #define N_EVENT_QUEUE 10 static Event eventQueue[N_EVENT_QUEUE]; static int n_event_queue; #ifdef USE_ALARM +static int alarm_sec = 0; +static short alarm_status = AL_UNSET; +static Buffer *alarm_buffer; +static Event alarm_event; static MySignalHandler SigAlarm(SIGNAL_ARG); #endif @@ -845,6 +853,13 @@ MAIN(int argc, char **argv, char **envp) mouse_active(); #endif /* MOUSE */ #ifdef USE_ALARM + if (alarm_status == AL_IMPLICIT) { + alarm_buffer = Currentbuf; + alarm_status = AL_IMPLICIT_DONE; + } else if (alarm_status == AL_IMPLICIT_DONE && alarm_buffer != Currentbuf) { + alarm_sec = 0; + alarm_status = AL_UNSET; + } if (alarm_sec > 0) { signal(SIGALRM, SigAlarm); alarm(alarm_sec); @@ -4609,10 +4624,17 @@ SigAlarm(SIGNAL_ARG) #endif w3mFuncList[alarm_event.cmd].func(); onA(); - if (alarm_once) + if (alarm_status == AL_IMPLICIT) { + alarm_buffer = Currentbuf; + alarm_status = AL_IMPLICIT_DONE; + } else if (alarm_status == AL_IMPLICIT_DONE && alarm_buffer != Currentbuf) { alarm_sec = 0; - signal(SIGALRM, SigAlarm); - alarm(alarm_sec); + alarm_status = AL_UNSET; + } + if (alarm_sec > 0) { + signal(SIGALRM, SigAlarm); + alarm(alarm_sec); + } } SIGNAL_RETURN; } @@ -4639,15 +4661,23 @@ setAlarm(void) cmd = getFuncList(getWord(&data), w3mFuncList, w3mNFuncList); } if (cmd >= 0) { - alarm_sec = sec; - alarm_once = FALSE; - alarm_event.cmd = cmd; - alarm_event.user_data = getQWord(&data); - signal(SIGALRM, SigAlarm); - alarm(alarm_sec); + setAlarmEvent(sec, AL_EXPLICIT, cmd, getQWord(&data)); } else { alarm_sec = 0; } displayBuffer(Currentbuf, B_NORMAL); } + +void +setAlarmEvent(int sec, short status, int cmd, void *data) +{ + if (status == AL_EXPLICIT || (status == AL_IMPLICIT && alarm_status != AL_EXPLICIT)) { + alarm_sec = sec; + alarm_status = status; + alarm_event.cmd = cmd; + alarm_event.user_data = data; + signal(SIGALRM, SigAlarm); + alarm(alarm_sec); + } +} #endif diff --git a/proto.h b/proto.h @@ -100,6 +100,7 @@ extern void linkbrz(void); extern void curlno(void); #ifdef USE_ALARM extern void setAlarm(void); +extern void setAlarmEvent(int sec, short status, int cmd, void *data); #else #define setAlarm nulcmd #endif