Bubbletea

162 阅读1分钟

Bubbletea

概述

依赖导入

package main
​
import (
    "fmt"
    "os"
​
    tea "github.com/charmbracelet/bubbletea"
)

快速开始

应用状态模型

type model struct {
    choices  []string           // items on the to-do list,所有待完成事项;
    cursor   int                // which to-do list item our cursor is pointing at,界面上光标位置;
    selected map[int]struct{}   // which to-do items are selected,已完成标识。
}

model用于存储Bubbletea应用程序的状态信息(该类型被我们自主创建,里面的内容由我们自行定义)