heh
This commit is contained in:
45
bin/main.ml
45
bin/main.ml
@ -106,7 +106,7 @@ module Display = struct
|
|||||||
[('1','!');('2','@');('3','#');('4','$');('5','%');
|
[('1','!');('2','@');('3','#');('4','$');('5','%');
|
||||||
('6','^');('7','&');('8','*');('9','(');('0',')');
|
('6','^');('7','&');('8','*');('9','(');('0',')');
|
||||||
('`','~');('-','_');('+','+');('[','{');(']','}');
|
('`','~');('-','_');('+','+');('[','{');(']','}');
|
||||||
('\\','|');(';',':');('\'','"');('.','<');('.','>');
|
('\\','|');(';',':');('\'','"');(',','<');('.','>');
|
||||||
('/','?')]
|
('/','?')]
|
||||||
|
|
||||||
let handle_keyevents (el:event list) (ze:unit Zed_edit.t) (zc:Zed_cursor.t) =
|
let handle_keyevents (el:event list) (ze:unit Zed_edit.t) (zc:Zed_cursor.t) =
|
||||||
@ -607,33 +607,36 @@ module Topmain = struct
|
|||||||
*)
|
*)
|
||||||
end
|
end
|
||||||
|
|
||||||
type top_instance = {ze: unit Zed_edit.t;
|
type textedit = {ze: unit Zed_edit.t; zc: Zed_cursor.t}
|
||||||
zc: Zed_cursor.t;
|
let make_textedit () = let z = Zed_edit.create () in {ze = z; zc = Zed_edit.new_cursor z;}
|
||||||
res: Buffer.t}
|
let draw_textedit (te:textedit) height (s:Display.state) =
|
||||||
let mktop () = let z = Zed_edit.create () in {ze = z; zc = Zed_edit.new_cursor z; res = Buffer.create 1024}
|
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 draw_top (t:top_instance) height (s:Display.state) =
|
||||||
let kr = Display.handle_keyevents s.events t.ze t.zc in
|
let kr = Display.handle_keyevents s.events t.te.ze t.te.zc in
|
||||||
pane_vbox [
|
(match kr with
|
||||||
draw_pp 30. (fun pp ->
|
| `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
|
||||||
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
|
|
||||||
Buffer.clear t.res;
|
Buffer.clear t.res;
|
||||||
Topmain.main (Format.formatter_of_buffer t.res) text ();
|
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
|
] s
|
||||||
|
|
||||||
|
|
||||||
let top_1 = mktop ()
|
let top_1 = make_top ()
|
||||||
|
|
||||||
let mouse_state = ref (0,0)
|
let mouse_state = ref (0,0)
|
||||||
let draw_komm (s:Display.state) =
|
let draw_komm (s:Display.state) =
|
||||||
|
|||||||
Reference in New Issue
Block a user