[w3m-dev 03439] restore alarm event
* fm.h (AL_RESTORE): added * main.c (alarm_sec): deleted (alarm_status): deleted (alarm_buffer): deleted (alarm_event): deleted (AlarmEvent): added (CurrentAlarm): added (PrevAlarm): added (main): rewrite with CurrentAlarm (SigAlarm): rewrite with CurrentAlarm (copyAlarmEvent): added (setAlarm): if AL_RESTORE, copy back from PrevAlarm rewrite with CurrentAlarm From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
1 parent
587867d610
commit
f360ff56be
3 files changed
+82
-32
No files matched your search
@@ -1,3 +1,20 @@
|
|||||||
|
2002-11-16 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
||||||
|
|
||||||
|
* [w3m-dev 03439] restore alarm event
|
||||||
|
* fm.h (AL_RESTORE): added
|
||||||
|
* main.c (alarm_sec): deleted
|
||||||
|
(alarm_status): deleted
|
||||||
|
(alarm_buffer): deleted
|
||||||
|
(alarm_event): deleted
|
||||||
|
(AlarmEvent): added
|
||||||
|
(CurrentAlarm): added
|
||||||
|
(PrevAlarm): added
|
||||||
|
(main): rewrite with CurrentAlarm
|
||||||
|
(SigAlarm): rewrite with CurrentAlarm
|
||||||
|
(copyAlarmEvent): added
|
||||||
|
(setAlarm): if AL_RESTORE, copy back from PrevAlarm
|
||||||
|
rewrite with CurrentAlarm
|
||||||
|
|
||||||
2002-11-16 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
2002-11-16 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
||||||
|
|
||||||
* [w3m-dev 03438] Re: segmentation fault by large complex table.
|
* [w3m-dev 03438] Re: segmentation fault by large complex table.
|
||||||
@@ -4785,4 +4802,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
|||||||
* release-0-2-1
|
* release-0-2-1
|
||||||
* import w3m-0.2.1
|
* import w3m-0.2.1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.522 2002/11/15 16:00:33 ukai Exp $
|
$Id: ChangeLog,v 1.523 2002/11/15 16:05:13 ukai Exp $
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: fm.h,v 1.80 2002/11/15 15:58:27 ukai Exp $ */
|
/* $Id: fm.h,v 1.81 2002/11/15 16:05:15 ukai Exp $ */
|
||||||
/*
|
/*
|
||||||
* w3m: WWW wo Miru utility
|
* w3m: WWW wo Miru utility
|
||||||
*
|
*
|
||||||
@@ -1070,6 +1070,7 @@ void w3m_exit(int i);
|
|||||||
#define AL_IMPLICIT_DONE 4
|
#define AL_IMPLICIT_DONE 4
|
||||||
#define AL_ONCE 8
|
#define AL_ONCE 8
|
||||||
#define AL_IMPLICIT_ONCE (AL_IMPLICIT|AL_ONCE)
|
#define AL_IMPLICIT_ONCE (AL_IMPLICIT|AL_ONCE)
|
||||||
|
#define AL_RESTORE 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: main.c,v 1.135 2002/11/15 15:51:24 ukai Exp $ */
|
/* $Id: main.c,v 1.136 2002/11/15 16:05:15 ukai Exp $ */
|
||||||
#define MAINPROGRAM
|
#define MAINPROGRAM
|
||||||
#include "fm.h"
|
#include "fm.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -42,10 +42,19 @@ static Event eventQueue[N_EVENT_QUEUE];
|
|||||||
static int n_event_queue;
|
static int n_event_queue;
|
||||||
|
|
||||||
#ifdef USE_ALARM
|
#ifdef USE_ALARM
|
||||||
static int alarm_sec = 0;
|
typedef struct {
|
||||||
static short alarm_status = AL_UNSET;
|
int sec;
|
||||||
static Buffer *alarm_buffer;
|
int cmd;
|
||||||
static Event alarm_event;
|
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 MySignalHandler SigAlarm(SIGNAL_ARG);
|
static MySignalHandler SigAlarm(SIGNAL_ARG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -977,16 +986,18 @@ main(int argc, char **argv, char **envp)
|
|||||||
mouse_active();
|
mouse_active();
|
||||||
#endif /* USE_MOUSE */
|
#endif /* USE_MOUSE */
|
||||||
#ifdef USE_ALARM
|
#ifdef USE_ALARM
|
||||||
if (alarm_status & AL_IMPLICIT) {
|
if (CurrentAlarm.status & AL_IMPLICIT) {
|
||||||
alarm_buffer = Currentbuf;
|
CurrentAlarm.buffer = Currentbuf;
|
||||||
alarm_status = AL_IMPLICIT_DONE | (alarm_status & AL_ONCE);
|
CurrentAlarm.status = AL_IMPLICIT_DONE
|
||||||
|
| (CurrentAlarm.status & AL_ONCE);
|
||||||
}
|
}
|
||||||
else if (alarm_status & AL_IMPLICIT_DONE && alarm_buffer != Currentbuf) {
|
else if (CurrentAlarm.status & AL_IMPLICIT_DONE &&
|
||||||
setAlarmEvent(0, AL_UNSET, FUNCNAME_nulcmd, NULL);
|
CurrentAlarm.buffer != Currentbuf) {
|
||||||
|
setAlarmEvent(0, AL_RESTORE, FUNCNAME_nulcmd, NULL);
|
||||||
}
|
}
|
||||||
if (alarm_sec > 0) {
|
if (CurrentAlarm.sec > 0) {
|
||||||
signal(SIGALRM, SigAlarm);
|
signal(SIGALRM, SigAlarm);
|
||||||
alarm(alarm_sec);
|
alarm(CurrentAlarm.sec);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SIGWINCH
|
#ifdef SIGWINCH
|
||||||
@@ -1009,7 +1020,7 @@ main(int argc, char **argv, char **envp)
|
|||||||
signal(SIGWINCH, resize_hook);
|
signal(SIGWINCH, resize_hook);
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_ALARM
|
#ifdef USE_ALARM
|
||||||
if (alarm_sec > 0) {
|
if (CurrentAlarm.sec > 0) {
|
||||||
alarm(0);
|
alarm(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -5237,37 +5248,51 @@ SigAlarm(SIGNAL_ARG)
|
|||||||
{
|
{
|
||||||
char *data;
|
char *data;
|
||||||
|
|
||||||
if (alarm_sec > 0) {
|
if (CurrentAlarm.sec > 0) {
|
||||||
CurrentKey = -1;
|
CurrentKey = -1;
|
||||||
CurrentKeyData = NULL;
|
CurrentKeyData = NULL;
|
||||||
CurrentCmdData = data = (char *)alarm_event.user_data;
|
CurrentCmdData = data = (char *)CurrentAlarm.data;
|
||||||
#ifdef USE_MOUSE
|
#ifdef USE_MOUSE
|
||||||
if (use_mouse)
|
if (use_mouse)
|
||||||
mouse_inactive();
|
mouse_inactive();
|
||||||
#endif
|
#endif
|
||||||
w3mFuncList[alarm_event.cmd].func();
|
w3mFuncList[CurrentAlarm.cmd].func();
|
||||||
#ifdef USE_MOUSE
|
#ifdef USE_MOUSE
|
||||||
if (use_mouse)
|
if (use_mouse)
|
||||||
mouse_active();
|
mouse_active();
|
||||||
#endif
|
#endif
|
||||||
CurrentCmdData = NULL;
|
CurrentCmdData = NULL;
|
||||||
onA();
|
onA();
|
||||||
if (alarm_status & AL_IMPLICIT) {
|
if (CurrentAlarm.status & AL_IMPLICIT) {
|
||||||
alarm_buffer = Currentbuf;
|
CurrentAlarm.buffer = Currentbuf;
|
||||||
alarm_status = AL_IMPLICIT_DONE | (alarm_status & AL_ONCE);
|
CurrentAlarm.status = AL_IMPLICIT_DONE
|
||||||
|
| (CurrentAlarm.status & AL_ONCE);
|
||||||
}
|
}
|
||||||
else if (alarm_status & AL_IMPLICIT_DONE
|
else if (CurrentAlarm.status & AL_IMPLICIT_DONE
|
||||||
&& (alarm_buffer != Currentbuf || alarm_status & AL_ONCE)) {
|
&& (CurrentAlarm.buffer != Currentbuf ||
|
||||||
setAlarmEvent(0, AL_UNSET, FUNCNAME_nulcmd, NULL);
|
CurrentAlarm.status & AL_ONCE)) {
|
||||||
|
setAlarmEvent(0, AL_RESTORE, FUNCNAME_nulcmd, NULL);
|
||||||
}
|
}
|
||||||
if (alarm_sec > 0) {
|
if (CurrentAlarm.sec > 0) {
|
||||||
signal(SIGALRM, SigAlarm);
|
signal(SIGALRM, SigAlarm);
|
||||||
alarm(alarm_sec);
|
alarm(CurrentAlarm.sec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SIGNAL_RETURN;
|
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
|
void
|
||||||
setAlarm(void)
|
setAlarm(void)
|
||||||
{
|
{
|
||||||
@@ -5303,13 +5328,20 @@ setAlarm(void)
|
|||||||
void
|
void
|
||||||
setAlarmEvent(int sec, short status, int cmd, void *data)
|
setAlarmEvent(int sec, short status, int cmd, void *data)
|
||||||
{
|
{
|
||||||
if (status == AL_UNSET || status == AL_EXPLICIT
|
if (status == AL_RESTORE) {
|
||||||
|| (status & AL_IMPLICIT && alarm_status != AL_EXPLICIT)) {
|
copyAlarmEvent(&PrevAlarm, &CurrentAlarm);
|
||||||
alarm_sec = sec;
|
PrevAlarm.sec = 0;
|
||||||
alarm_status = status;
|
PrevAlarm.status = AL_UNSET;
|
||||||
alarm_event.cmd = cmd;
|
return;
|
||||||
alarm_event.user_data = data;
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user