diff options
| author | Bobby <[email protected]> | 2026-02-15 15:21:20 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-02-15 15:21:20 +0530 |
| commit | 9c5ad61f5d6442f86272417fdd1b8a82dcc8f21d (patch) | |
| tree | 743b4f2b36218d8831417d6b02139d5add93642f /system | |
| parent | 12cfe611c4bcc0e2c6443c2b0a48b23e317f8502 (diff) | |
| download | akiba-9c5ad61f5d6442f86272417fdd1b8a82dcc8f21d.tar.xz akiba-9c5ad61f5d6442f86272417fdd1b8a82dcc8f21d.zip | |
feat: Enhance command prompt to display current stack name
Diffstat (limited to 'system')
| -rw-r--r-- | system/ash/ash.zig | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/system/ash/ash.zig b/system/ash/ash.zig index a3c940f..013de87 100644 --- a/system/ash/ash.zig +++ b/system/ash/ash.zig @@ -26,8 +26,11 @@ export fn main(pc: u32, pv: [*]const [*:0]const u8) u8 { while (true) { const location = akiba.io.getlocation(&location_buffer) catch "/"; - _ = akiba.io.mark(akiba.io.stream, location, Color.green) catch {}; - _ = akiba.io.mark(akiba.io.stream, " >>> ", Color.white) catch {}; + const stack_name = get_stack_name(location); + + _ = akiba.io.mark(akiba.io.stream, "(", Color.white) catch {}; + _ = akiba.io.mark(akiba.io.stream, stack_name, Color.green) catch {}; + _ = akiba.io.mark(akiba.io.stream, ") >>> ", Color.white) catch {}; input_len = 0; while (true) { @@ -147,3 +150,36 @@ fn build_path(buf: []u8, prefix: []const u8, name: []const u8, suffix: []const u } return buf[0..pos]; } + +fn get_stack_name(location: []const u8) []const u8 { + // Root case + if (location.len == 0 or (location.len == 1 and location[0] == '/')) { + return "/"; + } + + // Find last '/' and return everything after it + var last_slash: usize = 0; + for (location, 0..) |c, i| { + if (c == '/') { + last_slash = i; + } + } + + // If path ends with '/', look for second-to-last slash + if (last_slash == location.len - 1 and location.len > 1) { + var i: usize = location.len - 2; + while (i > 0) : (i -= 1) { + if (location[i] == '/') { + return location[i + 1 .. location.len - 1]; + } + } + return location[1 .. location.len - 1]; + } + + // Return part after last slash + if (last_slash + 1 < location.len) { + return location[last_slash + 1 ..]; + } + + return location; +} |
