go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit 677dbf536f8f5a42bc25eb2f4913696b10fd464c
parent aa0c2a283fe296fe903bc94161d47ba3858e5284
Author: lash <dev@holbrook.no>
Date:   Wed, 12 Apr 2023 07:56:02 +0100

Include newline in pager accumulation calc

Diffstat:
Mgo/engine/loop_test.go | 46++++++++++++++++++++++++++++++++++++++++++++--
Mgo/render/page.go | 4+++-
2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/go/engine/loop_test.go b/go/engine/loop_test.go @@ -3,6 +3,7 @@ package engine import ( "bytes" "context" + "fmt" "log" "strings" "testing" @@ -12,11 +13,10 @@ import ( "git.defalsify.org/festive/state" ) -func TestLoopCorrect(t *testing.T) { +func TestLoopBackForth(t *testing.T) { generateTestData(t) ctx := context.TODO() st := state.NewState(0) - //rs := NewFsWrapper(dataDir, &st) rs := resource.NewFsResource(dataDir) ca := cache.NewCache().WithCacheSize(1024) @@ -42,3 +42,45 @@ func TestLoopCorrect(t *testing.T) { t.Fatal(err) } } + +func TestLoopBrowse(t *testing.T) { + generateTestData(t) + ctx := context.TODO() + st := state.NewState(0) + rs := resource.NewFsResource(dataDir) + ca := cache.NewCache().WithCacheSize(1024) + + cfg := Config{ + OutputSize: 68, + } + en := NewEngine(cfg, &st, &rs, ca) + err := en.Init("root", ctx) + if err != nil { + t.Fatal(err) + } + + input := []string{ + "1", + "2", + "00", + "11", + "00", + } + inputStr := strings.Join(input, "\n") + inputBuf := bytes.NewBuffer(append([]byte(inputStr), 0x0a)) + outputBuf := bytes.NewBuffer(nil) + log.Printf("running with input: %s", inputBuf.Bytes()) + + err = Loop(&en, "root", ctx, inputBuf, outputBuf) + if err != nil { + t.Fatal(err) + } + + location, idx := st.Where() + if location != "long" { + fmt.Errorf("expected location 'long', got %s", location) + } + if idx != 1 { + fmt.Errorf("expected idx 1, got %v", idx) + } +} diff --git a/go/render/page.go b/go/render/page.go @@ -230,7 +230,8 @@ func(pg *Page) prepare(sym string, values map[string]string, idx uint16) (map[st netRemaining := remaining if len(sinkValues) > 1 { - netRemaining -= menuSizes[1] + log.Printf("menusizes %v", menuSizes) + netRemaining -= menuSizes[1] - 1 } for i, v := range sinkValues { @@ -253,6 +254,7 @@ func(pg *Page) prepare(sym string, values map[string]string, idx uint16) (map[st } if tb.Len() > 0 { tb.WriteByte(byte(0x00)) + l += 1 } tb.WriteString(v) }