Last active
November 24, 2016 05:43
-
-
Save dudelson/009f2f8bdb88333dce994f5f9d4d1315 to your computer and use it in GitHub Desktop.
A small example showing how to use lambda-term to print "Hello, world!" to the screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Lwt | |
open CamomileLibrary | |
let draw ui matrix = | |
(* let style = { LTerm_style.none with foreground = Some (LTerm_style.rgb 255 255 255) } in *) | |
let size = LTerm_ui.size ui in | |
let ctx = LTerm_draw.context matrix size in | |
LTerm_draw.draw_string ctx 2 2 "Hello, world!" | |
let rec loop ui = | |
LTerm_ui.wait ui >>= function | |
| LTerm_event.Key { code = Char c } when UChar.char_of c = 'q' -> return () | |
| _ -> | |
LTerm_ui.draw ui; | |
loop ui | |
let run () = | |
Lazy.force LTerm.stdout >>= fun term -> | |
LTerm_ui.create term draw >>= fun ui -> | |
loop ui >>= fun () -> | |
LTerm_ui.quit ui | |
let () = Lwt_main.run (run ()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment