/*--------------------------------*-C-*---------------------------------*
* File: command.c
*----------------------------------------------------------------------*
- * $Id: command.C,v 1.23 2003-12-18 14:11:47 pcg Exp $
+ * $Id: command.C,v 1.24 2003-12-19 06:17:03 pcg Exp $
*
* All portions of code are copyright by their respective author/s.
* Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
}
XFlush (Xdisplay);
-#if 0
- if (XPending (Xdisplay)) process_x_events ();
- if (XPending (Xdisplay)) process_x_events ();
-#endif
}
void
}
#endif
+#if IOM_IDLE
+idle_watcher::~idle_watcher ()
+{
+ if (iom_valid)
+ iom.unreg (this);
+}
+
+void io_manager::reg (idle_watcher *w)
+{
+ reg (w, iw);
+}
+
+void io_manager::unreg (idle_watcher *w)
+{
+ unreg (w, iw);
+}
+#endif
+
#if IOM_TIME
inline void set_now (void)
{
for (;;)
{
struct timeval *to = 0;
-
-#if IOM_TIME
struct timeval tval;
- time_watcher *w;
- for (;tw.size ();)
+#if IOM_IDLE
+ if (iw.size ())
{
- w = tw[0];
-
- for (time_watcher **i = tw.begin (); i < tw.end (); ++i)
- if ((*i)->at < w->at)
- w = *i;
+ tval.tv_sec = 0;
+ tval.tv_usec = 0;
+ to = &tval;
+ }
+ else
+#endif
+ {
+#if IOM_TIME
+ time_watcher *w;
- if (w->at > NOW)
+ for (;tw.size ();)
{
- double diff = w->at - NOW;
- tval.tv_sec = (int)diff;
- tval.tv_usec = (int)((diff - tval.tv_sec) * 1000000);
- to = &tval;
- break;
+ w = tw[0];
+
+ for (time_watcher **i = tw.begin (); i < tw.end (); ++i)
+ if ((*i)->at < w->at)
+ w = *i;
+
+ if (w->at > NOW)
+ {
+ double diff = w->at - NOW;
+ tval.tv_sec = (int)diff;
+ tval.tv_usec = (int)((diff - tval.tv_sec) * 1000000);
+ to = &tval;
+ break;
+ }
+ else if (w->at >= 0)
+ w->call (*w);
+ else
+ unreg (w);
}
- else if (w->at >= 0)
- w->call (*w);
- else
- unreg (w);
- }
#endif
+ }
#if IOM_CHECK
for (int i = 0; i < cw.size (); ++i)
if (revents)
w->call (*w, revents);
}
+#if IOM_IDLE
+ else if (iw.size ())
+ for (int i = 0; i < iw.size (); ++i)
+ iw[i]->call (*iw[i]);
+#endif
+
#elif IOM_TIME
if (!to)
break;
#define IOM_IO 1
#define IOM_TIME 1
#define IOM_CHECK 1
+#define IOM_IDLE 0
#if IOM_IO
typedef double tstamp;
#if IOM_CHECK
struct check_watcher;
#endif
+#if IOM_IDLE
+ struct idle_watcher;
+#endif
class io_manager {
#if IOM_IO
#if IOM_TIME
simplevec<time_watcher *> tw;
#endif
+#if IOM_IDLE
+ simplevec<idle_watcher *> iw;
+#endif
template<class watcher>
void reg (watcher *w, simplevec<watcher *> &queue);
public:
// register a watcher
#if IOM_IO
- void reg (io_watcher *w); void unreg (io_watcher *w);
+ void reg (io_watcher *w); void unreg (io_watcher *w);
#endif
#if IOM_TIME
- void reg (time_watcher *w); void unreg (time_watcher *w);
+ void reg (time_watcher *w); void unreg (time_watcher *w);
#endif
#if IOM_CHECK
void reg (check_watcher *w); void unreg (check_watcher *w);
#endif
+#if IOM_IDLE
+ void reg (idle_watcher *w); void unreg (idle_watcher *w);
+#endif
void loop ();
~io_watcher ();
- void set(int fd_, short events_) { fd = fd_; events = events_; }
+ void set (int fd_, short events_) { fd = fd_; events = events_; }
- void set(short events_) { set (fd, events_); }
+ void set (short events_) { set (fd, events_); }
+ void start () { iom.reg (this); }
void start (int fd_, short events_) { set (fd_, events_); iom.reg (this); }
void stop () { iom.unreg (this); }
};
};
#endif
+#if IOM_IDLE
+// run after checking for any i/o, but before waiting
+struct idle_watcher : callback1<void, idle_watcher &> {
+ template<class O1, class O2>
+ idle_watcher (O1 *object, void (O2::*method)(idle_watcher &))
+ : callback1<void, idle_watcher &>(object,method)
+ { }
+
+ ~idle_watcher ();
+
+ void start () { iom.reg (this); }
+ void stop () { iom.unreg (this); }
+};
+#endif
+
#endif
/*--------------------------------*-C-*---------------------------------*
* File: main.c
*----------------------------------------------------------------------*
- * $Id: main.C,v 1.17 2003-12-18 13:33:02 pcg Exp $
+ * $Id: main.C,v 1.18 2003-12-19 06:17:03 pcg Exp $
*
* All portions of code are copyright by their respective author/s.
* Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
}
rxvt_term::rxvt_term ()
-: pty_ev (this, &rxvt_term::pty_cb),
+: destroy_ev (this, &rxvt_term::destroy_cb),
#ifdef CURSOR_BLINK
blink_ev (this, &rxvt_term::blink_cb),
#endif
pointer_ev (this, &rxvt_term::pointer_cb),
#endif
x_ev (this, &rxvt_term::x_cb),
- destroy_ev (this, &rxvt_term::destroy_cb),
check_ev (this, &rxvt_term::check_cb),
- incr_ev (this, &rxvt_term::incr_cb)
+ incr_ev (this, &rxvt_term::incr_cb),
+ pty_ev (this, &rxvt_term::pty_cb)
{
cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
}