[add more doubly linked list features for script lines
John Meacham <john@repetae.net>**20060811063739] {
hunk ./script.c 2
+#include <assert.h>
+
hunk ./script.c 8
+
hunk ./script.c 28
+
hunk ./script.c 32
+static script_line_t *
+script_line_new(void)
+{
+        script_line_t *l;
+        l = malloc(sizeof(script_line_t));
+        memset(l,0,sizeof(script_line_t));
+        return l;
+}
+
+static bool
+script_line_unref(script_line_t *l)
+{
+        assert(l->ref >= 0);
+        if(l->ref-- == 0) {
+                RB_FREE(&l->chars);
+                free(l);
+                return false;
+        }
+        return true;
+}
+
+
hunk ./script.c 76
+void
+script_delete_line(sc_t *sc, script_line_t *l)
+{
+        l->next->prev = l->prev;
+        l->prev->next = l->next;
+        if(script_line_unref(l)) {
+                l->next = l;
+                l->prev = l;
+                l->is_deleted = true;
+        }
+}
+
+
+
hunk ./script.c 93
-        return NULL;
+        script_line_t *n = script_line_new();
+        n->prev = l;
+        n->next = l->next;
+        n->next->prev = n;
+        n->prev->next = n;
+        return n;
hunk ./script.h 68
-struct line_attr {
-        int double_height : 1; // is double height
-        int is_protected : 1;  // cannot change, in scrollback
-        int is_virtual   : 1;  // virtual, copy on dirty
-        int noflow : 1;        // inhibit reflowing if line is too long
-        int dirty : 1;         // dirty, must be read back in.
-};
-
hunk ./script.h 70
-        struct line_attr attr;
+        short ref;
+        bool is_deleted : 1;
+        bool is_protected : 1;  // cannot change, in scrollback
+        bool is_virtual   : 1;  // virtual, copy on dirty
+        bool noflow : 1;        // inhibit reflowing if line is too long
+        bool dirty : 1;         // dirty, must be read back in.
}
