]> khamidou — GitHub mirrors - te.git/commitdiff
added a function to insert a char in a buffer
authorkhamidou <karim@lambda-expr.org>
Tue, 9 Jun 2009 21:17:16 +0000 (23:17 +0200)
committerkhamidou <karim@lambda-expr.org>
Tue, 9 Jun 2009 21:17:16 +0000 (23:17 +0200)
buffer.c

index 44ae16512524f0f9c5d75a7254ca36277b484438..3941995392c2cb3a2c9e1b4e4a158b3c8c889b1a 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -39,12 +39,13 @@ void free_buffer(struct te_buffer *b)
 struct te_buffer* load_buffer(char *filename)
 {
        FILE *fp = fopen(filename, "r");
-
+       
        if (fp == NULL)
                fail("Unable to open %s", filename);
 
        struct te_buffer *b = alloc_and_insert_buffer();
 
+       b->name = strdup(filename);
        b->contents = bfromcstr("");
        if (b->contents == NULL)
                fail("Unable to allocate memory for buffer contents");
@@ -150,4 +151,14 @@ int move_right(struct te_buffer *buf)
        return OK;
 }
 
+void insert_char(struct te_buffer *buf, char c)
+{
+       if (buf == NULL)
+               return;
+
+       binsertch(buf->contents, buf->point, 1, c);
+
+       return;
+}
+