Skip to content

Commit

Permalink
Merge pull request #443 from noborus/drawSectionHeader
Browse files Browse the repository at this point in the history
Add sectionHeader to topLN
  • Loading branch information
noborus authored Sep 21, 2023
2 parents 9051636 + bcbd902 commit 1e9532a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions oviewer/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ func (root *Root) draw() {
lN = m.topLN + lN

// Section header
lN = root.sectionHeader(lN)
n := root.drawSectionHeader(lN)
if lN != n {
lN = n
m.topLN = lN
}

// Body
lX, lN = root.drawBody(lX, lN)
Expand Down Expand Up @@ -106,25 +110,28 @@ func (root *Root) drawHeader() int {
return lN
}

// sectionHeader draws section header.
func (root *Root) sectionHeader(lN int) int {
// drawSectionHeader draws section header.
func (root *Root) drawSectionHeader(lN int) int {
m := root.Doc
if !m.SectionHeader || m.SectionDelimiter == "" {
return lN
}

sectionLN, err := root.Doc.prevSection(lN)
if lN == 0 {
lN = 1
}
sectionLN, err := m.prevSection(lN)
if err != nil {
log.Println(err)
return lN
}

if m.Header > sectionLN {
return lN
}

sx, sn := 0, 0
if lN > sectionLN {
sx, sn := 0, sectionLN
sn = sectionLN
line, _ := m.getLineC(sn, m.TabWidth)
nextY := sn
for y := m.headerLen; sn < sectionLN+m.sectionHeaderNum; y++ {
Expand Down

0 comments on commit 1e9532a

Please sign in to comment.