mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Add command to sync scrollable area with renderer
This is necessary for initial paints, and probably for resizes.
This commit is contained in:
24
renderer.go
24
renderer.go
@@ -259,6 +259,10 @@ func (r *renderer) handleMessages(msg Msg) {
|
||||
case clearIgnoredLinesMsg:
|
||||
r.clearIgnoredLines()
|
||||
|
||||
case syncScrollAreaMsg:
|
||||
r.setIgnoredLines(msg.topBoundary, msg.bottomBoundary)
|
||||
r.insertTop(msg.lines, msg.topBoundary, msg.bottomBoundary)
|
||||
|
||||
case scrollUpMsg:
|
||||
r.insertTop(msg.lines, msg.topBoundary, msg.bottomBoundary)
|
||||
|
||||
@@ -309,8 +313,6 @@ func ClearIgnoredLines() Msg {
|
||||
return clearIgnoredLinesMsg{}
|
||||
}
|
||||
|
||||
// scrollDownMsg is experiemental. There are no guarantees about it persisting
|
||||
// in a future API. It's exposed for high performance scrolling.
|
||||
type scrollUpMsg struct {
|
||||
lines []string
|
||||
topBoundary int
|
||||
@@ -327,8 +329,6 @@ func ScrollUp(newLines []string, topBoundary, bottomBoundary int) Cmd {
|
||||
}
|
||||
}
|
||||
|
||||
// scrollDownMsg is experiemental. There are no guarantees about it persisting
|
||||
// in a future API. It's exposed for high performance scrolling.
|
||||
type scrollDownMsg struct {
|
||||
lines []string
|
||||
topBoundary int
|
||||
@@ -344,3 +344,19 @@ func ScrollDown(newLines []string, topBoundary, bottomBoundary int) Cmd {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type syncScrollAreaMsg struct {
|
||||
lines []string
|
||||
topBoundary int
|
||||
bottomBoundary int
|
||||
}
|
||||
|
||||
func SyncScrollArea(lines []string, topBoundary int, bottomBoundary int) Cmd {
|
||||
return func() Msg {
|
||||
return syncScrollAreaMsg{
|
||||
lines: lines,
|
||||
topBoundary: topBoundary,
|
||||
bottomBoundary: bottomBoundary,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user