Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

htidle.cc

Go to the documentation of this file.
00001 /*
00002  *      HT Editor
00003  *      htidle.cc
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #include "htdata.h"
00022 #include "htdebug.h"
00023 #include "htidle.h"
00024 #include "htkeyb.h"
00025 #include "htsys.h"
00026 
00027 ht_clist *idle_objs;
00028 
00029 int cur_idle=0;
00030 bool any_idles=0;
00031 
00032 void register_idle_object(Object *o)
00033 {
00034         idle_objs->insert(o);
00035 }
00036 
00037 void unregister_idle_object(Object *o)
00038 {
00039         int c=idle_objs->count();
00040         for (int i=0; i<c; i++) if (idle_objs->get(i)==o) {
00041                 idle_objs->remove(i);
00042         }
00043 }
00044 
00045 void do_idle()
00046 {
00047         int c=idle_objs->count();
00048         if (c) {
00049                 if (cur_idle>=c) {
00050                         cur_idle=0;
00051                         if (!any_idles) sys_suspend();
00052                         any_idles=0;
00053                 }
00054                 Object *i=idle_objs->get(cur_idle);
00055                 assert(i);
00056                 any_idles|=i->idle();
00057                 cur_idle++;
00058         } else {
00059                 sys_suspend();
00060         }
00061 }
00062 
00063 /*
00064  *      INIT
00065  */
00066 
00067 bool init_idle()
00068 {
00069         idle_objs=new ht_clist();
00070         idle_objs->init();
00071         return true;
00072 }
00073 
00074 /*
00075  *      DONE
00076  */
00077 
00078 void done_idle()
00079 {
00080         idle_objs->done();
00081         delete idle_objs;
00082 }

Generated on Fri May 7 21:15:34 2004 by doxygen 1.3.5