Index: trunk/src/view.c =================================================================== --- trunk/src/view.c (revision 21268) +++ trunk/src/view.c (revision 21269) @@ -81,6 +81,23 @@ return NULL; } +pcb_view_t *pcb_view_by_uid_cnt(const pcb_view_list_t *lst, unsigned long int uid, size_t *cnt) +{ + pcb_view_t *v; + size_t c = 0; + + for(v = pcb_view_list_first((pcb_view_list_t *)lst); v != NULL; v = pcb_view_list_next(v), cnt++) { + if (v->uid == uid) { + *cnt = c; + return v; + } + } + + *cnt = -1; + return NULL; +} + + void pcb_view_goto(pcb_view_t *item) { if (item->have_bbox) { Index: trunk/src/view.h =================================================================== --- trunk/src/view.h (revision 21268) +++ trunk/src/view.h (revision 21269) @@ -93,8 +93,10 @@ void pcb_view_list_free(pcb_view_list_t *lst); -/* Slow, linear search for an UID in a list; returns NULL if not found */ +/* Slow, linear search for an UID in a list; returns NULL if not found; + optionally count the number of preceeding items and sotre it in cnt. */ pcb_view_t *pcb_view_by_uid(const pcb_view_list_t *lst, unsigned long int uid); +pcb_view_t *pcb_view_by_uid_cnt(const pcb_view_list_t *lst, unsigned long int uid, size_t *cnt); /* Zoom the drawing area to the drc error */ void pcb_view_goto(pcb_view_t *item);