* horizontal scroll * rebase branch * add tests * add tests with 2 cells symbols * trimLeft, move to charmbracelete/x/ansi lib * up ansi package * Update viewport/viewport.go Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: do not navigate out to the right * fix: cache line width on setcontent * fix tests * fix viewport tests * add test for preventing right overscroll * chore(viewport): increase horizontal step to 6 * chore(viewport): make horizontal scroll API better match vertical scroll API * fix: nolint * fix: use ansi.Cut * perf: do not cut anything if not needed * feat: expose HorizontalScrollPercent * fix: do not scroll if width is 0 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: visible lines take frame into account * feat(viewport): column sign * feat: gutter, soft wrap * wip: search * wip: search * wip: search * fix: perf Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: rename * wip * wip * refactor: viewport highlight ranges * fix: ligloss update * doc: godoc * feat: fill height optional * fix: handle no content * fix: empty lines * wip * wip * Revert "wip" This reverts commit 933f181e88405c21d65a08b816a88030806ca03e. * Reapply "wip" This reverts commit 0e3e31b70f53d93250a1474547cc5157d50e9237. * fix: wide * fix: wide, find * still not quite there * fix: grapheme width * fix: cleanups * fix: refactors, improves highlight visibility * docs: godoc * chore: lipgloss update Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * chore: x/ansi update Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: typos, godocs Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: rename Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: typo * fix: scroll when soft-wrapping * fix: soft wrap adjustments * fix: update Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: deps Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Roman Suvorov <suvorov83@gmail.com> Co-authored-by: Roman Suvorov <tty2.rs@gmail.com> Co-authored-by: Christian Rocha <christian@rocha.is>
Bubbles
Some components for Bubble Tea applications. These components are used in production in Glow, Charm and many other applications.
Spinner
A spinner, useful for indicating that some kind an operation is happening. There are a couple default ones, but you can also pass your own ”frames.”
Text Input
A text input field, akin to an <input type="text"> in HTML. Supports unicode,
pasting, in-place scrolling when the value exceeds the width of the element and
the common, and many customization options.
Text Area
A text area field, akin to an <textarea /> in HTML. Allows for input that
spans multiple lines. Supports unicode, pasting, vertical scrolling when the
value exceeds the width and height of the element, and many customization
options.
Table
A component for displaying and navigating tabular data (columns and rows). Supports vertical scrolling and many customization options.
Progress
A simple, customizable progress meter, with optional animation via Harmonica. Supports solid and gradient fills. The empty and filled runes can be set to whatever you'd like. The percentage readout is customizable and can also be omitted entirely.
Paginator
A component for handling pagination logic and optionally drawing pagination UI. Supports "dot-style" pagination (similar to what you might see on iOS) and numeric page numbering, but you could also just use this component for the logic and visualize pagination however you like.
Viewport
A viewport for vertically scrolling content. Optionally includes standard pager keybindings and mouse wheel support. A high performance mode is available for applications which make use of the alternate screen buffer.
This component is well complemented with Reflow for ANSI-aware indenting and text wrapping.
List
A customizable, batteries-included component for browsing a set of items. Features pagination, fuzzy filtering, auto-generated help, an activity spinner, and status messages, all of which can be enabled and disabled as needed. Extrapolated from Glow.
File Picker
A customizable component for picking a file from the file system. Navigate through directories and select files, optionally limit to certain file extensions.
Timer
A simple, flexible component for counting down. The update frequency and output can be customized as you like.
Stopwatch
A simple, flexible component for counting up. The update frequency and output can be customized as you see fit.
Help
A customizable horizontal mini help view that automatically generates itself from your keybindings. It features single and multi-line modes, which the user can optionally toggle between. It will truncate gracefully if the terminal is too wide for the content.
Key
A non-visual component for managing keybindings. It’s useful for allowing users to remap keybindings as well as generating help views corresponding to your keybindings.
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"),
),
}
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyPressMsg:
switch {
case key.Matches(msg, DefaultKeyMap.Up):
// The user pressed up
case key.Matches(msg, DefaultKeyMap.Down):
// The user pressed down
}
}
return m, nil
}
There’s more where that came from
To check out community-maintained Bubbles see Charm & Friends. Made a cool Bubble that you want to share? PRs are welcome!
Contributing
See contributing.
Feedback
We’d love to hear your thoughts on this project. Feel free to drop us a note!
License
Part of Charm.
Charm热爱开源 • Charm loves open source

