From 4ae575a4c5d5d7eba3a127ef4b6686a8c5d9771c Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Mon, 26 Sep 2022 08:10:16 +0200 Subject: [PATCH] chore: use latest gofmt --- key/key.go | 52 +++++++++++++++++++++--------------------- paginator/paginator.go | 7 +++--- table/table.go | 3 +-- viewport/viewport.go | 5 ++-- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/key/key.go b/key/key.go index ac08194..c7888fa 100644 --- a/key/key.go +++ b/key/key.go @@ -2,35 +2,35 @@ // keymappings useful in Bubble Tea components. There are a few different ways // you can define a keymapping with this package. Here's one example: // -// type KeyMap struct { -// Up key.Binding -// Down key.Binding -// } +// type KeyMap struct { +// Up key.Binding +// Down key.Binding +// } // -// var DefaultKeyMap = KeyMap{ -// Up: key.NewBinding( -// key.WithKeys("k", "up"), // actual keybindings -// key.WithHelp("↑/k", "move up"), // corresponding help text -// ), -// Down: key.NewBinding( -// key.WithKeys("j", "down"), -// key.WithHelp("↓/j", "move down"), -// ), -// } +// var DefaultKeyMap = KeyMap{ +// Up: key.NewBinding( +// key.WithKeys("k", "up"), // actual keybindings +// key.WithHelp("↑/k", "move up"), // corresponding help text +// ), +// Down: key.NewBinding( +// key.WithKeys("j", "down"), +// key.WithHelp("↓/j", "move down"), +// ), +// } // -// func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { -// switch msg := msg.(type) { -// case tea.KeyMsg: -// switch { -// case key.Matches(msg, DefaultKeyMap.Up): -// // The user pressed up -// case key.Matches(msg, DefaultKeyMap.Down): -// // The user pressed down -// } -// } +// func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { +// switch msg := msg.(type) { +// case tea.KeyMsg: +// switch { +// case key.Matches(msg, DefaultKeyMap.Up): +// // The user pressed up +// case key.Matches(msg, DefaultKeyMap.Down): +// // The user pressed down +// } +// } // -// // ... -// } +// // ... +// } // // The help information, which is not used in the example above, can be used // to render help text for keystrokes in your views. diff --git a/paginator/paginator.go b/paginator/paginator.go index a84819a..a9490e7 100644 --- a/paginator/paginator.go +++ b/paginator/paginator.go @@ -65,10 +65,9 @@ func (m Model) ItemsOnPage(totalItems int) int { // of the slice you're rendering and you'll receive the start and end bounds // corresponding the to pagination. For example: // -// bunchOfStuff := []stuff{...} -// start, end := model.GetSliceBounds(len(bunchOfStuff)) -// sliceToRender := bunchOfStuff[start:end] -// +// bunchOfStuff := []stuff{...} +// start, end := model.GetSliceBounds(len(bunchOfStuff)) +// sliceToRender := bunchOfStuff[start:end] func (m *Model) GetSliceBounds(length int) (start int, end int) { start = m.Page * m.PerPage end = min(m.Page*m.PerPage+m.PerPage, length) diff --git a/table/table.go b/table/table.go index e99c029..cb058f7 100644 --- a/table/table.go +++ b/table/table.go @@ -109,8 +109,7 @@ func (m *Model) SetStyles(s Styles) { // Option is used to set options in New. For example: // -// table := New(WithColumns([]Column{{Title: "ID", Width: 10}})) -// +// table := New(WithColumns([]Column{{Title: "ID", Width: 10}})) type Option func(*Model) // New creates a new model for the table widget. diff --git a/viewport/viewport.go b/viewport/viewport.go index c4c3b5b..2be4f7a 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -240,9 +240,8 @@ func Sync(m Model) tea.Cmd { // number of lines. Use Model.ViewDown to get the lines that should be rendered. // For example: // -// lines := model.ViewDown(1) -// cmd := ViewDown(m, lines) -// +// lines := model.ViewDown(1) +// cmd := ViewDown(m, lines) func ViewDown(m Model, lines []string) tea.Cmd { if len(lines) == 0 { return nil