about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-06-04 21:56:43 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-06-04 21:56:43 -0700
commit73bbe731c57dfeec5dbd70e9279fa1ee028d2cd8 (patch)
tree2a251015e12cf045a9daeb701339886f11ec02dc
parent7531bc2124b837d5e2ad0185adeb6bf38e39edc4 (diff)
downloadmu-73bbe731c57dfeec5dbd70e9279fa1ee028d2cd8.tar.gz
select function to render first
-rw-r--r--shell/environment.mu2
-rw-r--r--shell/global.mu10
2 files changed, 11 insertions, 1 deletions
diff --git a/shell/environment.mu b/shell/environment.mu
index 7aa9970b..cb93e396 100644
--- a/shell/environment.mu
+++ b/shell/environment.mu
@@ -139,9 +139,9 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
       break-if-!=
       var cursor-in-globals-a/edx: (addr boolean) <- get self, cursor-in-globals?
       copy-to *cursor-in-globals-a, 1/true
-      # TODO: use function name
       var partial-function-name-ah/eax: (addr handle gap-buffer) <- get self, partial-function-name
       var partial-function-name/eax: (addr gap-buffer) <- lookup *partial-function-name-ah
+      set-global-cursor-index globals, partial-function-name
       var cursor-in-globals-a/ecx: (addr boolean) <- get self, cursor-in-globals?
       copy-to *cursor-in-globals-a, 1/true
       {
diff --git a/shell/global.mu b/shell/global.mu
index 6f6f1cb5..de9a27cc 100644
--- a/shell/global.mu
+++ b/shell/global.mu
@@ -502,3 +502,13 @@ fn move-gap-buffer-to-global _globals: (addr global-table), _definition-ah: (add
   var dest-ah/eax: (addr handle gap-buffer) <- get dest-global, input
   copy-object gap, dest-ah
 }
+
+fn set-global-cursor-index _globals: (addr global-table), name-gap: (addr gap-buffer) {
+  var globals/esi: (addr global-table) <- copy _globals
+  var name-storage: (stream byte 0x40)
+  var name/ecx: (addr stream byte) <- address name-storage
+  emit-gap-buffer name-gap, name
+  var index/ecx: int <- find-symbol-in-globals globals, name
+  var dest/edi: (addr int) <- get globals, cursor-index
+  copy-to *dest, index
+}