Skip to content
Myr

Simplify code a bit

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Muehlhaeuser · committed by Christian Muehlhaeuser · parent e8b7e51 · Browse files · 4 files+4 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+4 added−16 removed

  • other:+4 added−16 removed

4 files+4 added−16 removed

modified:paginator/paginator.go+2 added-5 removed
42 unmodified lines
43 return 044 }45 n := items / m.PerPage46 if items%m.PerPage > 0 {47 n += 147 n++48 }49 m.TotalPages = n50 return n51}
36 unmodified lines
88}8990// LastPage returns whether or not we're on the last page.91func (m Model) OnLastPage() bool {92 if m.Page == m.TotalPages-1 {93 return true94 }95 return false92 return m.Page == m.TotalPages-193}9495// NewModel creates a new model with defaults.96func NewModel() Model {
92 unmodified lines
modified:textinput/textinput.go-1 removed
180 unmodified lines
181 return m, nil182 }183184 switch msg := msg.(type) {185185 case boba.KeyMsg:186 switch msg.Type {187 case boba.KeyBackspace:188 fallthrough
161 unmodified lines
modified:viewport/viewport.go-2 removed
80 unmodified lines
81 switch msg := msg.(type) {8283 case boba.KeyMsg:84 switch msg.String() {8585 // Down one page86 case "pgdown":87 fallthrough88 case " ": // spacebar
31 unmodified lines
120 fallthrough121 case "k":122 m.LineUp(1)123 return m, nil125124 }125 }126127 return m, nil
42 unmodified lines
modified:commands.go+2 added-8 removed
20 unmodified lines
21 return func() Msg {22 n := time.Now()23 d := n.Truncate(duration).Add(duration).Sub(n)24 t := time.NewTimer(d)25 select {26 case now := <-t.C:27 return fn(now)25 return fn(<-t.C)28 }26 }27}2829// Tick is a command that at an interval independent of the system clock at the
1 unmodified line
31// runs for its entire duration.32func Tick(d time.Duration, fn func(time.Time) Msg) Cmd {33 return func() Msg {34 t := time.NewTimer(d)38 select {39 case now := <-t.C:40 return fn(now)35 return fn(<-t.C)41 }36 }37}3839// TerminalSizeMsg defines an interface for a message that contains terminal
17 unmodified lines