about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-29 15:56:24 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-29 15:56:24 -0700
commitff2ee758185781080490851ae7d9e87ec17d851e (patch)
tree78e9099dffa81ee57e1997d6f24bf1f58c3f17ae
parent2fb656b4f466f85437c268da9e05b270d020b964 (diff)
downloadmu-ff2ee758185781080490851ae7d9e87ec17d851e.tar.gz
6433 - render newlines correctly
There were three confounding issues to get past before this seemed to be
working right:
  - row/col count from 1 rather than 0
  - I was thinking in decimal rather than hex
  - print-byte buffers to stdout, but print-string does not. I didn't think
    this mattered, but it does matter to flush the current line before
    moving cursor again.

Only one of these issues was a bug in the code. The first two were bugs
in my mental model that necessitated no changes to code to be corrected.
-rw-r--r--103screen.subx1
-rw-r--r--apps/browse.mu3
2 files changed, 4 insertions, 0 deletions
diff --git a/103screen.subx b/103screen.subx
index 7011eb0f..328b1151 100644
--- a/103screen.subx
+++ b/103screen.subx
@@ -91,6 +91,7 @@ $clear-screen:end:
     5d/pop-to-ebp
     c3/return
 
+# row and col count from the top-left as (1, 1)
 move-cursor:  # row: int, column: int
     # . prologue
     55/push-ebp
diff --git a/apps/browse.mu b/apps/browse.mu
index bb3c1a1c..222ac5cd 100644
--- a/apps/browse.mu
+++ b/apps/browse.mu
@@ -33,10 +33,13 @@ $line-loop:  {
       var c/eax: byte <- read-byte-buffered in
       compare c, 0xffffffff  # EOF marker
       break-if-= $line-loop
+      compare c, 0xa  # newline
+      break-if-=  # no need to print newlines
       print-byte c
       col <- increment
       loop
     }
+    flush-stdout
     row <- increment
     loop
   }