type drawpos = { x: int; y: int }
let draw_bkg color width height pos =
- let clr = Cfg.Color.palette.(color) in
- draw_rect { x = pos.x; y = pos.y; w = width; h = height; c = clr }
+ draw_rect { x = pos.x; y = pos.y; w = width; h = height; c = color }
(* curried helpers *)
-let draw_dark_bkg = draw_bkg 0
-let draw_light_bkg = draw_bkg 1
-let draw_gray_bkg = draw_bkg 3
+let draw_dark_bkg = draw_bkg Cfg.Color.palette.(0)
+let draw_light_bkg = draw_bkg Cfg.Color.palette.(1)
+let draw_gray_bkg = draw_bkg Cfg.Color.palette.(3)
let draw_text text pos =
draw_string font Cfg.Color.palette.(5) text (pos.x + 2, pos.y + 2);
let pos = draw_status pos width "UNSI> *scratch*" in
let pos = draw_tags pos width (height / font.height / 4) "Sample tags data" in
let pos = draw_scroll pos height in
- let _ = draw_edit pos width height in
+ let _ = draw_edit pos width height in
flip ()
let onshutdown () =
--- /dev/null
+#include "internals.h"
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+CAMLprim value load_file(value path) {
+ CAMLparam1(path);
+ CAMLlocal1(str);
+ int fd, nread;
+ struct stat sb;
+ if (((fd = open(String_val(path), O_RDONLY, 0)) < 0) ||
+ (fstat(fd, &sb) < 0) ||
+ (sb.st_size == 0)) {
+ caml_failwith("could not open file");
+ } else {
+ str = caml_alloc_string(sb.st_size);
+ while ((nread = read(fd, String_val(str), sb.st_size)) > 0);
+ if (nread < 0)
+ caml_failwith("read() failed");
+ }
+ close(fd);
+ CAMLreturn(str);
+}
+
+CAMLprim value env_set(value name, value val) {
+ CAMLparam2(name,val);
+ CAMLreturn(Val_unit);
+}
+
+CAMLprim value env_get(value name) {
+ CAMLparam1(name);
+ CAMLreturn(Val_unit);
+}