diff options
| author | hachem <im@hachem.wtf> | 2026-10-09 20:13:44 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-10-09 20:13:44 +0200 |
| commit | 2ae433bd20bb68b787c3dd92f635f6c820dcfcb9 (patch) | |
| tree | f73c74d4d1c8ced97b6a7a7b6a55ca20beea9805 | |
| parent | 016a104cb4f2f99cdd3bec1f12ab188141376ca6 (diff) | |
fix: rework how paths work
| -rw-r--r-- | gils/gils.rv | 22 | ||||
| -rw-r--r-- | kernel/console.rv | 10 |
2 files changed, 29 insertions, 3 deletions
diff --git a/gils/gils.rv b/gils/gils.rv index 2432890..289e547 100644 --- a/gils/gils.rv +++ b/gils/gils.rv @@ -38,7 +38,27 @@ global expand_path = fn(path) -> string do path = "#{wd.path}#{slash}#{path}" end - return path + # collapse . and .. segments + const raw = path:split("/") + let parts = {} + for index in 0..raw:len() do + const seg = raw[index] + if seg == ".." do + if (parts:len() > 0) + parts:pop() + end else if seg != "" and seg != "." do + parts:push(seg) + end + end + + if (parts:len() == 0) + return "/" + + let result = "" + for index in 0..parts:len() do + result = result ~ "/" ~ parts[index] + end + return result end fn run_script_path(path, label, ctx) -> bool do diff --git a/kernel/console.rv b/kernel/console.rv index ba322f9..4a036ab 100644 --- a/kernel/console.rv +++ b/kernel/console.rv @@ -258,7 +258,10 @@ global console = { fn cursor_clear(self) do if self.shown do - fill_rect(self.cursor_x * self:cell_width(), self.cursor_y * self:cell_height(), self:cell_width(), self:cell_height(), BG_COLOR) + const cw = self:cell_width() + const ch = self:cell_height() + const thick = 2 * self.scale + fill_rect(self.cursor_x * cw, self.cursor_y * ch + (ch - thick), cw, thick, BG_COLOR) self.shown = :false end end, @@ -266,7 +269,10 @@ global console = { fn cursor_show(self) do self.cursor_x = self.column self.cursor_y = self.row - fill_rect(self.cursor_x * self:cell_width(), self.cursor_y * self:cell_height(), self:cell_width(), self:cell_height(), CURSOR_COLOR) + const cw = self:cell_width() + const ch = self:cell_height() + const thick = 2 * self.scale + fill_rect(self.cursor_x * cw, self.cursor_y * ch + (ch - thick), cw, thick, CURSOR_COLOR) self.shown = :true end, |
