Skip to content

Instantly share code, notes, and snippets.

@dudelson
Last active November 24, 2016 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudelson/009f2f8bdb88333dce994f5f9d4d1315 to your computer and use it in GitHub Desktop.
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
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