# Toolchain Configuration
#-------------------------------------------------------------------------------
-OFLAGS = -g
+OS = $(shell uname)
+OFLAGS = -g -nodynlink
MKLIBFLAGS = -custom
OLDFLAGS =
# Native Config
+OC = ocamlopt
BINEXT = bin
OBJEXT = cmx
LIBEXT = cmxa
# Bytecode Config
+#OC = ocamlc
#BINEXT = byte
#OBJEXT = cmo
#LIBEXT = cma
+ifeq ($(OS),Darwin)
+ OFLAGS += -ccopt -dead_strip
+endif
+
# Include and Lib Paths
#-------------------------------------------------------------------------------
INCS = -I . -I lib -I tests -I lib/lexers \
lib/cfg.ml \
lib/rope.ml \
lib/buf.ml \
+ lib/colormap.ml \
lib/draw.ml \
lib/scrollmap.ml \
- lib/colormap.ml \
$(LEXERS) \
lib/view.ml
#-------------------------------------------------------------------------------
.SUFFIXES: .c .o .ml .mli .mll .cmo .cmx .cmi .cma .cmxa .byte .bin
.c.o:
- ocamlc $(OFLAGS) -c $^ $(INCS)
+ ocamlopt $(OFLAGS) -c $^ $(INCS)
mv $(notdir $@) $(dir $@)
.ml.cmo :
ocamlc -c $(OFLAGS) $(INCS) -o $@ $<
.ml.cmx :
ocamlopt -c $(OFLAGS) $(INCS) -o $@ $<
.mli.cmi :
- ocamlc -c $(OFLAGS) $(INCS) -o $@ $<
+ $(OC) -c $(OFLAGS) $(INCS) -o $@ $<
.mll.ml :
ocamllex $(OLEXFLAGS) -o $@ $<
%.cma:
lib/colormap.cmo : lib/cfg.cmi lib/colormap.cmi lib/colormap.ml
lib/colormap.cmx lib/colormap.o : lib/cfg.cmi lib/cfg.cmx lib/colormap.cmi lib/colormap.ml
lib/colormap.cmi :
-lib/draw.cmo : lib/x11.cmi lib/cfg.cmi lib/buf.cmi lib/draw.cmi lib/draw.ml
-lib/draw.cmx lib/draw.o : lib/x11.cmi lib/x11.cmx lib/cfg.cmi lib/cfg.cmx lib/buf.cmi lib/buf.cmx lib/draw.cmi lib/draw.ml
-lib/draw.cmi : lib/x11.cmi lib/buf.cmi
+lib/draw.cmo : lib/x11.cmi lib/colormap.cmi lib/cfg.cmi lib/buf.cmi lib/draw.cmi lib/draw.ml
+lib/draw.cmx lib/draw.o : lib/x11.cmi lib/x11.cmx lib/colormap.cmi lib/colormap.cmx lib/cfg.cmi lib/cfg.cmx lib/buf.cmi lib/buf.cmx lib/draw.cmi lib/draw.ml
+lib/draw.cmi : lib/x11.cmi lib/colormap.cmi lib/buf.cmi
lib/misc.cmo lib/misc.cmi : lib/misc.ml
lib/misc.cmx lib/misc.o lib/misc.cmi : lib/misc.ml
lib/rope.cmo : lib/rope.cmi lib/rope.ml
(!count >= n)
) buf !pos;
pos := !pos + !count;
- Printf.printf "count %d\n" !count;
!count)
module Cursor = struct
let set_color mapref lexbuf c =
let span = Span.({
start = (lexeme_start lexbuf);
- stop = (lexeme_end lexbuf);
+ stop = (lexeme_end lexbuf) - 1;
style = c })
in
mapref := SpanSet.add span !mapref;
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
+ with Eof ->
+ Printf.printf "%b\n" @@ SpanSet.is_empty !mapref;
+ SpanSet.iter
+ (fun x -> Printf.printf "%d-%d\n" x.start x.stop)
+ !mapref;
+ print_endline "";
+ !mapref
let empty = SpanSet.empty
rule_bkg 1 (height - csr.y) csr;
csr.x <- csr.x + 1
-let buffer csr buf off =
+let buffer csr buf clr off =
dark_bkg (csr.width - csr.x) (csr.height - csr.y) csr;
let num = ref 0 and csr = (restart csr 2 0) in
let draw_rune c =
- draw_glyph csr c Cfg.Color.Syntax.normal;
+ draw_glyph csr c (Colormap.find (off + !num) clr);
num := !num + 1;
has_next_line csr
in
csr.x <- csr.x + 14;
vrule csr.height csr
-let edit csr buf =
+let edit csr buf clr =
dark_bkg (csr.width - csr.x) (csr.height - csr.y) csr;
- buffer csr buf
+ buffer csr buf clr
val light_bkg : int -> int -> Cursor.t -> unit
val rule_bkg : int -> int -> Cursor.t -> unit
-val buffer : Cursor.t -> Buf.t -> int -> int
+val buffer : Cursor.t -> Buf.t -> Colormap.t -> int -> int
val string : string -> Cursor.t -> unit
val hrule : int -> Cursor.t -> unit
val status : Cursor.t -> string -> unit
val tags : Cursor.t -> Buf.t -> unit
val scroll : Cursor.t -> (float * float) -> unit
-val edit : Cursor.t -> Buf.t -> int -> int
+val edit : Cursor.t -> Buf.t -> Colormap.t -> int -> int
(* Line and Block Comments *)
let ln_cmt = "//" [^ '\r' '\n']*
let blk_cmt = "/*" _* "*/"
+let character = "'" ([^'\\' '\''] | '\\' _) "'"
+let string = '"' ([^'\\' '"'] | '\\' _)* ['"' '\n']
+let identifier = ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_']*
let const = "true" | "false" | "NULL"
| "size_t" | "void" | "extern" | "static" | "inline" | "struct" | "enum"
| "typedef" | "union" | "volatile" | "auto" | "const" | "int8_t" | "int16_t"
| "int32_t" | "int64_t" | "uint8_t" | "uint16_t" | "uint32_t" | "uint64_t"
+ | "float" | "double"
rule scan color = parse
+ | ln_cmt { color Comment }
+(* | blk_cmt { color Comment } *)
+ | character { color Constant }
+ | string { color Constant }
+
| const { color Constant }
| keyword { color Keyword }
| typedef { color Type }
- | ln_cmt { color Comment }
- | blk_cmt { color Comment }
- | _
+
+ | identifier { (* skip *) }
+ | _ { (* skip *) }
| eof { raise Eof }
let draw view csr =
let view = (resize view (Draw.Cursor.max_width csr)) in
- let num = Draw.buffer csr view.buf (Scrollmap.first view.map) in
+ let num = Draw.buffer csr view.buf view.clr (Scrollmap.first view.map) in
{ view with num = num }
let scroll_up view =
#define _XOPEN_SOURCE 700
#include <time.h>
#include <sys/time.h>
+#define printf(...) ((void)0)
uint64_t getmillis(void) {
struct timespec time;