docs: fix typos and improve comment clarity

This commit is contained in:
Glenn Gonda 2023-02-16 00:07:02 -08:00 committed by Christian Rocha
parent ee382285e7
commit 3d3ed883d3
15 changed files with 51 additions and 51 deletions

View File

@ -146,7 +146,7 @@ func (m *Model) SetMode(mode Mode) tea.Cmd {
return nil
}
// BlinkCmd is an command used to manage cursor blinking.
// BlinkCmd is a command used to manage cursor blinking.
func (m *Model) BlinkCmd() tea.Cmd {
if m.mode != CursorBlink {
return nil

View File

@ -21,7 +21,7 @@ type KeyMap interface {
// which the help items are returned here.
ShortHelp() []key.Binding
// MoreHelp returns an extended group of help items, grouped by columns.
// FullHelp returns an extended group of help items, grouped by columns.
// The help bubble will render the help in the order in which the help
// items are returned here.
FullHelp() [][]key.Binding

View File

@ -26,7 +26,7 @@ type DefaultItemStyles struct {
DimmedTitle lipgloss.Style
DimmedDesc lipgloss.Style
// Charcters matching the current filter, if any.
// Characters matching the current filter, if any.
FilterMatch lipgloss.Style
}
@ -79,7 +79,7 @@ type DefaultItem interface {
// ItemDelegate called, which is called when the list's Update function is
// invoked.
//
// Settings ShortHelpFunc and FullHelpFunc is optional. They can can be set to
// Settings ShortHelpFunc and FullHelpFunc is optional. They can be set to
// include items in the list's default short and full help menus.
type DefaultDelegate struct {
ShowDescription bool
@ -116,7 +116,7 @@ func (d DefaultDelegate) Height() int {
return 1
}
// SetSpacing set the delegate's spacing.
// SetSpacing sets the delegate's spacing.
func (d *DefaultDelegate) SetSpacing(i int) {
d.spacing = i
}

View File

@ -3,7 +3,7 @@ package list
import "github.com/charmbracelet/bubbles/key"
// KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which
// is used to render the menu menu.
// is used to render the menu.
type KeyMap struct {
// Keybindings used when browsing the list.
CursorUp key.Binding

View File

@ -24,7 +24,7 @@ import (
// Item is an item that appears in the list.
type Item interface {
// Filter value is the value we use when filtering against this item when
// FilterValue is the value we use when filtering against this item when
// we're filtering the list.
FilterValue() string
}
@ -291,7 +291,7 @@ func (m Model) ShowStatusBar() bool {
return m.showStatusBar
}
// SetStatusBarItemName defines a replacement for the items identifier.
// SetStatusBarItemName defines a replacement for the item's identifier.
// Defaults to item/items.
func (m *Model) SetStatusBarItemName(singular, plural string) {
m.itemNameSingular = singular
@ -303,7 +303,7 @@ func (m Model) StatusBarItemName() (string, string) {
return m.itemNameSingular, m.itemNamePlural
}
// SetShowPagination hides or shoes the paginator. Note that pagination will
// SetShowPagination hides or shows the paginator. Note that pagination will
// still be active, it simply won't be displayed.
func (m *Model) SetShowPagination(v bool) {
m.showPagination = v
@ -331,7 +331,7 @@ func (m Model) Items() []Item {
return m.items
}
// Set the items available in the list. This returns a command.
// SetItems sets the items available in the list. This returns a command.
func (m *Model) SetItems(i []Item) tea.Cmd {
var cmd tea.Cmd
m.items = i
@ -362,7 +362,7 @@ func (m *Model) ResetFilter() {
m.resetFiltering()
}
// Replace an item at the given index. This returns a command.
// SetItem replaces an item at the given index. This returns a command.
func (m *Model) SetItem(index int, item Item) tea.Cmd {
var cmd tea.Cmd
m.items[index] = item
@ -375,8 +375,8 @@ func (m *Model) SetItem(index int, item Item) tea.Cmd {
return cmd
}
// Insert an item at the given index. If index is out of the upper bound, the
// item will be appended. This returns a command.
// InsertItem inserts an item at the given index. If the index is out of the upper bound,
// the item will be appended. This returns a command.
func (m *Model) InsertItem(index int, item Item) tea.Cmd {
var cmd tea.Cmd
m.items = insertItemIntoSlice(m.items, item, index)
@ -404,7 +404,7 @@ func (m *Model) RemoveItem(index int) {
m.updatePagination()
}
// Set the item delegate.
// SetDelegate sets the item delegate.
func (m *Model) SetDelegate(d ItemDelegate) {
m.delegate = d
m.updatePagination()
@ -418,7 +418,7 @@ func (m Model) VisibleItems() []Item {
return m.items
}
// SelectedItems returns the current selected item in the list.
// SelectedItem returns the current selected item in the list.
func (m Model) SelectedItem() Item {
i := m.Index()
@ -557,7 +557,7 @@ func (m *Model) SetSpinner(spinner spinner.Spinner) {
m.spinner.Spinner = spinner
}
// Toggle the spinner. Note that this also returns a command.
// ToggleSpinner toggles the spinner. Note that this also returns a command.
func (m *Model) ToggleSpinner() tea.Cmd {
if !m.showSpinner {
return m.StartSpinner()
@ -577,8 +577,8 @@ func (m *Model) StopSpinner() {
m.showSpinner = false
}
// Helper for disabling the keybindings used for quitting, in case you want to
// handle this elsewhere in your application.
// DisableQuitKeybindings is a helper for disabling the keybindings used for quitting,
// in case you want to handle this elsewhere in your application.
func (m *Model) DisableQuitKeybindings() {
m.disableQuitKeybindings = true
m.KeyMap.Quit.SetEnabled(false)
@ -646,7 +646,7 @@ func (m Model) itemsAsFilterItems() filteredItems {
item: item,
}
}
return filteredItems(fi)
return fi
}
// Set keybindings according to the filter state.

View File

@ -1,4 +1,4 @@
// Package paginator provides a Bubble Tea package for calulating pagination
// Package paginator provides a Bubble Tea package for calculating pagination
// and rendering pagination info. Note that this package does not render actual
// pages: it's purely for handling keystrokes related to pagination, and
// rendering pagination status.
@ -66,7 +66,7 @@ type Model struct {
}
// SetTotalPages is a helper function for calculating the total number of pages
// from a given number of items. It's use is optional since this pager can be
// from a given number of items. Its use is optional since this pager can be
// used for other things beyond navigating sets. Note that it both returns the
// number of total pages and alters the model.
func (m *Model) SetTotalPages(items int) int {
@ -93,7 +93,7 @@ func (m Model) ItemsOnPage(totalItems int) int {
// GetSliceBounds is a helper function for paginating slices. Pass the length
// of the slice you're rendering and you'll receive the start and end bounds
// corresponding the to pagination. For example:
// corresponding to the pagination. For example:
//
// bunchOfStuff := []stuff{...}
// start, end := model.GetSliceBounds(len(bunchOfStuff))
@ -104,7 +104,7 @@ func (m *Model) GetSliceBounds(length int) (start int, end int) {
return start, end
}
// PrevPage is a number function for navigating one page backward. It will not
// PrevPage is a helper function for navigating one page backward. It will not
// page beyond the first page (i.e. page 0).
func (m *Model) PrevPage() {
if m.Page > 0 {

View File

@ -96,7 +96,7 @@ func WithWidth(w int) Option {
}
// WithSpringOptions sets the initial frequency and damping options for the
// progressbar's built-in spring-based animation. Frequency corresponds to
// progress bar's built-in spring-based animation. Frequency corresponds to
// speed, and damping to bounciness. For details see:
//
// https://github.com/charmbracelet/harmonica
@ -136,7 +136,7 @@ type Model struct {
Full rune
FullColor string
// "Empty" sections of progress bar.
// "Empty" sections of the progress bar.
Empty rune
EmptyColor string
@ -194,12 +194,12 @@ func New(opts ...Option) Model {
// Deprecated: use [New] instead.
var NewModel = New
// Init exists satisfy the tea.Model interface.
// Init exists to satisfy the tea.Model interface.
func (m Model) Init() tea.Cmd {
return nil
}
// Update is used to animation the progress bar during transitions. Use
// Update is used to animate the progress bar during transitions. Use
// SetPercent to create the command you'll need to trigger the animation.
//
// If you're rendering with ViewAs you won't need this.
@ -266,7 +266,7 @@ func (m *Model) DecrPercent(v float64) tea.Cmd {
return m.SetPercent(m.Percent() - v)
}
// View renders the an animated progress bar in its current state. To render
// View renders an animated progress bar in its current state. To render
// a static progress bar based on your own calculations use ViewAs instead.
func (m Model) View() string {
return m.ViewAs(m.percentShown)
@ -336,7 +336,7 @@ func (m Model) percentageView(percent float64) string {
func (m *Model) setRamp(colorA, colorB string, scaled bool) {
// In the event of an error colors here will default to black. For
// usability's sake, and because such an error is only cosmetic, we're
// ignoring the error for sake of usability.
// ignoring the error.
a, _ := colorful.Hex(colorA)
b, _ := colorful.Hex(colorB)

View File

@ -32,7 +32,7 @@ func NewSanitizer(opts ...Option) Sanitizer {
return &s
}
// Option is the type of an option that can be passed to Sanitize().
// Option is the type of option that can be passed to Sanitize().
type Option func(sanitizer) sanitizer
// ReplaceTabs replaces tabs by the specified string.

View File

@ -22,7 +22,7 @@ func nextID() int {
// TickMsg is a message that is sent on every timer tick.
type TickMsg struct {
// ID is the identifier of the stopwatch that send the message. This makes
// ID is the identifier of the stopwatch that sends the message. This makes
// it possible to determine which stopwatch a tick belongs to when there
// are multiple stopwatches running.
//
@ -99,7 +99,7 @@ func (m Model) Toggle() tea.Cmd {
return m.Start()
}
// Reset restes the stopwatch to 0.
// Reset resets the stopwatch to 0.
func (m Model) Reset() tea.Cmd {
return func() tea.Msg {
return ResetMsg{ID: m.id}

View File

@ -35,7 +35,7 @@ type Column struct {
}
// KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which
// is used to render the menu menu.
// is used to render the menu.
type KeyMap struct {
LineUp key.Binding
LineDown key.Binding
@ -222,7 +222,7 @@ func (m Model) Focused() bool {
return m.focus
}
// Focus focusses the table, allowing the user to move around the rows and
// Focus focuses the table, allowing the user to move around the rows and
// interact.
func (m *Model) Focus() {
m.focus = true
@ -274,13 +274,13 @@ func (m Model) Rows() []Row {
return m.rows
}
// SetRows set a new rows state.
// SetRows sets a new rows state.
func (m *Model) SetRows(r []Row) {
m.rows = r
m.UpdateViewport()
}
// SetColumns set a new columns state.
// SetColumns sets a new columns state.
func (m *Model) SetColumns(c []Column) {
m.cols = c
m.UpdateViewport()
@ -319,7 +319,7 @@ func (m *Model) SetCursor(n int) {
m.UpdateViewport()
}
// MoveUp moves the selection up by any number of row.
// MoveUp moves the selection up by any number of rows.
// It can not go above the first row.
func (m *Model) MoveUp(n int) {
m.cursor = clamp(m.cursor-n, 0, len(m.rows)-1)
@ -334,7 +334,7 @@ func (m *Model) MoveUp(n int) {
m.UpdateViewport()
}
// MoveDown moves the selection down by any number of row.
// MoveDown moves the selection down by any number of rows.
// It can not go below the last row.
func (m *Model) MoveDown(n int) {
m.cursor = clamp(m.cursor+n, 0, len(m.rows)-1)

View File

@ -346,7 +346,7 @@ func (m *Model) insertRunesFromUserInput(runes []rune) {
return
}
// Save the reminder of the original line at the current
// Save the remainder of the original line at the current
// cursor position.
tail := make([]rune, len(m.value[m.row][m.col:]))
copy(tail, m.value[m.row][m.col:])
@ -431,7 +431,7 @@ func (m *Model) CursorDown() {
m.row++
m.col = 0
} else {
// Move the cursor to the start of the next line. So that we can get
// Move the cursor to the start of the next line so that we can get
// the line information. We need to add 2 columns to account for the
// trailing space wrapping.
m.col = min(li.StartColumn+li.Width+2, len(m.value[m.row])-1)
@ -520,7 +520,7 @@ func (m *Model) Focus() tea.Cmd {
return m.Cursor.Focus()
}
// Blur removes the focus state on the model. When the model is blurred it can
// Blur removes the focus state on the model. When the model is blurred it can
// not receive keyboard input and the cursor will be hidden.
func (m *Model) Blur() {
m.focus = false
@ -537,7 +537,7 @@ func (m *Model) Reset() {
m.SetCursor(0)
}
// rsan initializes or retrieves the rune sanitizer.
// san initializes or retrieves the rune sanitizer.
func (m *Model) san() runeutil.Sanitizer {
if m.rsan == nil {
// Textinput has all its input on a single line so collapse
@ -827,12 +827,12 @@ func (m *Model) moveToEnd() {
// whether or not line numbers are being shown.
//
// Ensure that SetWidth is called after setting the Prompt and ShowLineNumbers,
// If it important that the width of the textarea be exactly the given width
// It is important that the width of the textarea be exactly the given width
// and no more.
func (m *Model) SetWidth(w int) {
m.viewport.Width = clamp(w, minWidth, maxWidth)
// Since the width of the textarea input is dependant on the width of the
// Since the width of the textarea input is dependent on the width of the
// prompt and line numbers, we need to calculate it by subtracting.
inputWidth := w
if m.ShowLineNumbers {
@ -1167,7 +1167,7 @@ func (m Model) cursorLineNumber() int {
return line
}
// mergeLineBelow merges the current line with the line below.
// mergeLineBelow merges the current line the cursor is on with the line below.
func (m *Model) mergeLineBelow(row int) {
if row >= len(m.value)-1 {
return

View File

@ -322,7 +322,7 @@ func TestVerticalNavigationKeepsCursorHorizontalPosition(t *testing.T) {
if lineInfo.CharOffset != 4 || lineInfo.ColumnOffset != 2 {
t.Log(lineInfo.CharOffset)
t.Log(lineInfo.ColumnOffset)
t.Fatal("Expected cursor to be on the fourth character because there two double width runes on the first line.")
t.Fatal("Expected cursor to be on the fourth character because there are two double width runes on the first line.")
}
downMsg := tea.KeyMsg{Type: tea.KeyDown, Alt: false, Runes: []rune{}}

View File

@ -26,7 +26,7 @@ const (
EchoNormal EchoMode = iota
// EchoPassword displays the EchoCharacter mask instead of actual
// characters. This is commonly used for password fields.
// characters. This is commonly used for password fields.
EchoPassword
// EchoNone displays nothing as characters are entered. This is commonly
@ -404,7 +404,7 @@ func (m *Model) deleteWordBackward() {
}
}
// deleteWordForward deletes the word right to the cursor If input is masked
// deleteWordForward deletes the word right to the cursor. If input is masked
// delete everything after the cursor so as not to reveal word breaks in the
// masked input.
func (m *Model) deleteWordForward() {

View File

@ -55,11 +55,11 @@ type StartStopMsg struct {
// TickMsg is a message that is sent on every timer tick.
type TickMsg struct {
// ID is the identifier of the stopwatch that send the message. This makes
// ID is the identifier of the timer that sends the message. This makes
// it possible to determine which timer a tick belongs to when there
// are multiple timers running.
//
// Note, however, that a timer will reject ticks from other stopwatches, so
// Note, however, that a timer will reject ticks from other timers, so
// it's safe to flow all TickMsgs through all timers and have them still
// behave appropriately.
ID int

View File

@ -68,7 +68,7 @@ func (m Model) Init() tea.Cmd {
return nil
}
// AtTop returns whether or not the viewport is in the very top position.
// AtTop returns whether or not the viewport is at the very top position.
func (m Model) AtTop() bool {
return m.YOffset <= 0
}