okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

dawnadd charm tui skillf7fcae1

main
691 B27 linesraw
1package main
2
3import (
4	tea "charm.land/bubbletea/v2"
5	"context"
6	"fmt"
7	"github.com/charmbracelet/x/term"
8	"os"
9	"time"
10)
11
12func run() error {
13	if !term.IsTerminal(os.Stdin.Fd()) || !term.IsTerminal(os.Stderr.Fd()) {
14		return fmt.Errorf("tail demo requires terminal stdin and stderr")
15	}
16	ctx, cancel := context.WithCancel(context.Background())
17	defer cancel()
18	m := &model{ctx: ctx, cancel: cancel, events: produce(ctx, 80, 250*time.Millisecond), history: newHistory(32), width: 80, height: 24}
19	_, err := tea.NewProgram(m, tea.WithInput(os.Stdin), tea.WithOutput(os.Stderr)).Run()
20	return err
21}
22func main() {
23	if err := run(); err != nil {
24		fmt.Fprintln(os.Stderr, err)
25		os.Exit(1)
26	}
27}