From 698bd768b70625acf1b491df61c42e75c17e5fb4 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 19 Oct 2017 21:39:17 -0400 Subject: [PATCH] stripped buf down to bare minimum --- edit.ml | 2 +- lib/buf.ml | 85 ++++-------------------------------------------------- 2 files changed, 7 insertions(+), 80 deletions(-) diff --git a/edit.ml b/edit.ml index a8e7f56..c477612 100644 --- a/edit.ml +++ b/edit.ml @@ -4,7 +4,7 @@ open X11 let font = font_load "Times New Roman:size=12" let font = font_load "Monaco:size=10::antialias=true:autohint=true" *) -let font = font_load "Sans Serif:size=11:antialias=true:autohint=true" +let font = font_load "Verdana:size=11:antialias=true:autohint=true" let tags_buf = ref Buf.create let edit_buf = ref Buf.create diff --git a/lib/buf.ml b/lib/buf.ml index a67d558..80e33fd 100644 --- a/lib/buf.ml +++ b/lib/buf.ml @@ -1,92 +1,19 @@ -type encoding = Utf8 | Binary - -type lfstyle = Unix | Dos - -type bufinfo = { - path: string; - modtime: int; - charset: encoding; - crlf: lfstyle; -} - -type bufstate = { - nlines : int; - outpoint : int; - rope : Rope.t -} - type buf = { - info : bufinfo; - current : bufstate; - lastsave : bufstate; - undo : bufstate list; - redo : bufstate list; + path : string; + rope : Rope.t } let iter_from fn buf i = - Rope.iter_from fn buf.current.rope i + Rope.iter_from fn buf.rope i let create = - let state = { nlines = 0; outpoint = 0; rope = Rope.empty } - and info = { path = ""; modtime = 0; charset = Utf8; crlf = Unix } in - { info = info; current = state; lastsave = state; undo = []; redo = [] } + { path = ""; rope = Rope.empty } let load path = - let file = Rope.from_string (Misc.load_file path) in - let state = { nlines = 0; outpoint = 0; rope = file } - and info = { path = ""; modtime = 0; charset = Utf8; crlf = Unix } in - { info = info; current = state; lastsave = state; undo = []; redo = [] } + { path = path; rope = Rope.from_string (Misc.load_file path) } let saveas buf path = () let save buf = - saveas buf buf.info.path - -(* - -/* cursor/selection representation */ -typedef struct { - size_t beg; - size_t end; - size_t col; -} Sel; - -void buf_init(Buf* buf, void ( *errfn )( char* )); -size_t buf_load(Buf* buf, char* path); -void buf_reload(Buf* buf); -void buf_save(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); - -void buf_undo(Buf* buf, Sel* sel); -void buf_redo(Buf* buf, Sel* sel); - -Rune buf_get(Buf* buf, size_t pos); -size_t buf_end(Buf* buf); - -size_t buf_change(Buf* buf, size_t beg, size_t end); -void buf_chomp(Buf* buf); -void buf_loglock(Buf* buf); -void buf_logclear(Buf* buf); -bool buf_iseol(Buf* buf, size_t pos); -size_t buf_bol(Buf* buf, size_t pos); -size_t buf_eol(Buf* buf, size_t pos); -size_t buf_bow(Buf* buf, size_t pos); -size_t buf_eow(Buf* buf, size_t pos); -size_t buf_lscan(Buf* buf, size_t pos, Rune r); -size_t buf_rscan(Buf* buf, size_t pos, Rune r); -void buf_getword(Buf* buf, bool ( *isword )(Rune), Sel* sel); -void buf_getblock(Buf* buf, Rune beg, Rune end, Sel* sel); -size_t buf_byrune(Buf* buf, size_t pos, int count); -size_t buf_byword(Buf* buf, size_t pos, int count); -size_t buf_byline(Buf* buf, size_t pos, int count); -void buf_findstr(Buf* buf, int dir, char* str, size_t* beg, size_t* end); -void buf_lastins(Buf* buf, size_t* beg, size_t* end); -size_t buf_setln(Buf* buf, size_t line); -size_t buf_getln(Buf* buf, size_t off); -size_t buf_getcol(Buf* buf, size_t pos); -size_t buf_setcol(Buf* buf, size_t pos, size_t col); - -*) + saveas buf buf.path -- 2.52.0