heh
This commit is contained in:
39
bin/main.ml
39
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
|
||||
let kr = Display.handle_keyevents s.events t.te.ze t.te.zc in
|
||||
(match kr with
|
||||
| `Execute ->
|
||||
let text = Zed_string.to_utf8 (Zed_rope.to_string (Zed_edit.text t.ze)) in
|
||||
let text = str_of_textedit t.te in
|
||||
Buffer.clear t.res;
|
||||
Topmain.main (Format.formatter_of_buffer t.res) text ();
|
||||
| _ -> ());
|
||||
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) =
|
||||
|
||||
Reference in New Issue
Block a user