about summary refs log tree commit diff stats
path: root/linux/tui.mu
         __  _ __    __        _            __  _ __        __     
        / /_(_) /___/ /__     (_)___  _____/ /_(_) /___  __/ /____ 
       / __/ / / __  / _ \   / / __ \/ ___/ __/ / __/ / / / __/ _ \
      / /_/ / / /_/ /  __/  / / / / (__  ) /_/ / /_/ /_/ / /_/  __/
      \__/_/_/\__,_/\___/  /_/_/ /_/____/\__/_/\__/\__,_/\__/\___/ 
                                                                   
teral.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Test some primitives for text-mode.
#
# To run:
#   $ ./translate tui.mu
#   $ ./a.elf

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

  print-string 0/screen, "press a key to see its code: "
  enable-keyboard-immediate-mode
  var x/eax: grapheme <- read-key-from-real-keyboard
  enable-keyboard-type-mode
  enable-screen-type-mode
  print-string 0/screen, "You pressed "
  var x-int/eax: int <- copy x
  print-int32-hex 0/screen, x-int
  print-string 0/screen, "\n"
  return 0
}