Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix typos and improve comment clarity #332

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cursor/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion help/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions list/defaultitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion list/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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()

Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -646,7 +646,7 @@ func (m Model) itemsAsFilterItems() filteredItems {
item: item,
}
}
return filteredItems(fi)
return fi
}

// Set keybindings according to the filter state.
Expand Down
8 changes: 4 additions & 4 deletions paginator/paginator.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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))
Expand All @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion runeutil/runeutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions stopwatch/stopwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down Expand Up @@ -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}
Expand Down
12 changes: 6 additions & 6 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions textarea/textarea.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:])
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion textarea/textarea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}}
Expand Down
Loading