rule_bkg 1 (height - csr.y) csr;
csr.x <- csr.x + 1
+let make_line_array lines nlines =
+ let lines = (Array.of_list (List.rev !lines)) in
+ let line_ary = (Array.make nlines (-1)) in
+ Array.blit lines 0 line_ary 0;
+ lines
+
let buffer csr buf clr off =
- dark_bkg (csr.width - csr.x) (csr.height - csr.y) csr;
+ let height = (csr.height - csr.y) in
+ dark_bkg (csr.width - csr.x) height csr;
csr.y <- csr.y + 2;
+ let nlines = ((height -2) / font_height) in
let num = ref 0 and csr = (restart csr 2 0)
and boxes = ref [] and lines = ref [] in
let draw_rune c =
in
Buf.iter draw_rune buf off;
List.iter X11.draw_rect !boxes; (* draw selection boxes *)
- (!num, !lines)
+ (!num, (make_line_array lines nlines))
let status csr str =
dark_bkg csr.width (4 + font_height) csr;
val light_bkg : int -> int -> Cursor.t -> unit
val rule_bkg : int -> int -> Cursor.t -> unit
-val buffer : Cursor.t -> Buf.t -> Colormap.t -> int -> (int * int list)
+val buffer : Cursor.t -> Buf.t -> Colormap.t -> int -> (int * int array)
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 -> Colormap.t -> int -> (int * int list)
+val edit : Cursor.t -> Buf.t -> Colormap.t -> int -> (int * int array)
type t = {
num : int;
- lines: int list;
+ lines: int array;
buf : Buf.t;
map : Scrollmap.t;
clr : Colormap.t;
}
let from_buffer buf width height =
- { num = 0; buf = buf; lines = [];
+ { num = 0; buf = buf; lines = [||];
map = Scrollmap.make buf width 0;
clr = Colormap.make (Buf.make_lexer buf);
pos = (0,0);
let get_at view x y =
let sx,sy = view.pos and w,h = view.dim in
let off =
- try List.nth view.lines ((h - (y + 2)) / Draw.font.height)
- with Failure _ -> Buf.length view.buf
+ try view.lines.((y - sy - 2) / Draw.font.height)
+ with Invalid_argument _ -> ((Buf.length view.buf) - 1)
in
get_col_offset view.buf off (w - sx) (x - sx)
-
let select view start stop =
{ view with buf = Buf.select view.buf start stop }