From db0d3892440fc805d3c2b03546c0aa5bd55a0b00 Mon Sep 17 00:00:00 2001 From: malc Date: Tue, 15 Jun 2010 20:07:57 +0400 Subject: [PATCH] Crop --- link.c | 14 ++++++++++++++ main.ml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/link.c b/link.c index 89c07c8..8b1e832 100644 --- a/link.c +++ b/link.c @@ -1367,6 +1367,20 @@ CAMLprim value ml_gettext (value ptr_v, value rect_v, value oy_v, value rectsel_ CAMLreturn (Val_unit); } +CAMLprim value ml_getpagewh (value pagedimno_v) +{ + CAMLparam1 (pagedimno_v); + CAMLlocal1 (ret_v); + int pagedimno = Int_val (pagedimno_v); + + ret_v = caml_alloc_small (4 * Double_wosize, Double_array_tag); + Store_double_field (ret_v, 0, state.pagedims[pagedimno].box.x0); + Store_double_field (ret_v, 1, state.pagedims[pagedimno].box.x1); + Store_double_field (ret_v, 2, state.pagedims[pagedimno].box.y0); + Store_double_field (ret_v, 3, state.pagedims[pagedimno].box.y1); + CAMLreturn (ret_v); +} + static void initgl (void) { #ifdef _BIG_ENDIAN diff --git a/main.ml b/main.ml index 29a164a..dd7f785 100644 --- a/main.ml +++ b/main.ml @@ -10,6 +10,7 @@ external gettext : string -> (int * int * int * int) -> int -> bool -> unit = "ml_gettext";; external checklink : string -> int -> int -> bool = "ml_checklink";; external getlink : string -> int -> int -> (int * int) option = "ml_getlink";; +external getpagewh : int -> float array = "ml_getpagewh";; type mstate = Msel of ((int * int) * (int * int)) | Mnone;; @@ -862,6 +863,19 @@ let viewkeyboard ~key ~x ~y = in enttext (Some ('~', "", textentry, ondone)) + + | 'z' -> + begin match state.layout with + | l :: _ -> + let a = getpagewh l.pagedimno in + let w = truncate (a.(1) -. a.(0)) + and h = truncate (a.(3) -. a.(0)) in + Glut.reshapeWindow (w + conf.scrollw) h; + Glut.postRedisplay (); + + | [] -> () + end + | _ -> vlog "huh? %d %c" key (Char.chr key); end -- 2.11.4.GIT