# Include and Lib Paths
#-------------------------------------------------------------------------------
-INCS = -I . -I lib -I tests \
+INCS = -I . -I lib -I tests -I lib/lexers \
-I /usr/X11R6/include \
-I /usr/include/freetype2 -I /usr/X11R6/include/freetype2
edit.ml \
unittests.ml
+LEXERS = \
+ lib/lexers/lex_cpp.ml
+
LIBSRCS = \
lib/misc.ml \
lib/x11.ml \
lib/draw.ml \
lib/scrollmap.ml \
lib/colormap.ml \
+ $(LEXERS) \
lib/view.ml
TESTSRCS = \
tests/view_tests.ml \
tests/scrollmap_tests.ml
-LEXERS = \
- lib/lexers/lex_cpp.ml
-
LIBOBJS = \
$(LIBSRCS:.ml=.$(OBJEXT)) \
- $(LEXERS:.ml=.$(OBJEXT)) \
lib/x11_prims.o \
lib/misc_prims.o \
lib/utf8.o
lib/scrollmap.cmo : lib/draw.cmi lib/buf.cmi lib/scrollmap.cmi lib/scrollmap.ml
lib/scrollmap.cmx lib/scrollmap.o : lib/draw.cmi lib/draw.cmx lib/buf.cmi lib/buf.cmx lib/scrollmap.cmi lib/scrollmap.ml
lib/scrollmap.cmi : lib/buf.cmi
-lib/view.cmo lib/view.cmi : lib/scrollmap.cmi lib/draw.cmi lib/buf.cmi lib/view.ml
-lib/view.cmx lib/view.o lib/view.cmi : lib/scrollmap.cmi lib/scrollmap.cmx lib/draw.cmi lib/draw.cmx lib/buf.cmi lib/buf.cmx lib/view.ml
+lib/view.cmo lib/view.cmi : lib/scrollmap.cmi lib/draw.cmi lib/colormap.cmi lib/buf.cmi lib/view.ml
+lib/view.cmx lib/view.o lib/view.cmi : lib/scrollmap.cmi lib/scrollmap.cmx lib/draw.cmi lib/draw.cmx lib/colormap.cmi lib/colormap.cmx lib/buf.cmi lib/buf.cmx lib/view.ml
lib/x11.cmo lib/x11.cmi : lib/x11.ml
lib/x11.cmx lib/x11.o lib/x11.cmi : lib/x11.ml
tests/buf_tests.cmo tests/buf_tests.cmi : tests/buf_tests.ml
let iter fn buf i =
iteri (fun i c -> (fn c)) buf i
+let make_lexfn buf =
+ let pos = ref 0 in
+ (fun bytebuf n ->
+ let count = ref 0 in
+ iteri (fun i c ->
+ Bytes.set bytebuf !count (Char.chr c);
+ incr count;
+ (!count >= n)
+ ) buf !pos;
+ pos := !pos + !count;
+ Printf.printf "count %d\n" !count;
+ !count)
+
module Cursor = struct
type csr = {
mutable start : int;
val is_at : dest -> t -> int -> bool
val is_bol : t -> int -> bool
val is_eol : t -> int -> bool
+
+val make_lexfn : t -> (bytes -> int -> int)
+
mapref := SpanSet.add span !mapref;
()
-let create scanfn fetchfn =
+let make scanfn fetchfn =
+ print_endline "generating colormap";
let mapref = ref SpanSet.empty in
try
let lexbuf = Lexing.from_function fetchfn in
let set_color = set_color mapref lexbuf in
while true do
+ print_endline "scanning";
scanfn set_color lexbuf
done;
!mapref
with Eof -> !mapref
+let empty = SpanSet.empty
+
let find pos set =
let range = Span.({ start = pos; stop = pos; style = Normal }) in
match (SpanSet.find_opt range set) with
type lexer = (style -> unit) -> Lexing.lexbuf -> unit
-val create : lexer -> (bytes -> int -> int) -> t
+val empty : t
+val make : lexer -> (bytes -> int -> int) -> t
(*
val from_channel : lexer -> in_channel -> t
| typedef { color Type }
| ln_cmt { color Comment }
| blk_cmt { color Comment }
- | _ { None }
+ | _
| eof { raise Eof }
type t = {
num : int;
buf : Buf.t;
- map : Scrollmap.t
+ map : Scrollmap.t;
+ clr : Colormap.t
}
let from_buffer buf width height =
- { num = 0; buf = buf; map = Scrollmap.make buf width 0 }
+ { num = 0; buf = buf;
+ map = Scrollmap.make buf width 0;
+ clr = Colormap.make Lex_cpp.scan (Buf.make_lexfn buf) }
let empty width height =
from_buffer (Buf.empty) width height