#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>
/******************************************************************************/
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;
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) {
+}
+
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;
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);
#define INCLUDE_DEFS
-#include <atf.h>
#include <stdc.h>
-#include <utf.h>
+#include <atf.h>
#include <edit.h>
#include <unistd.h>
+++ /dev/null
-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);
-