From 127f76226e398d168d8e6144e829cd40cae8aaa6 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Fri, 2 Sep 2022 12:56:18 -0700 Subject: [PATCH] docs(example): set wordwrap in glamour example --- examples/glamour/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/glamour/main.go b/examples/glamour/main.go index 1768abb..dacf8f9 100644 --- a/examples/glamour/main.go +++ b/examples/glamour/main.go @@ -55,13 +55,18 @@ type example struct { } func newExample() (*example, error) { - vp := viewport.New(78, 20) + const width = 78 + + vp := viewport.New(width, 20) vp.Style = lipgloss.NewStyle(). BorderStyle(lipgloss.RoundedBorder()). BorderForeground(lipgloss.Color("62")). PaddingRight(2) - renderer, err := glamour.NewTermRenderer(glamour.WithStylePath("notty")) + renderer, err := glamour.NewTermRenderer( + glamour.WithStylePath("notty"), + glamour.WithWordWrap(width), + ) if err != nil { return nil, err } @@ -84,10 +89,6 @@ func (e example) Init() tea.Cmd { func (e example) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { - case tea.WindowSizeMsg: - e.viewport.Width = msg.Width - return e, nil - case tea.KeyMsg: switch msg.String() { case "q", "ctrl+c", "esc":