package main import ( "github.com/charmbracelet/bubbles/textarea" "github.com/charmbracelet/bubbles/viewport" ) func initialModel() model { // detailed tree to showcase design root := &TreeNode{ Label: "nextshell-mock-folder", Expanded: true, Children: []*TreeNode{ { Label: "cmd", Expanded: true, Children: []*TreeNode{ {Label: "build"}, {Label: "deploy"}, {Label: "test"}, }, }, { Label: "pkg", Expanded: true, Children: []*TreeNode{ { Label: "http", Expanded: true, Children: []*TreeNode{ {Label: "client.go"}, {Label: "server.go"}, }, }, { Label: "ui", Expanded: true, Children: []*TreeNode{ {Label: "main.go"}, {Label: "widgets.go"}, {Label: "styles.go"}, }, }, }, }, { Label: "configs", Children: []*TreeNode{ {Label: "dev.yaml"}, {Label: "prod.yaml"}, }, }, {Label: "README.md"}, {Label: "Makefile"}, }, } // sample commands to showcase cards, various sizes commands := []Command{ { Input: "help", Result: dedent(` Available commands: - help Show this message - ls List files - cat FILE Show file contents - run TASK Run a task Tip: Use 'ls -la' for details.`, ), }, { Input: "ls -la /home/alice/projects", Result: dedent(` total 96 drwxr-xr-x 12 alice alice 4096 Aug 22 21:00 . drwxr-xr-x 3 alice alice 4096 Aug 10 09:10 .. -rw-r--r-- 1 alice alice 220 Aug 1 12:00 README.md drwxr-xr-x 4 alice alice 4096 Aug 22 20:58 src drwxr-xr-x 3 alice alice 4096 Aug 22 20:55 pkg drwxr-xr-x 5 alice alice 4096 Aug 22 20:59 ui `), }, { Input: "cat src/ui/main.go", Result: dedent(` package main import "fmt" func main() { fmt.Println("ui starting...") // ...lots of code... }`, ), }, { Input: "run test-suite --verbose", Result: longMockOutput(60), // long output to show truncation and scrolling in card result }, { Input: "grep -R \"TODO\" .", Result: dedent(` src/ui/widgets.go:23:// TODO: refactor toolbar pkg/http/server.go:78:// TODO: handle timeouts README.md:4:`, ), }, } v := viewport.New(90, 30) t := textarea.New() t.ShowLineNumbers = false t.Prompt = "$ " m := model{ treeRoot: root, viewport: v, commands: commands, textarea: t, } // set viewport content with current commands m.resize(120, 40) // initial reasonable size for demo; WindowSizeMsg will update on real terminal m.viewport.SetContent(m.renderCommandsContent()) m.viewport.GotoBottom() return m }