about summary refs log tree commit diff stats
path: root/apps/tui.mu
blob: 07d3147ef2d964ef929adb6f55695548db1e8c6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Test some primitives for text-mode.
#
# To run:
#   $ ./translate_mu apps/tui.mu
#   $ ./a.elf

fn main -> exit-status/ebx: int {
  var nrows/eax: int <- copy 0
  var ncols/ecx: int <- copy 0
  nrows, ncols <- screen-size
  enable-screen-grid-mode
  move-cursor 5, 35
  start-color 1, 0x7a
  start-blinking
  print-string "Hello world!"
  reset-formatting
  move-cursor 6, 35
  print-string "tty dimensions: "
  print-int32-to-screen nrows
  print-string " rows, "
  print-int32-to-screen ncols
  print-string " rows\n"

  print-string "press a key to see its code: "
  enable-keyboard-immediate-mode
  var x/eax: byte <- read-key
  enable-keyboard-type-mode
  enable-screen-type-mode
  print-string "You pressed "
  print-int32-to-screen x
  print-string "\n"
  exit-status <- copy 0
}