Skip to content

Commit 28f5482

Browse files
committed
Show result in debug mode
1 parent bc947d5 commit 28f5482

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cmd/exe/debugger.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
. "github.com/antonmedv/expr/vm"
88
"github.com/gdamore/tcell"
99
"github.com/rivo/tview"
10+
"github.com/sanity-io/litter"
1011
"sort"
1112
"strconv"
1213
"strings"
@@ -21,7 +22,6 @@ func debugger() {
2122
check(err)
2223

2324
vm := NewVM(true)
24-
go vm.Run(program, nil)
2525

2626
app := tview.NewApplication()
2727
table := tview.NewTable()
@@ -42,6 +42,19 @@ func debugger() {
4242
AddItem(sub, 0, 1, false)
4343
app.SetRoot(flex, true)
4444

45+
go func() {
46+
out := vm.Run(program, nil)
47+
app.QueueUpdateDraw(func() {
48+
sub.RemoveItem(scope)
49+
result := tview.NewTextView()
50+
result.
51+
SetBorder(true).
52+
SetTitle("Output")
53+
result.SetText(litter.Sdump(out))
54+
sub.AddItem(result, 0, 1, false)
55+
})
56+
}()
57+
4558
index := make(map[int]int)
4659
for row, line := range strings.Split(program.Disassemble(), "\n") {
4760
if line == "" {

0 commit comments

Comments
 (0)