From 158b53eb8f19e3ff97af6c411ba2561fda130266 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 30 May 2021 09:23:36 -0700 Subject: [PATCH] first attempt doesn't work I was aware of some complications. The various indexes and y coordinates in the trace's cache would be unstable and need to be recomputed. But it's surprising that the trace _completely disappears_. --- shell/sandbox.mu | 9 +++++++++ shell/trace.mu | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/shell/sandbox.mu b/shell/sandbox.mu index dd50a7a2..ef90340e 100644 --- a/shell/sandbox.mu +++ b/shell/sandbox.mu @@ -574,6 +574,15 @@ fn edit-sandbox _self: (addr sandbox), key: byte, globals: (addr global-table), break-if-= var trace-ah/eax: (addr handle trace) <- get self, trace var trace/eax: (addr trace) <- lookup *trace-ah + # if expanding the trace, first check if we need to run the sandbox again + { + compare g, 0xa/newline + break-if-!= + var need-rerun?/eax: boolean <- cursor-too-deep? trace + compare need-rerun?, 0/false + break-if-= + run-sandbox self, globals, real-screen, tweak-real-screen? + } edit-trace trace, g return } diff --git a/shell/trace.mu b/shell/trace.mu index d644ae1f..63a5987f 100644 --- a/shell/trace.mu +++ b/shell/trace.mu @@ -1107,6 +1107,35 @@ fn hide-trace-line _self: (addr trace), line: (addr trace-line) { } } +fn cursor-too-deep? _self: (addr trace) -> _/eax: boolean { + var self/esi: (addr trace) <- copy _self + var trace-ah/eax: (addr handle array trace-line) <- get self, data + var _trace/eax: (addr array trace-line) <- lookup *trace-ah + var trace/edi: (addr array trace-line) <- copy _trace + var cursor-line-index-addr/ecx: (addr int) <- get self, cursor-line-index + var cursor-line-index/ecx: int <- copy *cursor-line-index-addr + var cursor-line-offset/eax: (offset trace-line) <- compute-offset trace, cursor-line-index + var cursor-line/edx: (addr trace-line) <- index trace, cursor-line-offset + var cursor-line-visible?/eax: (addr boolean) <- get cursor-line, visible? + var cursor-line-depth/ebx: (addr int) <- get cursor-line, depth + var target-depth/ebx: int <- copy *cursor-line-depth + # if cursor-line is visible, return false + compare *cursor-line-visible?, 0/false + { + break-if-= + return 0/false + } + # return cursor-line-depth >= max-depth-1 + target-depth <- increment + var max-depth-addr/eax: (addr int) <- get self, max-depth + compare target-depth, *max-depth-addr + { + break-if-< + return 1/true + } + return 0/false +} + fn test-cursor-down-and-up-within-trace { var t-storage: trace var t/esi: (addr trace) <- address t-storage