mirror of
https://github.com/Maks1mS/bubbles.git
synced 2024-12-23 22:32:59 +03:00
chore: use latest gofmt
This commit is contained in:
parent
bd074d2dbc
commit
4ae575a4c5
52
key/key.go
52
key/key.go
@ -2,35 +2,35 @@
|
|||||||
// keymappings useful in Bubble Tea components. There are a few different ways
|
// keymappings useful in Bubble Tea components. There are a few different ways
|
||||||
// you can define a keymapping with this package. Here's one example:
|
// you can define a keymapping with this package. Here's one example:
|
||||||
//
|
//
|
||||||
// type KeyMap struct {
|
// type KeyMap struct {
|
||||||
// Up key.Binding
|
// Up key.Binding
|
||||||
// Down key.Binding
|
// Down key.Binding
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// var DefaultKeyMap = KeyMap{
|
// var DefaultKeyMap = KeyMap{
|
||||||
// Up: key.NewBinding(
|
// Up: key.NewBinding(
|
||||||
// key.WithKeys("k", "up"), // actual keybindings
|
// key.WithKeys("k", "up"), // actual keybindings
|
||||||
// key.WithHelp("↑/k", "move up"), // corresponding help text
|
// key.WithHelp("↑/k", "move up"), // corresponding help text
|
||||||
// ),
|
// ),
|
||||||
// Down: key.NewBinding(
|
// Down: key.NewBinding(
|
||||||
// key.WithKeys("j", "down"),
|
// key.WithKeys("j", "down"),
|
||||||
// key.WithHelp("↓/j", "move down"),
|
// key.WithHelp("↓/j", "move down"),
|
||||||
// ),
|
// ),
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
// func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
// switch msg := msg.(type) {
|
// switch msg := msg.(type) {
|
||||||
// case tea.KeyMsg:
|
// case tea.KeyMsg:
|
||||||
// switch {
|
// switch {
|
||||||
// case key.Matches(msg, DefaultKeyMap.Up):
|
// case key.Matches(msg, DefaultKeyMap.Up):
|
||||||
// // The user pressed up
|
// // The user pressed up
|
||||||
// case key.Matches(msg, DefaultKeyMap.Down):
|
// case key.Matches(msg, DefaultKeyMap.Down):
|
||||||
// // The user pressed down
|
// // The user pressed down
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// // ...
|
// // ...
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// The help information, which is not used in the example above, can be used
|
// The help information, which is not used in the example above, can be used
|
||||||
// to render help text for keystrokes in your views.
|
// to render help text for keystrokes in your views.
|
||||||
|
@ -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
|
// of the slice you're rendering and you'll receive the start and end bounds
|
||||||
// corresponding the to pagination. For example:
|
// corresponding the to pagination. For example:
|
||||||
//
|
//
|
||||||
// bunchOfStuff := []stuff{...}
|
// bunchOfStuff := []stuff{...}
|
||||||
// start, end := model.GetSliceBounds(len(bunchOfStuff))
|
// start, end := model.GetSliceBounds(len(bunchOfStuff))
|
||||||
// sliceToRender := bunchOfStuff[start:end]
|
// sliceToRender := bunchOfStuff[start:end]
|
||||||
//
|
|
||||||
func (m *Model) GetSliceBounds(length int) (start int, end int) {
|
func (m *Model) GetSliceBounds(length int) (start int, end int) {
|
||||||
start = m.Page * m.PerPage
|
start = m.Page * m.PerPage
|
||||||
end = min(m.Page*m.PerPage+m.PerPage, length)
|
end = min(m.Page*m.PerPage+m.PerPage, length)
|
||||||
|
@ -109,8 +109,7 @@ func (m *Model) SetStyles(s Styles) {
|
|||||||
|
|
||||||
// Option is used to set options in New. For example:
|
// 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)
|
type Option func(*Model)
|
||||||
|
|
||||||
// New creates a new model for the table widget.
|
// New creates a new model for the table widget.
|
||||||
|
@ -240,9 +240,8 @@ func Sync(m Model) tea.Cmd {
|
|||||||
// number of lines. Use Model.ViewDown to get the lines that should be rendered.
|
// number of lines. Use Model.ViewDown to get the lines that should be rendered.
|
||||||
// For example:
|
// For example:
|
||||||
//
|
//
|
||||||
// lines := model.ViewDown(1)
|
// lines := model.ViewDown(1)
|
||||||
// cmd := ViewDown(m, lines)
|
// cmd := ViewDown(m, lines)
|
||||||
//
|
|
||||||
func ViewDown(m Model, lines []string) tea.Cmd {
|
func ViewDown(m Model, lines []string) tea.Cmd {
|
||||||
if len(lines) == 0 {
|
if len(lines) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user