about summary refs log tree commit diff stats
path: root/prototypes/browse/19
diff options
context:
space:
mode:
Diffstat (limited to 'prototypes/browse/19')
-rw-r--r--prototypes/browse/19/README.md5
-rw-r--r--prototypes/browse/19/main.mu2
-rw-r--r--prototypes/browse/19/screen-position-state.mu13
3 files changed, 13 insertions, 7 deletions
diff --git a/prototypes/browse/19/README.md b/prototypes/browse/19/README.md
index 47975886..042af867 100644
--- a/prototypes/browse/19/README.md
+++ b/prototypes/browse/19/README.md
@@ -1,5 +1,4 @@
 Fill in screen state code.
 
-It's not quite working yet. Lines don't wrap.
-
-But at least we're moving the cursor correctly before we start drawing.
+It's not quite working yet. We don't handle newlines, and that causes the
+row/col computations to go out of sync.
diff --git a/prototypes/browse/19/main.mu b/prototypes/browse/19/main.mu
index 6457ca81..c936a575 100644
--- a/prototypes/browse/19/main.mu
+++ b/prototypes/browse/19/main.mu
@@ -37,7 +37,7 @@ fn render-normal fs: (addr file-state), state: (addr screen-position-state) {
     compare c, 0xffffffff  # EOF marker
     break-if-=
     #
-    print-byte c
+    add-char state, c
     #
     loop
   }
diff --git a/prototypes/browse/19/screen-position-state.mu b/prototypes/browse/19/screen-position-state.mu
index 3bfd361b..2d2a675f 100644
--- a/prototypes/browse/19/screen-position-state.mu
+++ b/prototypes/browse/19/screen-position-state.mu
@@ -37,7 +37,7 @@ fn init-screen-position-state _self: (addr screen-position-state) {
   copy-to *dest, 5  # left-margin
   # self->rightcol = self->leftcol + text-width
   dest <- get self, rightcol
-  copy-to *dest, 0x45  # left-margin + text-width
+  copy-to *dest, 0xa  # left-margin + text-width
   #
   start-drawing self
 }
@@ -80,11 +80,18 @@ fn add-char _self: (addr screen-position-state), c: byte {
 
 fn next-line _self: (addr screen-position-state) {
   var self/esi: (addr screen-position-state) <- copy _self
+  var tmp/eax: (addr int) <- copy 0
+  var tmp2/ecx: int <- copy 0
+  # self->col = self->leftcol
+  tmp <- get self, leftcol
+  tmp2 <- copy *tmp
+  tmp <- get self, col
+  copy-to *tmp, tmp2
   # self->row++
-  var tmp/eax: (addr int) <- get self, row
+  tmp <- get self, row
   increment *tmp
   # if (self->row > self->botrow) next-page(self)
-  var tmp2/ecx: int <- copy *tmp
+  tmp2 <- copy *tmp
   tmp <- get self, botrow
   compare tmp2, *tmp
   {