From 40a72b339ec38b82384c98c85b6f5de52e9b7f90 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 6 Nov 2017 16:05:09 -0500 Subject: [PATCH] fixed bug in scrollmap creation that was creating empty lines --- edit.ml | 4 ++-- lib/scrollmap.ml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/edit.ml b/edit.ml index b6f3ff0..1b3b4cc 100644 --- a/edit.ml +++ b/edit.ml @@ -35,10 +35,10 @@ let edit_view = ref (View.empty 640 480) let onfocus focused = () let onkeypress mods rune = - edit_view := View.scroll_dn !edit_view + edit_view := View.scroll_up !edit_view let onmousebtn mods btn x y pressed = - match btn with + if pressed then match btn with | 1 -> () | 2 -> () | 3 -> () diff --git a/lib/scrollmap.ml b/lib/scrollmap.ml index 6852a26..8a8fefe 100644 --- a/lib/scrollmap.ml +++ b/lib/scrollmap.ml @@ -15,9 +15,10 @@ let make buf width off = let bol = (Rope.to_bol (Buf.rope buf) off) in let lines = ref [bol] in let process_glyph i c = - if (Draw.Cursor.next_glyph csr c) then + let is_eol = (Rope.is_eol (Buf.rope buf) i) in + if (Draw.Cursor.next_glyph csr c) && is_eol == false then lines := i :: !lines; - ((Rope.is_eol (Buf.rope buf) i) == false) + (is_eol == false) in Buf.iteri_from process_glyph buf off; let lines = (Array.of_list (List.rev !lines)) in -- 2.52.0