shell: reduce trace depth in sandbox

We'll gradually make this more dynamic.
This commit is contained in:
Kartik K. Agaram 2021-05-22 10:28:21 -07:00
parent 6934f78e97
commit 7a04c8104d
3 changed files with 24 additions and 1 deletions

View File

@ -138,6 +138,13 @@ fn draw-text-rightward-from-cursor screen: (addr screen), text: (addr array byte
set-cursor-position screen, cursor-x, cursor-y
}
fn draw-text-rightward-from-cursor-over-full-screen screen: (addr screen), text: (addr array byte), color: int, background-color: int {
var width/eax: int <- copy 0
var height/ecx: int <- copy 0
width, height <- screen-size screen
draw-text-rightward-from-cursor screen, text, width, color, background-color
}
fn render-grapheme screen: (addr screen), g: grapheme, xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
compare g, 0xa/newline
var x/eax: int <- copy x

View File

@ -31,7 +31,7 @@ fn initialize-sandbox _self: (addr sandbox), fake-screen-and-keyboard?: boolean
var trace-ah/eax: (addr handle trace) <- get self, trace
allocate trace-ah
var trace/eax: (addr trace) <- lookup *trace-ah
initialize-trace trace, 0x100/max-depth, 0x8000/lines, 0x80/visible
initialize-trace trace, 4/max-depth, 0x8000/lines, 0x80/visible
var cursor-in-data?/eax: (addr boolean) <- get self, cursor-in-data?
copy-to *cursor-in-data?, 1/true
}

View File

@ -433,6 +433,22 @@ fn render-trace screen: (addr screen), _self: (addr trace), xmin: int, ymin: int
var i/edx: int <- copy 0
var max-addr/ebx: (addr int) <- get self, first-free
var max/ebx: int <- copy *max-addr
# display trace depth (not in tests)
$render-trace:render-depth: {
compare max, 0
break-if-<=
var max-depth/edx: (addr int) <- get self, max-depth
{
var width/eax: int <- copy 0
var height/ecx: int <- copy 0
width, height <- screen-size screen
compare width, 0x80
break-if-< $render-trace:render-depth
}
set-cursor-position screen, 0x70/x, y
draw-text-rightward-from-cursor-over-full-screen screen, "trace depth: ", 0x17/fg, 0xc5/bg=blue-bg
draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, *max-depth, 0x7/fg, 0xc5/bg=blue-bg
}
$render-trace:loop: {
compare i, max
break-if->=