Permalink
Browse files

Add handler for tabulation key: add 3 spaces when tabulation key is p…

…ressed
  • Loading branch information...
1 parent 6950802 commit 4c7c2938188029e226c9320f37b672ea95607531 @OCamlPro-Bozman OCamlPro-Bozman committed Dec 13, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 toplevel/toplevel.ml
View
5 toplevel/toplevel.ml
@@ -481,13 +481,16 @@ let run () =
Html.document##onkeydown <-
(Html.handler
(fun e -> match e##keyCode with
+ | 09 -> (* Tabulation key*)
+ textbox##value <- textbox##value##concat (_s " ");
+ Js._false
| 13 -> (* ENTER key *)
let keyEv = match Js.Opt.to_option (Html.CoerceTo.keyboardEvent e) with
| None -> assert false
| Some t -> t in
(* Special handling of ctrl key *)
if keyEv##ctrlKey = Js._true then
- textbox##value <- _s ((Js.to_string textbox##value) ^ "\n");
+ textbox##value <- textbox##value##concat (_s "\n");
if keyEv##ctrlKey = Js._true || keyEv##shiftKey = Js._true then
let rows_height = textbox##scrollHeight / (textbox##rows + 1) in
let h = string_of_int (rows_height * (textbox##rows + 1) + 20) ^ "px" in

0 comments on commit 4c7c293

Please sign in to comment.