aboutsummaryrefslogtreecommitdiffstats
path: root/src/script.c
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2018-04-11 20:49:32 -0400
committerClyne Sullivan <tullivan99@gmail.com>2018-04-11 20:49:32 -0400
commit8e11f269ce352df26af7c44d283131494dcd70fa (patch)
treebe0cbdfb115c0ec9f334b9dd9476d2a59ef3a93a /src/script.c
parent0726b60a6e32760fbadd1cdd39362c9c7a0fd9cc (diff)
status bar, arrow keys, ins/del
Diffstat (limited to 'src/script.c')
-rw-r--r--src/script.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/script.c b/src/script.c
index 61ff598..51a3bb7 100644
--- a/src/script.c
+++ b/src/script.c
@@ -168,6 +168,7 @@ int script_gets(instance *it)
char *s = malloc(64);
char c[2] = {0, 0};
int index = 0;
+ int furthest = 0;
do {
do {
@@ -178,9 +179,32 @@ int script_gets(instance *it)
if (c[0] == 0x7F) {
it->lnidx = 998;
break;
+ } else if (c[0] == K_LEFT) {
+ if (index > 0) {
+ dsp_spos(-1, 0);
+ index--;
+ }
+ continue;
+ } else if (c[0] == K_RIGHT) {
+ if (index < furthest) {
+ dsp_spos(1, 0);
+ index++;
+ }
+ continue;
+ } else if (c[0] == K_UP || c[0] == K_DOWN)
+ continue;
+
+ if (c[0] == '\n') {
+ s[furthest] = '\n';
+ break;
+ }
+
+ extern int keypad_insert;
+ if (keypad_insert != 0 && index < furthest) {
+ for (int i = furthest; i >= index; i--)
+ s[i] = s[i - 1];
}
- //c[0] = serial_get();
s[index] = c[0];
if (c[0] == '\b' || c[0] == 127) {
index--;
@@ -188,11 +212,20 @@ int script_gets(instance *it)
dsp_puts("\b");
index--;
}
+ } else if (keypad_insert != 0) {
+ dsp_spos(-index, 0);
+ s[furthest + 1] = '\0';
+ dsp_puts(s);
+ dsp_spos(-(furthest - index), 0);
+ furthest++;
} else if (c[0] != '\n'/*'\r'*/) {
dsp_puts(c);
}
- } while (s[index] != '\n'/*'\r'*/ && index++ < 63);
- s[index] = '\0';
+
+ if (++index > furthest)
+ furthest = index;
+ } while (furthest < 63);
+ s[furthest] = '\0';
variable *r = make_vars(0, s);
ipush(it, (uint32_t)r);
@@ -274,7 +307,7 @@ int script_program(instance *it)
int initrdOffset = (int)igetarg(it, 0)->value.f;
char *name = initrd_getname(initrdOffset);
- dsp_rect(0, 0, 480, 320, 0);
+ dsp_rect(0, 0, 480, 300, 0);
dsp_cpos(0, 0);
dsp_coff(0, 0);