4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * See the included file LICENSE for details.
9 #include <libtu/objlist.h>
10 #include <libtu/setparam.h>
18 static ObjList *taglist=NULL;
21 /*{{{ Adding/removing tags */
24 bool region_set_tagged(WRegion *reg, int sp)
26 bool set=(reg->flags®ION_TAGGED);
27 bool nset=libtu_do_setparam(sp, set);
30 if(reg->flags®ION_TAGGED){
31 reg->flags&=~REGION_TAGGED;
32 objlist_remove(&taglist, (Obj*)reg);
34 reg->flags|=REGION_TAGGED;
35 objlist_insert_last(&taglist, (Obj*)reg);
37 region_notify_change(reg, ioncore_g.notifies.tag);
45 * Change tagging state of \var{reg} as defined by \var{how}
46 * (one of \codestr{set}, \codestr{unset}, or \codestr{toggle}).
47 * The resulting state is returned.
49 EXTL_EXPORT_AS(WRegion, set_tagged)
50 bool region_set_tagged_extl(WRegion *reg, const char *how)
52 return region_set_tagged(reg, libtu_string_to_setparam(how));
57 * Is \var{reg} tagged?
61 bool region_is_tagged(WRegion *reg)
63 return ((reg->flags®ION_TAGGED)!=0);
71 void ioncore_tagged_clear()
73 while(ioncore_tagged_first(TRUE)!=NULL)
85 * Returns first tagged object, untagging it as well if \var{untag} is set.
89 WRegion *ioncore_tagged_first(bool untag)
94 reg=(WRegion*)OBJLIST_FIRST(WRegion*, taglist);
96 reg=(WRegion*)objlist_take_first(&taglist);
99 reg->flags&=~REGION_TAGGED;
100 region_notify_change(reg, ioncore_g.notifies.tag);
109 * Iterate over tagged regions until \var{iterfn} returns \code{false}.
110 * The function itself returns \code{true} if it reaches the end of list
111 * without this happening.
115 bool ioncore_tagged_i(ExtlFn iterfn)
117 return extl_iter_objlist(iterfn, taglist);