From 7633df3d8bdb6e0f17702f0fa141bc7a53270c34 Mon Sep 17 00:00:00 2001 From: cqc Date: Sun, 11 Jul 2021 23:50:37 -0500 Subject: [PATCH] heh --- bin/main.ml | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/bin/main.ml b/bin/main.ml index 8bc6b6b..109b28a 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -106,7 +106,7 @@ module Display = struct [('1','!');('2','@');('3','#');('4','$');('5','%'); ('6','^');('7','&');('8','*');('9','(');('0',')'); ('`','~');('-','_');('+','+');('[','{');(']','}'); - ('\\','|');(';',':');('\'','"');('.','<');('.','>'); + ('\\','|');(';',':');('\'','"');(',','<');('.','>'); ('/','?')] let handle_keyevents (el:event list) (ze:unit Zed_edit.t) (zc:Zed_cursor.t) = @@ -607,33 +607,36 @@ module Topmain = struct *) end -type top_instance = {ze: unit Zed_edit.t; - zc: Zed_cursor.t; - res: Buffer.t} -let mktop () = let z = Zed_edit.create () in {ze = z; zc = Zed_edit.new_cursor z; res = Buffer.create 1024} +type textedit = {ze: unit Zed_edit.t; zc: Zed_cursor.t} +let make_textedit () = let z = Zed_edit.create () in {ze = z; zc = Zed_edit.new_cursor z;} +let draw_textedit (te:textedit) height (s:Display.state) = + draw_pp 30. (fun pp -> + let text = Zed_string.to_utf8 (Zed_rope.to_string (Zed_edit.text te.ze)) in + F.pf pp "> "; F.text pp text; F.pf pp "@.@.";) s + +let str_of_textedit (te:textedit) = Zed_string.to_utf8 (Zed_rope.to_string (Zed_edit.text te.ze)) + + +type top_instance = {te: textedit; res: Buffer.t} +let make_top () = {te = (make_textedit ()); res = Buffer.create 1024} let draw_top (t:top_instance) height (s:Display.state) = - let kr = Display.handle_keyevents s.events t.ze t.zc in - pane_vbox [ - draw_pp 30. (fun pp -> - let text = Zed_string.to_utf8 (Zed_rope.to_string (Zed_edit.text t.ze)) in - F.pf pp "> "; F.text pp text; F.pf pp "@.@."; - ); - draw_pp 30. (fun pp -> - let ztc = Zed_edit.new_cursor t.ze in - let ztx = Zed_edit.context t.ze ztc in - match kr with - | `Execute -> - let text = Zed_string.to_utf8 (Zed_rope.to_string (Zed_edit.text t.ze)) in + let kr = Display.handle_keyevents s.events t.te.ze t.te.zc in + (match kr with + | `Execute -> + let text = str_of_textedit t.te in Buffer.clear t.res; Topmain.main (Format.formatter_of_buffer t.res) text (); - F.pf pp "%s@." (Buffer.contents t.res); - F.flush pp () - | _ -> () + | _ -> ()); + pane_vbox [ + draw_textedit t.te 30.; + draw_pp 30. (fun pp -> + F.pf pp "%s@." (Buffer.contents t.res); + F.flush pp () ); ] s -let top_1 = mktop () +let top_1 = make_top () let mouse_state = ref (0,0) let draw_komm (s:Display.state) =