This commit is contained in:
Kartik K. Agaram 2014-10-04 23:00:19 -07:00
parent 133401ecbc
commit bdadc933ef
2 changed files with 44 additions and 18 deletions

25
edit.mu Normal file
View File

@ -0,0 +1,25 @@
(main
(cls)
((x1 integer) <- literal 10)
((y1 integer) <- literal 5)
(cursor (x1 integer) (y1 integer))
((s string) <- literal "Hello, ")
(print (s string))
(bold-mode)
((s string) <- literal "you")
(print (s string))
(non-bold-mode)
((s string) <- literal ".")
(print (s string))
((x2y2 integer) <- literal 1)
(cursor (x2y2 integer) (x2y2 integer))
((s string) <- literal "Press a key...")
(print (s string))
((key string) <- getc)
(cll)
((s string) <- literal "You pressed: ")
(print (s string))
(print (key string))
((s string) <- literal "\n")
(print (s string))
)

37
mu.arc
View File

@ -58,6 +58,7 @@
location (obj size 1)
integer (obj size 1)
boolean (obj size 1)
string (obj size 1) ; temporary hack
; arrays consist of an integer length followed by the right number of elems
integer-array (obj array t elem 'integer)
integer-address (obj size 1 address t elem 'integer) ; pointer to int
@ -292,9 +293,6 @@
(if types*.type!array
(new-array type (v arg.1))
(new-scalar type)))
print
(do1 nil
(apply prn (map m arg)))
; multiprocessing
run
@ -302,6 +300,22 @@
fork
(enq (make-context (v arg.0)) contexts*)
; text interaction
cls
(do1 nil ($.charterm-clear-screen))
cll
(do1 nil ($.charterm-clear-line))
cursor
(do1 nil ($.charterm-cursor (m arg.0) (m arg.1)))
print
(do1 nil ($.charterm-display (m arg.0)))
getc
($.charterm-read-key)
bold-mode
(do1 nil ($.charterm-bold))
non-bold-mode
(do1 nil ($.charterm-normal))
reply
(do (pop-stack context)
(if empty.context (return ninstrs))
@ -435,20 +449,7 @@
(reset)
(awhen cdr.argv
(map add-fns:readfile it)
($.open-charterm)
(run 'main)
($.close-charterm)
(prn memory*))
($:with-charterm
(charterm-clear-screen)
(charterm-cursor 10 5)
(charterm-display "Hello, ")
(charterm-bold)
(charterm-display "you")
(charterm-normal)
(charterm-display ".")
(charterm-cursor 1 1)
(charterm-display "Press a key...")
(let ((key (charterm-read-key)))
(charterm-cursor 1 1)
(charterm-clear-line)
(printf "You pressed: ~S\r\n" key)))