mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
chore(merge): branch 'master' into v2-exp
This commit is contained in:
+11
-13
@@ -24,9 +24,12 @@ const (
|
|||||||
minHeight = 1
|
minHeight = 1
|
||||||
defaultHeight = 6
|
defaultHeight = 6
|
||||||
defaultWidth = 40
|
defaultWidth = 40
|
||||||
defaultCharLimit = 400
|
defaultCharLimit = 0 // no limit
|
||||||
defaultMaxHeight = 99
|
defaultMaxHeight = 99
|
||||||
defaultMaxWidth = 500
|
defaultMaxWidth = 500
|
||||||
|
|
||||||
|
// XXX: in v2, make max lines dynamic and default max lines configurable.
|
||||||
|
maxLines = 10000
|
||||||
)
|
)
|
||||||
|
|
||||||
// Internal messages for clipboard operations.
|
// Internal messages for clipboard operations.
|
||||||
@@ -299,13 +302,13 @@ func New() Model {
|
|||||||
Prompt: lipgloss.ThickBorder().Left + " ",
|
Prompt: lipgloss.ThickBorder().Left + " ",
|
||||||
Styles: styles,
|
Styles: styles,
|
||||||
activeStyle: &styles.Blurred,
|
activeStyle: &styles.Blurred,
|
||||||
cache: memoization.NewMemoCache[line, [][]rune](defaultMaxHeight),
|
cache: memoization.NewMemoCache[line, [][]rune](maxLines),
|
||||||
EndOfBufferCharacter: ' ',
|
EndOfBufferCharacter: ' ',
|
||||||
ShowLineNumbers: true,
|
ShowLineNumbers: true,
|
||||||
Cursor: cur,
|
Cursor: cur,
|
||||||
KeyMap: DefaultKeyMap(),
|
KeyMap: DefaultKeyMap(),
|
||||||
|
|
||||||
value: make([][]rune, minHeight, defaultMaxHeight),
|
value: make([][]rune, minHeight, maxLines),
|
||||||
focus: false,
|
focus: false,
|
||||||
col: 0,
|
col: 0,
|
||||||
row: 0,
|
row: 0,
|
||||||
@@ -381,9 +384,8 @@ func (m *Model) insertRunesFromUserInput(runes []rune) {
|
|||||||
// whatnot.
|
// whatnot.
|
||||||
runes = m.san().Sanitize(runes)
|
runes = m.san().Sanitize(runes)
|
||||||
|
|
||||||
var availSpace int
|
|
||||||
if m.CharLimit > 0 {
|
if m.CharLimit > 0 {
|
||||||
availSpace = m.CharLimit - m.Length()
|
availSpace := m.CharLimit - m.Length()
|
||||||
// If the char limit's been reached, cancel.
|
// If the char limit's been reached, cancel.
|
||||||
if availSpace <= 0 {
|
if availSpace <= 0 {
|
||||||
return
|
return
|
||||||
@@ -414,9 +416,9 @@ func (m *Model) insertRunesFromUserInput(runes []rune) {
|
|||||||
lines = append(lines, runes[lstart:])
|
lines = append(lines, runes[lstart:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obey the maximum height limit.
|
// Obey the maximum line limit.
|
||||||
if m.MaxHeight > 0 && len(m.value)+len(lines)-1 > m.MaxHeight {
|
if maxLines > 0 && len(m.value)+len(lines)-1 > maxLines {
|
||||||
allowedHeight := max(0, m.MaxHeight-len(m.value)+1)
|
allowedHeight := max(0, maxLines-len(m.value)+1)
|
||||||
lines = lines[:allowedHeight]
|
lines = lines[:allowedHeight]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,11 +613,7 @@ func (m *Model) Blur() {
|
|||||||
|
|
||||||
// Reset sets the input to its default state with no input.
|
// Reset sets the input to its default state with no input.
|
||||||
func (m *Model) Reset() {
|
func (m *Model) Reset() {
|
||||||
startCap := m.MaxHeight
|
m.value = make([][]rune, minHeight, maxLines)
|
||||||
if startCap <= 0 {
|
|
||||||
startCap = defaultMaxHeight
|
|
||||||
}
|
|
||||||
m.value = make([][]rune, minHeight, startCap)
|
|
||||||
m.col = 0
|
m.col = 0
|
||||||
m.row = 0
|
m.row = 0
|
||||||
m.viewport.GotoTop()
|
m.viewport.GotoTop()
|
||||||
|
|||||||
Reference in New Issue
Block a user