diff --git a/go.sum b/go.sum index ddebddbb..671609f6 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,6 @@ github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.18.1 h1:rmuU42rScKWlhhJDyXZRKJQHXFX02chSVW1IvkPGiVM= -github.com/spf13/viper v1.18.1/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -89,8 +87,6 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4= -golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE= golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= diff --git a/oviewer/draw.go b/oviewer/draw.go index 1d8dbfb2..4c1a9fea 100644 --- a/oviewer/draw.go +++ b/oviewer/draw.go @@ -38,13 +38,9 @@ func (root *Root) draw() { // Section header n := root.drawSectionHeader(lN) - if root.Doc.SectionHeaderNum > lN && lN != n { + if lN == 0 && lN <= root.Doc.SectionHeaderNum { lN = n - if m.topLN == 0 { - m.topLN = 1 - } } - // Body lX, lN = root.drawBody(lX, lN) @@ -115,7 +111,6 @@ func (root *Root) drawHeader() int { // drawSectionHeader advances the line // if the section header contains a line in the terminal. func (root *Root) drawSectionHeader(lN int) int { - log.Println("drawSectionHeader", lN) m := root.Doc if !m.SectionHeader || m.SectionDelimiter == "" { return lN @@ -154,6 +149,9 @@ func (root *Root) drawSectionHeader(lN int) int { root.sectionLineHighlight(y, line.str) m.headerLen += 1 if nextN != sn { + if root.scr.sectionHeaderLeft > 0 { + root.scr.sectionHeaderLeft-- + } sn = nextN line, valid = m.getLineC(sn, m.TabWidth) } @@ -195,6 +193,9 @@ func (root *Root) drawBody(lX int, lN int) (int, int) { lX = nextX if nextY != lN { lN = nextY + if root.scr.sectionHeaderLeft > 0 { + root.scr.sectionHeaderLeft-- + } line, valid = m.getLineC(lN, m.TabWidth) root.bodyStyle(line.lc, root.StyleBody) if valid { @@ -656,10 +657,9 @@ func (root *Root) sectionLineHighlight(y int, str string) { } if root.scr.sectionHeaderLeft > 0 { root.yStyle(y, root.StyleSectionLine) - root.scr.sectionHeaderLeft-- } if root.Doc.SectionDelimiterReg.MatchString(str) { root.yStyle(y, root.StyleSectionLine) - root.scr.sectionHeaderLeft = root.Doc.SectionHeaderNum - 1 + root.scr.sectionHeaderLeft = root.Doc.SectionHeaderNum } }