mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
wip: filepicker, help, list, table, textarea, textinput, viewport
This commit is contained in:
@@ -29,8 +29,10 @@ const (
|
||||
)
|
||||
|
||||
// Internal messages for clipboard operations.
|
||||
type pasteMsg string
|
||||
type pasteErrMsg struct{ error }
|
||||
type (
|
||||
pasteMsg string
|
||||
pasteErrMsg struct{ error }
|
||||
)
|
||||
|
||||
// KeyMap is the key bindings for different actions within the textarea.
|
||||
type KeyMap struct {
|
||||
@@ -244,12 +246,12 @@ type Model struct {
|
||||
}
|
||||
|
||||
// New creates a new model with default settings.
|
||||
func New(r *tea.Context) Model {
|
||||
vp := viewport.New(0, 0)
|
||||
func New(ctx *tea.Context) Model {
|
||||
vp := viewport.New(ctx, 0, 0)
|
||||
vp.KeyMap = viewport.KeyMap{}
|
||||
cur := cursor.New()
|
||||
|
||||
focusedStyle, blurredStyle := DefaultStyles(r.Renderer)
|
||||
focusedStyle, blurredStyle := DefaultStyles(ctx.Renderer)
|
||||
|
||||
m := Model{
|
||||
CharLimit: defaultCharLimit,
|
||||
@@ -605,8 +607,7 @@ func (m *Model) transposeLeft() {
|
||||
if m.col >= len(m.value[m.row]) {
|
||||
m.SetCursor(m.col - 1)
|
||||
}
|
||||
m.value[m.row][m.col-1], m.value[m.row][m.col] =
|
||||
m.value[m.row][m.col], m.value[m.row][m.col-1]
|
||||
m.value[m.row][m.col-1], m.value[m.row][m.col] = m.value[m.row][m.col], m.value[m.row][m.col-1]
|
||||
if m.col < len(m.value[m.row]) {
|
||||
m.SetCursor(m.col + 1)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
@@ -429,7 +430,9 @@ func TestRendersEndOfLineBuffer(t *testing.T) {
|
||||
}
|
||||
|
||||
func newTextArea() Model {
|
||||
textarea := New()
|
||||
textarea := New(&tea.Context{
|
||||
Renderer: lipgloss.DefaultRenderer(),
|
||||
})
|
||||
|
||||
textarea.Prompt = "> "
|
||||
textarea.Placeholder = "Hello, World!"
|
||||
|
||||
Reference in New Issue
Block a user