aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-16 16:17:02 +0200
committeruser <user@clank>2026-07-16 16:17:02 +0200
commit30f3a65e2de99cdffd091289b4edb8e14be9032d (patch)
treedce23b1cb2cbef5a24e279c7ada29d44c23c7403
parentosk: wrap the cursor around all four edges (diff)
downloadgbos-30f3a65e2de99cdffd091289b4edb8e14be9032d.tar.gz
gbos-30f3a65e2de99cdffd091289b4edb8e14be9032d.tar.xz
gbos-30f3a65e2de99cdffd091289b4edb8e14be9032d.zip
sh: handle backspace in readline; prompt is now '#'
readc() returning $08/$7F now drops the last char from the command buffer (and emits one $08 so the terminal erases it) instead of storing the raw byte. Previously "lz<bksp>s" left the buffer as "lz\x08s", so the command "ls" was reported "not found" even though the screen showed "ls". Also change the shell prompt from '$' to '#'. osk: B button types the selected key SHIFTED (uppercase a-z). A types the key as shown (lowercase/digit/symbol); B on a letter subtracts 32 for the uppercase glyph (the font already has A-Z). Non-letters are unchanged.
Diffstat (limited to '')
-rw-r--r--c/sh.c6
-rw-r--r--src/osk.asm15
2 files changed, 19 insertions, 2 deletions
diff --git a/c/sh.c b/c/sh.c
index b1bf630..df2c5e9 100644
--- a/c/sh.c
+++ b/c/sh.c
@@ -104,13 +104,17 @@ void main(void) {
unsigned char nt, i, pipepos, c, bg;
/* reap finished background jobs */
{ unsigned char p; while ((p = reap())) { putc('['); putu(p); puts(" done]"); nl(); } }
- puts(cwd); puts("$ ");
+ puts(cwd); puts("# ");
/* read a line (echoing), stop at newline; exit on EOF */
i = 0;
for (;;) {
c = readc();
if (c == EOF) poweroff();
if (c == '\r' || c == '\n') { nl(); break; }
+ if (c == 8 || c == 127) { /* backspace: drop last char */
+ if (i > 0) { i--; putc(8); }
+ continue;
+ }
if (i < 79) { line[i++] = c; putc(c); }
}
line[i] = 0;
diff --git a/src/osk.asm b/src/osk.asm
index 490a402..02700c6 100644
--- a/src/osk.asm
+++ b/src/osk.asm
@@ -337,9 +337,22 @@ osk_handle::
bit 4, a
call nz, osk_right
ld a, [wPadNew]
- bit 0, a ; A: type the selected key
+ bit 0, a ; A: type the key as shown
+ jr z, .chkb
+ call osk_selected
+ scf
+ ret
+.chkb
+ ld a, [wPadNew]
+ bit 1, a ; B: type the key SHIFTED (uppercase a-z)
jr z, .none
call osk_selected
+ cp "a"
+ jr c, .shifted
+ cp "z"+1
+ jr nc, .shifted
+ sub 32 ; 'a'..'z' -> 'A'..'Z'
+.shifted
scf
ret
.none