From f864cf0874147a1613960d6f799ec2c764faa482 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 9 Oct 2020 23:43:24 -0700 Subject: 6986 Cursor now stays on the right row as we bounce in and out of function calls. --- apps/tile/environment.mu | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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. -- cgit 1.4.1-2-gfad0