mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-10-18 16:38:56 +03:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1d489252fe | ||
|
06358c35f9 | ||
|
005233b529 | ||
|
18d25458da | ||
|
db97ac515d | ||
|
200f95759b | ||
|
7ecce3fb97 | ||
|
746834a7ce | ||
|
fd306528f9 | ||
|
a4dc540f3d | ||
|
151d1026dd |
12
.github/workflows/soft-serve.yml
vendored
Normal file
12
.github/workflows/soft-serve.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: soft-serve
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
soft-serve:
|
||||
uses: charmbracelet/meta/.github/workflows/soft-serve.yml@main
|
||||
secrets:
|
||||
ssh-key: "${{ secrets.CHARM_SOFT_SERVE_KEY }}"
|
@@ -149,8 +149,8 @@ var DefaultKeyMap = KeyMap{
|
||||
key.WithHelp("↑/k", "move up"), // corresponding help text
|
||||
),
|
||||
Down: key.NewBinding(
|
||||
WithKeys("j", "down"),
|
||||
WithHelp("↓/j", "move down"),
|
||||
key.WithKeys("j", "down"),
|
||||
key.WithHelp("↓/j", "move down"),
|
||||
),
|
||||
}
|
||||
|
||||
@@ -178,6 +178,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
* [mritd/bubbles](https://github.com/mritd/bubbles): Some general-purpose
|
||||
bubbles. Inputs with validation, menu selection, a modified progressbar, and
|
||||
so on.
|
||||
* [bubblelister](https://github.com/treilik/bubblelister): An alternate list
|
||||
that is scrollable without pagination and has the ability to contain other
|
||||
bubbles as list items.
|
||||
* [bubbleboxer](https://github.com/treilik/bubbleboxer): Layout multiple bubbles
|
||||
side-by-side in a layout-tree.
|
||||
|
||||
If you’ve built a Bubble you think should be listed here,
|
||||
[let us know](mailto:vt100@charm.sh).
|
||||
|
@@ -13,8 +13,8 @@
|
||||
// key.WithHelp("↑/k", "move up"), // corresponding help text
|
||||
// ),
|
||||
// Down: key.NewBinding(
|
||||
// WithKeys("j", "down"),
|
||||
// WithHelp("↓/j", "move down"),
|
||||
// key.WithKeys("j", "down"),
|
||||
// key.WithHelp("↓/j", "move down"),
|
||||
// ),
|
||||
// }
|
||||
//
|
||||
|
10
list/list.go
10
list/list.go
@@ -107,6 +107,8 @@ type Model struct {
|
||||
// Key mappings for navigating the list.
|
||||
KeyMap KeyMap
|
||||
|
||||
disableQuitKeybindings bool
|
||||
|
||||
// Additional key mappings for the short and full help views. This allows
|
||||
// you to add additional key mappings to the help menu without
|
||||
// re-implementing the help component. Of course, you can also disable the
|
||||
@@ -324,7 +326,8 @@ func (m *Model) SetItem(index int, item Item) tea.Cmd {
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Insert an item at the given index. This returns a command.
|
||||
// Insert an item at the given index. If 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)
|
||||
@@ -520,6 +523,7 @@ func (m *Model) StopSpinner() {
|
||||
// Helper for disabling the keybindings used for quitting, incase you want to
|
||||
// handle this elsewhere in your application.
|
||||
func (m *Model) DisableQuitKeybindings() {
|
||||
m.disableQuitKeybindings = true
|
||||
m.KeyMap.Quit.SetEnabled(false)
|
||||
m.KeyMap.ForceQuit.SetEnabled(false)
|
||||
}
|
||||
@@ -602,7 +606,7 @@ func (m *Model) updateKeybindings() {
|
||||
m.KeyMap.ClearFilter.SetEnabled(false)
|
||||
m.KeyMap.CancelWhileFiltering.SetEnabled(true)
|
||||
m.KeyMap.AcceptWhileFiltering.SetEnabled(m.FilterInput.Value() != "")
|
||||
m.KeyMap.Quit.SetEnabled(true)
|
||||
m.KeyMap.Quit.SetEnabled(false)
|
||||
m.KeyMap.ShowFullHelp.SetEnabled(false)
|
||||
m.KeyMap.CloseFullHelp.SetEnabled(false)
|
||||
|
||||
@@ -622,7 +626,7 @@ func (m *Model) updateKeybindings() {
|
||||
m.KeyMap.ClearFilter.SetEnabled(m.filterState == FilterApplied)
|
||||
m.KeyMap.CancelWhileFiltering.SetEnabled(false)
|
||||
m.KeyMap.AcceptWhileFiltering.SetEnabled(false)
|
||||
m.KeyMap.Quit.SetEnabled(true)
|
||||
m.KeyMap.Quit.SetEnabled(!m.disableQuitKeybindings)
|
||||
|
||||
if m.Help.ShowAll {
|
||||
m.KeyMap.ShowFullHelp.SetEnabled(true)
|
||||
|
@@ -412,6 +412,11 @@ func (m *Model) deleteWordLeft() bool {
|
||||
return m.deleteBeforeCursor()
|
||||
}
|
||||
|
||||
// Linter note: it's critical that we acquire the initial cursor position
|
||||
// here prior to altering it via SetCursor() below. As such, moving this
|
||||
// call into the corresponding if clause does not apply here.
|
||||
oldPos := m.pos //nolint:ifshort
|
||||
|
||||
blink := m.setCursor(m.pos - 1)
|
||||
for unicode.IsSpace(m.value[m.pos]) {
|
||||
if m.pos <= 0 {
|
||||
@@ -433,10 +438,10 @@ func (m *Model) deleteWordLeft() bool {
|
||||
}
|
||||
}
|
||||
|
||||
if m.pos > len(m.value) {
|
||||
if oldPos > len(m.value) {
|
||||
m.value = m.value[:m.pos]
|
||||
} else {
|
||||
m.value = append(m.value[:m.pos], m.value[m.pos:]...)
|
||||
m.value = append(m.value[:m.pos], m.value[oldPos:]...)
|
||||
}
|
||||
|
||||
return blink
|
||||
@@ -454,7 +459,7 @@ func (m *Model) deleteWordRight() bool {
|
||||
return m.deleteAfterCursor()
|
||||
}
|
||||
|
||||
i := m.pos
|
||||
oldPos := m.pos
|
||||
m.setCursor(m.pos + 1)
|
||||
for unicode.IsSpace(m.value[m.pos]) {
|
||||
// ignore series of whitespace after cursor
|
||||
@@ -474,12 +479,12 @@ func (m *Model) deleteWordRight() bool {
|
||||
}
|
||||
|
||||
if m.pos > len(m.value) {
|
||||
m.value = m.value[:i]
|
||||
m.value = m.value[:oldPos]
|
||||
} else {
|
||||
m.value = append(m.value[:i], m.value[m.pos:]...)
|
||||
m.value = append(m.value[:oldPos], m.value[m.pos:]...)
|
||||
}
|
||||
|
||||
return m.setCursor(i)
|
||||
return m.setCursor(oldPos)
|
||||
}
|
||||
|
||||
// wordLeft moves the cursor one word to the left. Returns whether or not the
|
||||
@@ -795,6 +800,9 @@ func Paste() tea.Msg {
|
||||
}
|
||||
|
||||
func clamp(v, low, high int) int {
|
||||
if high < low {
|
||||
low, high = high, low
|
||||
}
|
||||
return min(high, max(low, v))
|
||||
}
|
||||
|
||||
|
@@ -358,7 +358,10 @@ func (m Model) View() string {
|
||||
extraLines = strings.Repeat("\n", max(0, m.Height-len(lines)))
|
||||
}
|
||||
|
||||
return m.Style.Render(strings.Join(lines, "\n") + extraLines)
|
||||
return m.Style.Copy().
|
||||
UnsetWidth().
|
||||
UnsetHeight().
|
||||
Render(strings.Join(lines, "\n") + extraLines)
|
||||
}
|
||||
|
||||
func clamp(v, low, high int) int {
|
||||
|
Reference in New Issue
Block a user