]> git.mdlowis.com Git - archive/gapbuf.git/commitdiff
removed utf.h and added puts and del
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 7 Mar 2018 02:20:24 +0000 (21:20 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 7 Mar 2018 02:20:24 +0000 (21:20 -0500)
buf.c
edit.h
testbuf.c
utf.h [deleted file]

diff --git a/buf.c b/buf.c
index cc45ad8f8c335a87aeded2e8da954cde29be0a92..9f9b90bbf353b38b05e6a2eb644e56a087d4bc13 100644 (file)
--- a/buf.c
+++ b/buf.c
@@ -1,15 +1,9 @@
 #define _POSIX_C_SOURCE 200809L
 #include <stdc.h>
-#include <utf.h>
 #include <edit.h>
-#include <wchar.h>
-#include <ctype.h>
 #include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/time.h>
 #include <fcntl.h>
-#include <time.h>
+#include <sys/stat.h>
 
 /******************************************************************************/
 
@@ -57,7 +51,7 @@ void buf_init(Buf* buf, void (*errfn)(char*)) {
     memset(buf, 0, sizeof(Buf));
     buf->expand_tabs = true;
     buf->bufsize     = pagealign(1);
-    buf->bufstart    = emalloc(buf->bufsize * sizeof(Rune));
+    buf->bufstart    = emalloc(buf->bufsize);
     buf->bufend      = buf->bufstart + buf->bufsize;
     buf->gapstart    = buf->bufstart;
     buf->gapend      = buf->bufend;
@@ -124,10 +118,19 @@ int buf_getc(Buf* buf, Sel* sel) {
     return 0;
 }
 
-void buf_putc(Buf* buf, Sel* sel, Rune rune, int fmtopts) {
+void buf_putc(Buf* buf, Sel* sel, int rune, int fmtopts) {
+    Sel lsel = selconvert(buf, sel);
+    selupdate(buf, sel, &lsel);
+}
+
+void buf_puts(Buf* buf, Sel* sel, char* str, int fmtopts) {
     Sel lsel = selconvert(buf, sel);
     selupdate(buf, sel, &lsel);
 }
 
 void buf_last(Buf* buf, Sel* sel) {
 }
+
+void buf_del(Buf* buf, Sel* sel) {
+}
+
diff --git a/edit.h b/edit.h
index ed7b1b6539dd5d81168333a1461b6d4e4fcdb8bd..7b56e302ad6fb6d0dacf5bb10390f30c70bc0bf1 100644 (file)
--- a/edit.h
+++ b/edit.h
@@ -13,7 +13,7 @@ typedef struct Log {
         struct {
             size_t off;  /* offset in the file where the deletion occurred */
             size_t len;  /* number of runes deleted */
-            Rune* runes; /* array of runes containing deleted content */
+            char* runes; /* deleted content */
         } del;
     } data;
 } Log;
@@ -48,17 +48,13 @@ void buf_init(Buf* buf, void (*errfn)(char*));
 void buf_load(Buf* buf, char* path);
 void buf_reload(Buf* buf);
 void buf_save(Buf* buf);
+void buf_del(Buf* buf, Sel* sel);
 int buf_getc(Buf* buf, Sel* sel);
-void buf_putc(Buf* buf, Sel* sel, Rune rune, int fmtopts);
+void buf_putc(Buf* buf, Sel* sel, int rune, int fmtopts);
+void buf_puts(Buf* buf, Sel* sel, char* str, int fmtopts);
 void buf_last(Buf* buf, Sel* sel);
 
 #if 0
-Rune buf_get(Buf* buf, size_t pos);
-size_t buf_end(Buf* buf);
-size_t buf_insert(Buf* buf, bool indent, size_t off, Rune rune);
-size_t buf_delete(Buf* buf, size_t beg, size_t end);
-size_t buf_change(Buf* buf, size_t beg, size_t end);
-
 void buf_chomp(Buf* buf);
 void buf_undo(Buf* buf, Sel* sel);
 void buf_redo(Buf* buf, Sel* sel);
index e9ac58d1abbeabe343202f4a04879056462f31b1..58bc87b00a81964920eef76a9f3d7c2234d30f79 100644 (file)
--- a/testbuf.c
+++ b/testbuf.c
@@ -1,7 +1,6 @@
 #define INCLUDE_DEFS
-#include <atf.h>
 #include <stdc.h>
-#include <utf.h>
+#include <atf.h>
 #include <edit.h>
 #include <unistd.h>
 
diff --git a/utf.h b/utf.h
deleted file mode 100644 (file)
index b057363..0000000
--- a/utf.h
+++ /dev/null
@@ -1,26 +0,0 @@
-enum {
-    UTF_MAX   = 6u,       /* maximum number of bytes that make up a rune */
-    RUNE_SELF = 0x80,     /* byte values larger than this are *not* ascii */
-    RUNE_ERR  = 0xFFFD,   /* rune value representing an error */
-    RUNE_MAX  = 0x10FFFF, /* Maximum decodable rune value */
-    RUNE_EOF  = -1,       /* rune value representing end of file */
-    RUNE_CRLF = -2,       /* rune value representing a \r\n sequence */
-};
-
-/* Represents a unicode code point */
-typedef int32_t Rune;
-
-size_t utf8encode(char str[UTF_MAX], Rune rune);
-bool utf8decode(Rune* rune, size_t* length, int byte);
-Rune fgetrune(FILE* f);
-void fputrune(Rune rune, FILE* f);
-int runewidth(unsigned col, Rune r);
-size_t rstrlen(Rune* runes);
-Rune* charstorunes(char* str);
-bool risword(Rune r);
-bool rissigil(Rune r);
-bool risfile(Rune r);
-bool riscmd(Rune r);
-bool risblank(Rune r);
-bool risbigword(Rune r);
-