X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Ftags.c;h=383af0c116a0a3a67c2454dd644acfa7757d1b92;hp=6b7d5c24431cd34c9ec6680c9d3ae4dfd3a17db2;hb=803afbc1cd633f6c025bcd9537e9b7e9aedadd0d;hpb=8366314611bf30a0f31d25bf5f5023186fa87692 diff --git a/ioncore/tags.c b/ioncore/tags.c index 6b7d5c2..383af0c 100644 --- a/ioncore/tags.c +++ b/ioncore/tags.c @@ -1,7 +1,7 @@ /* * ion/ioncore/tags.c * - * Copyright (c) Tuomo Valkonen 1999-2006. + * Copyright (c) Tuomo Valkonen 1999-2007. * * Ion is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by @@ -11,8 +11,11 @@ #include #include + +#include "global.h" #include "region.h" #include "tags.h" +#include "extlconv.h" static ObjList *taglist=NULL; @@ -34,7 +37,7 @@ bool region_set_tagged(WRegion *reg, int sp) reg->flags|=REGION_TAGGED; objlist_insert_last(&taglist, (Obj*)reg); } - region_notify_change(reg, "tag"); + region_notify_change(reg, ioncore_g.notifies.tag); } return nset; @@ -69,7 +72,7 @@ bool region_is_tagged(WRegion *reg) EXTL_EXPORT void ioncore_clear_tags() { - while(ioncore_tags_take_first()!=NULL) + while(ioncore_tagged_take_first()!=NULL) /* nothing */; } @@ -85,48 +88,34 @@ void ioncore_clear_tags() */ EXTL_SAFE EXTL_EXPORT -WRegion *ioncore_tags_first() +WRegion *ioncore_tagged_first() { return (WRegion*)OBJLIST_FIRST(WRegion*, taglist); } -WRegion *ioncore_tags_take_first() +WRegion *ioncore_tagged_take_first() { WRegion *reg=(WRegion*)objlist_take_first(&taglist); if(reg!=NULL){ reg->flags&=~REGION_TAGGED; - region_notify_change(reg, "tag"); + region_notify_change(reg, ioncore_g.notifies.tag); } return reg; } /*EXTL_DOC - * Returns a list of tagged regions. + * Iterate over tagged regions until \var{iterfn} returns \code{false}. + * The function itself returns \code{true} if it reaches the end of list + * without this happening. */ EXTL_SAFE EXTL_EXPORT -ExtlTab ioncore_tagged_list() +bool ioncore_tagged_i(ExtlFn iterfn) { - int n=0; - ExtlTab tab; - WRegion *region; - ObjListIterTmp tmp; - - region=ioncore_tags_first(); - if(!region) - return extl_table_none(); - - tab=extl_create_table(); - - FOR_ALL_ON_OBJLIST(WRegion*, region, taglist, tmp){ - if(extl_table_seti_o(tab, n+1, (Obj*)region)) - n++; - } - - return tab; + return extl_iter_objlist(iterfn, taglist); }