mu/linux/apps/tui.mu

35 lines
986 B
Forth
Raw Normal View History

2020-05-30 15:44:46 +00:00
# Test some primitives for text-mode.
#
# To run:
2021-07-16 15:09:42 +00:00
# $ ./translate apps/tui.mu
2020-05-30 15:44:46 +00:00
# $ ./a.elf
2020-05-27 07:09:22 +00:00
2020-11-02 06:17:40 +00:00
fn main -> _/ebx: int {
2020-05-27 07:09:22 +00:00
var nrows/eax: int <- copy 0
var ncols/ecx: int <- copy 0
nrows, ncols <- screen-size 0
2020-05-27 07:09:22 +00:00
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: code-point-utf8 <- read-key-from-real-keyboard
enable-keyboard-type-mode
enable-screen-type-mode
print-string 0/screen, "You pressed "
2020-07-13 04:01:34 +00:00
var x-int/eax: int <- copy x
print-int32-hex 0/screen, x-int
print-string 0/screen, "\n"
2020-11-02 06:17:40 +00:00
return 0
2020-05-27 07:09:22 +00:00
}