about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/browse.mu17
1 files changed, 11 insertions, 6 deletions
diff --git a/apps/browse.mu b/apps/browse.mu
index fc391430..a2a25584 100644
--- a/apps/browse.mu
+++ b/apps/browse.mu
@@ -2,11 +2,14 @@
 
 fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
   var filename/eax: (addr array byte) <- first-arg args
-  var file/eax: (addr buffered-file) <- load-file filename
+  var file/esi: (addr buffered-file) <- load-file filename
   enable-screen-grid-mode
+  var nrows/eax: int <- copy 0
+  var ncols/ecx: int <- copy 0
+  nrows, ncols <- screen-size
   enable-keyboard-immediate-mode
   {
-    render file, 0x20, 0x30  # nrows, ncols
+    render file, nrows, ncols
     var key/eax: byte <- read-key
     compare key, 0x71  # 'q'
     loop-if-!=
@@ -16,14 +19,15 @@ fn main args: (addr array (addr array byte)) -> exit-status/ebx: int {
   exit-status <- copy 0
 }
 
+# decide how to lay out pages on screen
 fn render in: (addr buffered-file), nrows: int, ncols: int {
   # hardcoded parameter: text-width
   var toprow/eax: int <- copy 2
   var botrow/ecx: int <- copy toprow
-  botrow <- add nrows
+  botrow <- add 0x20
   var leftcol/edx: int <- copy 5
   var rightcol/ebx: int <- copy leftcol
-  rightcol <- add ncols
+  rightcol <- add 0x30
   render-page in, toprow, leftcol, botrow, rightcol
 }
 
@@ -80,13 +84,14 @@ fn first-arg args-on-stack: (addr array (addr array byte)) -> out/eax: (addr arr
   out <- copy *result
 }
 
-fn load-file filename: (addr array byte) -> out/eax: (addr buffered-file) {
+fn load-file filename: (addr array byte) -> out/esi: (addr buffered-file) {
   var result: (handle buffered-file)
   {
     var tmp1/eax: (addr handle buffered-file) <- address result
     open filename, 0, tmp1
   }
-  out <- lookup result
+  var tmp2/eax: (addr buffered-file) <- lookup result
+  out <- copy tmp2
 }
 
 fn dump in: (addr buffered-file) {