remove debug

This commit is contained in:
cqc
2024-05-15 15:10:10 -05:00
parent 4ce218978b
commit d72b7529c5

29
ogui.ml
View File

@ -5,7 +5,6 @@ module Str = Re.Str
type stroke = { width : float; color : Gv.Color.t } type stroke = { width : float; color : Gv.Color.t }
let debuglayout = ref false
let stroke_none = { width = 0.; color = Gv.Color.transparent } let stroke_none = { width = 0.; color = Gv.Color.transparent }
let pp_text_row : Gv.Text.text_row F.t = let pp_text_row : Gv.Text.text_row F.t =
@ -537,10 +536,6 @@ module TextLayout = struct
List.fold_left List.fold_left
(fun (l : section list) sec -> (fun (l : section list) sec ->
let s, e = sec.byte_range in 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 l
@ (if @ (if
e < cs || ce < s e < cs || ce < s
@ -574,10 +569,6 @@ module TextLayout = struct
let with_cursor (cur : cursor) ?(format = default_cursor_formatter) let with_cursor (cur : cursor) ?(format = default_cursor_formatter)
layout : layout = layout : layout =
let c = with_range (cur.index, cur.index + 1) ~format layout in 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 c
let with_mark (mark : int option) (cur : int) let with_mark (mark : int option) (cur : int)
@ -745,7 +736,7 @@ module TextEdit = struct
unit Lwt.t = unit Lwt.t =
TextBuffer.fold_string text (fun s -> TextBuffer.fold_string text (fun s ->
let slen = String.length s in let slen = String.length s in
(if cursor.index < scroll then if cursor.index < scroll then
match match
String.rindex_from_opt s String.rindex_from_opt s
(min (slen - 1) (cursor.index - 1)) (min (slen - 1) (cursor.index - 1))
@ -765,13 +756,7 @@ module TextEdit = struct
rows rows
with with
| None -> () | None -> ()
| Some i' -> t.scroll <- i')); | 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)
let cursor_update (t : t) (f : int -> int) : unit Lwt.t = let cursor_update (t : t) (f : int -> int) : unit Lwt.t =
col t >>= fun last_col -> col t >>= fun last_col ->
@ -1128,10 +1113,6 @@ module Painter = struct
in in
Seq.fold_left Seq.fold_left
(fun ((cur, start) : p2 * int) (row : Gv.Text.text_row) -> (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 = let sections =
List.filter List.filter
(fun (r : TextLayout.section) -> (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 rec layout (box : box2) (ui : Ui.t) (frame : frame) : box2 Lwt.t
= =
let box' = Margin.inner frame.style.margin box in 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 (match frame.t with
| `Box (dir, ll) -> | `Box (dir, ll) ->
Lwt_list.fold_left_s Lwt_list.fold_left_s
@ -1218,9 +1198,4 @@ module Painter = struct
in in
draw_box ui.gv ~box:r' ~style:frame.style; draw_box ui.gv ~box:r' ~style:frame.style;
Lwt.return r' Lwt.return r'
let layout a b c =
let r = layout a b c in
debuglayout := false;
r
end end