hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/user/hexview.c
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-10-04 16:03:42 +0200
committerhachem <im@hachem.wtf>2026-10-04 16:03:42 +0200
commit52dab7fc85d877e80e3032f0afabae906adebad8 (patch)
treeb6d56299b839413bb77b1b8c8fa9f7a682124a05 /user/hexview.c
parenta8a35a00a3c3c57cfbef2311d0348376c2e83208 (diff)
feat: fs tree and free list alloc
Diffstat (limited to 'user/hexview.c')
-rw-r--r--user/hexview.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/user/hexview.c b/user/hexview.c
index 6354338..c211b44 100644
--- a/user/hexview.c
+++ b/user/hexview.c
@@ -19,12 +19,22 @@ static void put_hex32(unsigned long value)
#define PAGE 256
#define COLS 16
-void _start(void)
+void _start(const char* arg, unsigned long arglen)
{
- put("hexview, type a filename\nfile: ");
char name[64];
- read_line(name, 64);
- put("\n");
+
+ if (arglen > 0 && arglen < 64)
+ {
+ for (unsigned long i = 0; i < arglen; i++)
+ name[i] = arg[i];
+ name[arglen] = 0;
+ }
+ else
+ {
+ put("hexview, type a filename\nfile: ");
+ read_line(name, 64);
+ put("\n");
+ }
long size = sys_fs_size(name);
if (size < 0)
@@ -35,6 +45,7 @@ void _start(void)
unsigned long offset = 0;
char buffer[PAGE];
+
for (;;)
{
long count = sys_fs_read(name, offset, buffer, PAGE);
@@ -61,6 +72,7 @@ void _start(void)
else
put(" ");
}
+
put(" ");
for (int column = 0; column < COLS && row + column < count; column++)
{
@@ -73,8 +85,18 @@ void _start(void)
put("\n");
}
- put("[n]ext [p]rev [q]uit > ");
+ put("[n]ext [p]rev [q]uit (or up/down arrows) > ");
char key = (char)sys_read();
+ if (key == 27) // ESC
+ {
+ sys_read();
+ char final = (char)sys_read();
+ if (final == 'A')
+ key = 'p';
+ else if (final == 'B')
+ key = 'n';
+ }
+
put("\n");
if (key == 'q')
break;