about summary refs log tree commit diff stats
path: root/shell/gap-buffer.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-04-28 13:55:10 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-28 13:55:10 -0700
commit5b7f938733c973a5f91fedf8635d6b4ed77ae1cb (patch)
tree625a96d27b8771051ccaac491c70fb8af1c4281b /shell/gap-buffer.mu
parente73f1a3b4129507008d57001fab23924d3fbbf54 (diff)
downloadmu-5b7f938733c973a5f91fedf8635d6b4ed77ae1cb.tar.gz
start stashing and clearing sandbox after definitions
Diffstat (limited to 'shell/gap-buffer.mu')
-rw-r--r--shell/gap-buffer.mu9
1 files changed, 9 insertions, 0 deletions
diff --git a/shell/gap-buffer.mu b/shell/gap-buffer.mu
index 893dc176..7abe57c1 100644
--- a/shell/gap-buffer.mu
+++ b/shell/gap-buffer.mu
@@ -24,6 +24,15 @@ fn clear-gap-buffer _self: (addr gap-buffer) {
   clear-grapheme-stack right
 }
 
+fn gap-buffer-capacity _gap: (addr gap-buffer) -> _/ecx: int {
+  var gap/esi: (addr gap-buffer) <- copy _gap
+  var left/eax: (addr grapheme-stack) <- get gap, left
+  var left-data-ah/eax: (addr handle array grapheme) <- get left, data
+  var left-data/eax: (addr array grapheme) <- lookup *left-data-ah
+  var result/eax: int <- length left-data
+  return result
+}
+
 # just for tests
 fn initialize-gap-buffer-with self: (addr gap-buffer), s: (addr array byte) {
   initialize-gap-buffer self, 0x10/capacity