From 803e8ffe90f02398e1d06045a098ac41a798399c Mon Sep 17 00:00:00 2001 From: Matheus Castello Date: Thu, 13 Dec 2018 21:14:22 -0200 Subject: [PATCH] Targets: RISCV: Main: Add native clearScreen Now we can clean terminal with the clear() command Signed-off-by: Matheus Castello --- targets/riscv/main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/targets/riscv/main.c b/targets/riscv/main.c index e28cc21885..f6efb0382f 100644 --- a/targets/riscv/main.c +++ b/targets/riscv/main.c @@ -24,10 +24,24 @@ #include "irq.h" #include "uart.h" -#include "platform_config.h" +#include "jslex.h" +#include "jsvar.h" +#include "jsparse.h" +#include "jswrap_json.h" + #include "jsinteractive.h" #include "jshardware.h" +#include "jswrapper.h" + +void addNativeFunction(const char *name, void (*callbackPtr)(void)) { + jsvObjectSetChildAndUnLock(execInfo.root, name, jsvNewNativeFunction(callbackPtr, JSWAT_VOID)); +} +static void clearScreen() +{ + jsiConsolePrint("\033[2J"); + jsiConsolePrint("\033[H"); +} int main (void) { @@ -35,6 +49,8 @@ int main (void) jsvInit(0); jsiInit(true); + addNativeFunction("clear", clearScreen); + while(1) jsiLoop(); }