1
1
mirror of https://github.com/walles/moar.git synced 2024-08-16 15:30:34 +03:00

WIP: Go to the line with the search hit

Some warnings, we should at least be using scrollPosition.isVisible().
This commit is contained in:
Johan Walles 2024-05-15 20:28:14 +02:00
parent c1641c8456
commit 6325a1cd95
2 changed files with 8 additions and 1 deletions

View File

@ -445,6 +445,9 @@ func (p *Pager) StartPaging(screen twin.Screen, chromaStyle *chroma.Style, chrom
case twin.EventTerminalBackgroundDetected:
// Do nothing, we don't care about background color updates
case eventGoToLine:
p.scrollPosition = NewScrollPositionFromLineNumber(event.lineNumber, "goToLine")
default:
log.Warnf("Unhandled event type: %v", event)
}

View File

@ -18,6 +18,10 @@ const (
searchCommandDone
)
type eventGoToLine struct {
lineNumber linenumbers.LineNumber
}
type PagerModeSearch struct {
pager *Pager
@ -83,7 +87,7 @@ func (m *PagerModeSearch) initSearcher() {
case searchCommandSearch:
found := m.searcherSearch()
if found != nil {
FIXME: Tell the pager to scroll to this position
m.pager.screen.Events() <- eventGoToLine{*found}
}
case searchCommandDone:
return