Skip to content

Commit

Permalink
docs(example): set wordwrap in glamour example
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Sep 2, 2022
1 parent 989d49f commit 127f762
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions examples/glamour/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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":
Expand Down

0 comments on commit 127f762

Please sign in to comment.