From d72b7529c5f27537073ee9d87ee28a6467d1088f Mon Sep 17 00:00:00 2001 From: cqc Date: Wed, 15 May 2024 15:10:10 -0500 Subject: [PATCH] remove debug --- ogui.ml | 67 ++++++++++++++++++--------------------------------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/ogui.ml b/ogui.ml index dc119e9..dbfffdd 100644 --- a/ogui.ml +++ b/ogui.ml @@ -5,7 +5,6 @@ module Str = Re.Str type stroke = { width : float; color : Gv.Color.t } -let debuglayout = ref false let stroke_none = { width = 0.; color = Gv.Color.transparent } let pp_text_row : Gv.Text.text_row F.t = @@ -537,10 +536,6 @@ module TextLayout = struct List.fold_left (fun (l : section list) sec -> let s, e = sec.byte_range in - if !debuglayout then - F.epr "with_range section cs=%d ce=%d s=%d e=%d@." cs ce - s e; - l @ (if e < cs || ce < s @@ -574,10 +569,6 @@ module TextLayout = struct let with_cursor (cur : cursor) ?(format = default_cursor_formatter) layout : layout = let c = with_range (cur.index, cur.index + 1) ~format layout in - if !debuglayout then - F.epr "with_cursor %a@." - F.(brackets @@ list ~sep:cut pp_section) - c.sections; c let with_mark (mark : int option) (cur : int) @@ -745,33 +736,27 @@ module TextEdit = struct unit Lwt.t = TextBuffer.fold_string text (fun s -> let slen = String.length s in - (if cursor.index < scroll then - match - String.rindex_from_opt s - (min (slen - 1) (cursor.index - 1)) - '\n' - with - | Some i' -> t.scroll <- i' + 1 - | None -> t.scroll <- 0 - else - match index_rows_from s scroll rows with - | None -> () - | Some eow -> ( - F.epr "eow=%d@." eow; - if cursor.index >= eow then - match - rindex_rows_from s - (min (slen - 1) cursor.index) - rows - with - | None -> () - | Some i' -> t.scroll <- i')); - F.epr - "scroll_update slen=%d cursor=%d scroll=%d c-s=%d rows=%d@." - (String.length s) t.cursor.index t.scroll - (cursor.index - t.scroll) - rows; - debuglayout := true) + if cursor.index < scroll then + match + String.rindex_from_opt s + (min (slen - 1) (cursor.index - 1)) + '\n' + with + | Some i' -> t.scroll <- i' + 1 + | None -> t.scroll <- 0 + else + match index_rows_from s scroll rows with + | None -> () + | Some eow -> ( + F.epr "eow=%d@." eow; + if cursor.index >= eow then + match + rindex_rows_from s + (min (slen - 1) cursor.index) + rows + with + | None -> () + | Some i' -> t.scroll <- i')) let cursor_update (t : t) (f : int -> int) : unit Lwt.t = col t >>= fun last_col -> @@ -1128,10 +1113,6 @@ module Painter = struct in Seq.fold_left (fun ((cur, start) : p2 * int) (row : Gv.Text.text_row) -> - if !debuglayout then - F.epr "start=%d row=%a %a @." start pp_text_row row - F.(brackets @@ list TextLayout.pp_section) - g.sections; let sections = List.filter (fun (r : TextLayout.section) -> @@ -1184,7 +1165,6 @@ module Painter = struct let rec layout (box : box2) (ui : Ui.t) (frame : frame) : box2 Lwt.t = let box' = Margin.inner frame.style.margin box in - if !debuglayout then F.epr "layout box'=%a@." Gg.Box2.pp box'; (match frame.t with | `Box (dir, ll) -> Lwt_list.fold_left_s @@ -1218,9 +1198,4 @@ module Painter = struct in draw_box ui.gv ~box:r' ~style:frame.style; Lwt.return r' - - let layout a b c = - let r = layout a b c in - debuglayout := false; - r end