From: Michael D. Lowis Date: Wed, 7 Mar 2018 02:20:24 +0000 (-0500) Subject: removed utf.h and added puts and del X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=5e9135dbb4f68cec6c512fa57282f0eac1712e15;p=archive%2Fgapbuf.git removed utf.h and added puts and del --- diff --git a/buf.c b/buf.c index cc45ad8..9f9b90b 100644 --- a/buf.c +++ b/buf.c @@ -1,15 +1,9 @@ #define _POSIX_C_SOURCE 200809L #include -#include #include -#include -#include #include -#include -#include -#include #include -#include +#include /******************************************************************************/ @@ -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 ed7b1b6..7b56e30 100644 --- 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); diff --git a/testbuf.c b/testbuf.c index e9ac58d..58bc87b 100644 --- a/testbuf.c +++ b/testbuf.c @@ -1,7 +1,6 @@ #define INCLUDE_DEFS -#include #include -#include +#include #include #include diff --git a/utf.h b/utf.h deleted file mode 100644 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); -