diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-09-16 09:36:38 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-09-16 09:36:38 -0700 |
commit | 985e85cc56cd8099a04b46bf0e5a2d2ca521e862 (patch) | |
tree | 69a3ef3e7ed7c964e4057cfee02eaf7dc95ae8d2 | |
parent | fecb649b9ac20397f8eec017be63864db4e571bb (diff) | |
download | mu-985e85cc56cd8099a04b46bf0e5a2d2ca521e862.tar.gz |
6788
-rw-r--r-- | 306files.subx | 3 | ||||
-rw-r--r-- | apps/browse/main.mu | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/306files.subx b/306files.subx index bbeece76..f547e8e1 100644 --- a/306files.subx +++ b/306files.subx @@ -44,6 +44,9 @@ open: # filename: (addr array byte), write?: boolean, out: (addr handle buffere 89/<- %ecx 0/r32/eax # restore edx 5a/pop-to-edx + # if fd < 0 return + 3d/compare-eax-with 0/imm32 + 7c/jump-if-< $open:end/disp8 # allocate a buffered-file (allocate Heap 0x1010 *(ebp+0x10)) # file-buffer-size + 16 for other fields # var out-addr/edi: (addr buffered-file) diff --git a/apps/browse/main.mu b/apps/browse/main.mu index dca84559..3736c1f4 100644 --- a/apps/browse/main.mu +++ b/apps/browse/main.mu @@ -27,6 +27,7 @@ fn main args-on-stack: (addr array addr array byte) -> exit-status/ebx: int { } fn interactive args: (addr array addr array byte) -> exit-status/ebx: int { +$interactive:body: { # initialize fs from args[1] var filename/eax: (addr array byte) <- first-arg args var file-storage: (handle buffered-file) @@ -34,6 +35,14 @@ fn interactive args: (addr array addr array byte) -> exit-status/ebx: int { open filename, 0, file-storage-addr var _fs/eax: (addr buffered-file) <- lookup file-storage var fs/esi: (addr buffered-file) <- copy _fs + # if no file, exit + { + compare fs, 0 + break-if-!= + print-string-to-real-screen "file not found\n" + exit-status <- copy 1 + break $interactive:body + } # enable-screen-grid-mode enable-keyboard-immediate-mode @@ -53,6 +62,7 @@ fn interactive args: (addr array addr array byte) -> exit-status/ebx: int { enable-screen-type-mode exit-status <- copy 0 } +} fn render screen: (addr paginated-screen), fs: (addr buffered-file) { start-drawing screen |