about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-09 23:43:24 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-09 23:43:24 -0700
commitf864cf0874147a1613960d6f799ec2c764faa482 (patch)
treeded0e6e6a17159591a6e4a61c05ecd3591d671f1
parent5b7ccbc8f4f16a1c104f3415cccbdf5cce55727f (diff)
downloadmu-f864cf0874147a1613960d6f799ec2c764faa482.tar.gz
6986
Cursor now stays on the right row as we bounce in and out of function calls.
-rw-r--r--apps/tile/environment.mu24
1 files changed, 23 insertions, 1 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index cbbae239..71da0ddc 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -413,7 +413,29 @@ fn render-sandbox screen: (addr screen), functions: (addr handle function), bind
   allocate curr-path  # leak
 #?   print-string 0, "==\n"
   var dummy/ecx: int <- render-line screen, functions, 0, line, expanded-words, 3, left-col, curr-path, cursor-word, cursor-col-a  # input-row=3
-  move-cursor screen, 3, cursor-col  # input-row
+  var cursor-row/eax: int <- call-depth-at-cursor _sandbox
+  move-cursor screen, cursor-row, cursor-col
+}
+
+fn call-depth-at-cursor _sandbox: (addr sandbox) -> result/eax: int {
+  var sandbox/esi: (addr sandbox) <- copy _sandbox
+  var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
+  result <- call-path-element-length cursor-call-path
+  result <- add 2  # input-row-1
+}
+
+fn call-path-element-length _x: (addr handle call-path-element) -> result/eax: int {
+  var curr-ah/ecx: (addr handle call-path-element) <- copy _x
+  var out/edi: int <- copy 0
+  {
+    var curr/eax: (addr call-path-element) <- lookup *curr-ah
+    compare curr, 0
+    break-if-=
+    curr-ah <- get curr, next
+    out <- increment
+    loop
+  }
+  result <- copy out
 }
 
 # Render the line of words in line, along with the state of the stack under each word.
77'>177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323