-
Thank you so much for making wonderful project! I'm new to bubbletea. I made a simple program like as follows. This shows 10-line time. This works as what I expect it to. bubbletea-10-lines.mp4The following shows 100-line time. However it does not start with 0. bubbletea-100-lines-trimmed.mp4I expect it starts with 0 and there are 100 lines. Here is the code. package main
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
"log"
"time"
)
type model struct {
t time.Time
}
type updateTimeMsg struct{}
func (model) Init() tea.Cmd {
return func() tea.Msg {
return updateTimeMsg{}
}
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c":
return m, tea.Quit
}
case updateTimeMsg:
m.t = time.Now()
return m, tea.Tick(50*time.Millisecond, func(t time.Time) tea.Msg {
return updateTimeMsg{}
})
}
return m, nil
}
func (m model) View() string {
var out string
for i := 0; i < 10; i++ { // change this to 100
out += fmt.Sprintf("%d: %v\n", i, m.t)
}
return out
}
func main() {
prog := tea.NewProgram(model{})
_, err := prog.Run()
if err != nil {
log.Fatal(err)
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Bubble Tea can't jump back into your terminal's scrollback buffer, so it will always only render as many lines as your terminal is currently able to display. That's a limitation of terminals, sadly. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for the reponse. I understood that is the terminal limitation. |
Beta Was this translation helpful? Give feedback.
Bubble Tea can't jump back into your terminal's scrollback buffer, so it will always only render as many lines as your terminal is currently able to display. That's a limitation of terminals, sadly.