aboutsummaryrefslogtreecommitdiffstats
path: root/src/script.c
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2018-03-08 12:17:58 -0500
committerClyne Sullivan <tullivan99@gmail.com>2018-03-08 12:17:58 -0500
commitc27af361feeca0e7cbfa51f5589b09d0c110e9c9 (patch)
treebde1d2cb0924f2cbd9153a9a23b3911b0adfc4de /src/script.c
parent94a62e8a7b5fcebf94bb0ae7760b9720e8db2715 (diff)
graphing perfection
Diffstat (limited to 'src/script.c')
-rw-r--r--src/script.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/script.c b/src/script.c
index 495e409..8fad2f3 100644
--- a/src/script.c
+++ b/src/script.c
@@ -22,7 +22,6 @@ int script_color(interpreter *it);
int script_rand(interpreter *it);
int script_getkey(interpreter *it);
int script_pixel(interpreter *it);
-int script_solve(interpreter *it);
void script_loadlib(interpreter *it)
{
@@ -36,7 +35,6 @@ void script_loadlib(interpreter *it)
inew_cfunc(it, "rand", script_rand);
inew_cfunc(it, "getkey", script_getkey);
inew_cfunc(it, "pixel", script_pixel);
- inew_cfunc(it, "solve", script_solve);
}
int script_puts(interpreter *it)
@@ -50,14 +48,21 @@ int script_gets(interpreter *it)
{
char *s = malloc(64);
char c[2] = {0, 0};
- uint16_t index = 0;
+ int index = 0;
do {
c[0] = serial_get();
s[index] = c[0];
- if (c[0] != '\r')
+ if (c[0] == '\b' || c[0] == 127) {
+ index--;
+ if (index > -1) {
+ dsp_puts("\b");
+ index--;
+ }
+ } else if (c[0] != '\r') {
dsp_puts(c);
- } while (s[index] != '\r' && index++ < 23);
+ }
+ } while (s[index] != '\r' && index++ < 63);
s[index] = '\0';
variable *r = make_vars(0, s);
@@ -135,18 +140,3 @@ int script_pixel(interpreter *it)
return 0;
}
-int script_solve(interpreter *it)
-{
- const char *expr = igetarg_string(it, 0);
- int len = strlen(expr);
- char *buf = (char *)malloc(len + 2);
- strcpy(buf, expr);
- buf[len] = ')';
- buf[len + 1] = '\0';
- variable *r = idoexpr(it, buf);
- if (r == 0)
- r = make_varn(0, 0.0f);
- iret(it, r);
- free(r);
- return 0;
-}