https://github.com/akkartik/mu/blob/master/apps/tui.mu
 1 # Test some primitives for text-mode.
 2 #
 3 # To run:
 4 #   $ ./translate_mu apps/tui.mu
 5 #   $ ./a.elf
 6 
 7 fn main -> exit-status/ebx: int {
 8   var nrows/eax: int <- copy 0
 9   var ncols/ecx: int <- copy 0
10   nrows, ncols <- screen-size
11   enable-screen-grid-mode
12   move-cursor-on-screen 5, 0x22
13   start-color-on-screen 1, 0x7a
14   start-blinking-on-screen
15   print-string-to-screen "Hello world!"
16   reset-formatting-on-screen
17   move-cursor-on-screen 6, 0x22
18   print-string-to-screen "tty dimensions: "
19   print-int32-hex-to-screen nrows
20   print-string-to-screen " rows, "
21   print-int32-hex-to-screen ncols
22   print-string-to-screen " rows\n"
23 
24   print-string-to-screen "press a key to see its code: "
25   enable-keyboard-immediate-mode
26   var x/eax: byte <- read-key
27   enable-keyboard-type-mode
28   enable-screen-type-mode
29   print-string-to-screen "You pressed "
30   var x-int/eax: int <- copy x
31   print-int32-hex-to-screen x-int
32   print-string-to-screen "\n"
33   exit-status <- copy 0
34 }