From cec0d9553babfd80dc694b10a5ed3cfaef086706 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 15 Apr 2021 23:20:00 -0700 Subject: open question: animations in the fake screen Right now we just render the state of the screen at the end of an evaluation. --- shell/global.mu | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/shell/global.mu b/shell/global.mu index f341be99..46c43234 100644 --- a/shell/global.mu +++ b/shell/global.mu @@ -30,6 +30,7 @@ fn initialize-globals _self: (addr global-table) { append-primitive self, "cons" # for screens append-primitive self, "print" + append-primitive self, "clear" append-primitive self, "lines" append-primitive self, "columns" append-primitive self, "up" @@ -472,6 +473,13 @@ fn apply-primitive _f: (addr cell), args-ah: (addr handle cell), out: (addr hand apply-print args-ah, out, trace return } + { + var is-clear?/eax: boolean <- string-equal? f-name, "clear" + compare is-clear?, 0/false + break-if-= + apply-clear args-ah, out, trace + return + } { var is-lines?/eax: boolean <- string-equal? f-name, "lines" compare is-lines?, 0/false @@ -1126,6 +1134,36 @@ fn apply-print _args-ah: (addr handle cell), out: (addr handle cell), trace: (ad copy-object second-ah, out } +fn apply-clear _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) { + trace-text trace, "eval", "apply clear" + var args-ah/eax: (addr handle cell) <- copy _args-ah + var _args/eax: (addr cell) <- lookup *args-ah + var args/esi: (addr cell) <- copy _args + # TODO: check that args is a pair + var empty-args?/eax: boolean <- nil? args + compare empty-args?, 0/false + { + break-if-= + error trace, "'clear' needs 1 arg but got 0" + return + } + # screen = args->left + var first-ah/eax: (addr handle cell) <- get args, left + var first/eax: (addr cell) <- lookup *first-ah + var first-type/ecx: (addr int) <- get first, type + compare *first-type, 5/screen + { + break-if-= + error trace, "first arg for 'clear' is not a screen" + return + } + var screen-ah/eax: (addr handle screen) <- get first, screen-data + var _screen/eax: (addr screen) <- lookup *screen-ah + var screen/ecx: (addr screen) <- copy _screen + # + clear-screen screen +} + fn apply-up _args-ah: (addr handle cell), out: (addr handle cell), trace: (addr trace) { trace-text trace, "eval", "apply up" var args-ah/eax: (addr handle cell) <- copy _args-ah -- cgit 1.4.1-2-gfad0