From 7517c1b1bd157d7b1f35e41a6234b650fcf7dcb0 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 2 Sep 2021 16:18:51 -0400 Subject: [PATCH] Add a border to the Glamour example per the viewport API update --- examples/glamour/main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/glamour/main.go b/examples/glamour/main.go index 8828991..1768abb 100644 --- a/examples/glamour/main.go +++ b/examples/glamour/main.go @@ -55,7 +55,11 @@ type example struct { } func newExample() (*example, error) { - vp := viewport.NewModel(78, 20) + vp := viewport.New(78, 20) + vp.Style = lipgloss.NewStyle(). + BorderStyle(lipgloss.RoundedBorder()). + BorderForeground(lipgloss.Color("62")). + PaddingRight(2) renderer, err := glamour.NewTermRenderer(glamour.WithStylePath("notty")) if err != nil { @@ -89,8 +93,8 @@ func (e example) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "q", "ctrl+c", "esc": return e, tea.Quit default: - newModel, cmd := e.viewport.Update(msg) - e.viewport = newModel.(viewport.Model) + var cmd tea.Cmd + e.viewport, cmd = e.viewport.Update(msg) return e, cmd } default: