about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-19 22:47:03 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-19 22:47:21 -0700
commit1436f0298f4c6b9a141a4f23fb89f5c00e98175d (patch)
treeafd8ff89fbd4c7b2250a4eb5c11cd6c049d031bf /apps/tile
parentf32e575e387859af74f7023f9f02b32dee839962 (diff)
downloadmu-1436f0298f4c6b9a141a4f23fb89f5c00e98175d.tar.gz
6812 - tile: render cursor location
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/environment.mu16
-rw-r--r--apps/tile/gap-buffer.mu8
-rw-r--r--apps/tile/word.mu6
3 files changed, 26 insertions, 4 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index c57c64e7..d589464c 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -137,7 +137,8 @@ fn render _env: (addr environment), max-depth: int {
     curr-word <- lookup *next-word-ah
     loop
   }
-  move-cursor screen, 3, *cursor-col-a  # input-row
+  var col/eax: (addr int) <- copy cursor-col-a
+  move-cursor screen, 3, *col  # input-row
 }
 
 # Render:
@@ -181,8 +182,17 @@ fn render-column screen: (addr screen), first-word: (addr word), final-word: (ad
   # render word, initialize result
   move-cursor screen, 3, botleft-col  # input-row
   print-word screen, final-word
-#?   var len/eax: int <- word-length final-word
-#?   right-col <- copy len
+
+  # update cursor
+  {
+    var f/eax: (addr word) <- copy final-word
+    compare f, cursor-word
+    break-if-!=
+    var cursor-index/eax: int <- cursor-index cursor-word
+    cursor-index <- add botleft-col
+    var dest/edi: (addr int) <- copy cursor-col-a
+    copy-to *dest, cursor-index
+  }
 
   # post-process right-col
   right-col <- copy max-width
diff --git a/apps/tile/gap-buffer.mu b/apps/tile/gap-buffer.mu
index 96e39aed..8a57fc5b 100644
--- a/apps/tile/gap-buffer.mu
+++ b/apps/tile/gap-buffer.mu
@@ -139,7 +139,6 @@ $gap-right:body: {
   }
   {
     var left/ecx: (addr grapheme-stack) <- get self, left
-    # HERE: can't use 'result' here: "unknown variable 'result'"
     push-grapheme-stack left, g
   }
 }
@@ -163,6 +162,13 @@ $gap-left:body: {
 }
 }
 
+fn gap-index _self: (addr gap-buffer) -> result/eax: int {
+  var self/eax: (addr gap-buffer) <- copy _self
+  var left/eax: (addr grapheme-stack) <- get self, left
+  var top-addr/eax: (addr int) <- get left, top
+  result <- copy *top-addr
+}
+
 fn gap-buffer-equal? _self: (addr gap-buffer), s: (addr array byte) -> result/eax: boolean {
 $gap-buffer-equal?:body: {
   var self/esi: (addr gap-buffer) <- copy _self
diff --git a/apps/tile/word.mu b/apps/tile/word.mu
index 4c7b13dd..cbc3c90d 100644
--- a/apps/tile/word.mu
+++ b/apps/tile/word.mu
@@ -134,6 +134,12 @@ fn cursor-to-end _self: (addr word) {
   gap-to-end data
 }
 
+fn cursor-index _self: (addr word) -> result/eax: int {
+  var self/esi: (addr word) <- copy _self
+  var data/eax: (addr gap-buffer) <- get self, data
+  result <- gap-index data
+}
+
 fn print-word screen: (addr screen), _self: (addr word) {
   var self/esi: (addr word) <- copy _self
   var data/eax: (addr gap-buffer) <- get self, data