Add slide_delete_item()
authorThomas White <taw@bitwiz.me.uk>
Thu, 2 May 2019 20:59:36 +0000 (22:59 +0200)
committerThomas White <taw@bitwiz.me.uk>
Thu, 2 May 2019 21:04:23 +0000 (23:04 +0200)
libstorycode/slide.c
libstorycode/slide.h

index f5c4c9c..fc7b24c 100644 (file)
@@ -57,6 +57,21 @@ void slide_free(Slide *s)
 }
 
 
+void slide_delete_item(Slide *s, SlideItem *item)
+{
+       int i;
+       for ( i=0; i<s->n_items; i++ ) {
+               if ( &s->items[i] == item ) {
+                       memmove(&s->items[i], &s->items[i+1],
+                               (s->n_items-i-1)*sizeof(SlideItem));
+                       s->n_items--;
+                       return;
+               }
+       }
+       fprintf(stderr, "Didn't find slide item to delete!\n");
+}
+
+
 static SlideItem *add_item(Slide *s)
 {
        SlideItem *new_items;
index 3957f9e..3dbd20e 100644 (file)
@@ -37,6 +37,8 @@ typedef struct _slideitem SlideItem;
 extern Slide *slide_new(void);
 extern void slide_free(Slide *s);
 
+extern void slide_delete_item(Slide *s, SlideItem *item);
+
 extern SlideItem *slide_add_image(Slide *s, char *filename, struct frame_geom geom);
 extern SlideItem *slide_add_text(Slide *s, char **text, int n_text,
                                  struct frame_geom geom, enum alignment alignment);