mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 12:46:14 +00:00
rebase branch
This commit is contained in:
committed by
Roman Suvorov
parent
98ba87b817
commit
fe8d41e8bb
+3
-15
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/charmbracelet/bubbles/key"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/mattn/go-runewidth"
|
||||
)
|
||||
|
||||
// New returns a new model with the given width and height as well as default
|
||||
@@ -132,7 +133,7 @@ func (m Model) visibleLines() (lines []string) {
|
||||
if m.indent > 0 {
|
||||
cutLines := make([]string, len(lines))
|
||||
for i := range lines {
|
||||
cutLines[i] = getStringWithIndent(lines[i], m.indent)
|
||||
cutLines[i] = runewidth.TruncateLeft(lines[i], m.indent, "")
|
||||
}
|
||||
|
||||
return cutLines
|
||||
@@ -309,7 +310,7 @@ func ViewUp(m Model, lines []string) tea.Cmd {
|
||||
// Must be set before `MoveLeft` or `MoveRight` is used.
|
||||
// If 0 or negative, left/right movement doesn't work.
|
||||
func (m *Model) SetHorizontalStep(n int) {
|
||||
if n < 1 {
|
||||
if n < 0 {
|
||||
n = 0
|
||||
}
|
||||
|
||||
@@ -469,16 +470,3 @@ func max(a, b int) int {
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func getStringWithIndent(s string, indent int) string {
|
||||
if indent == 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
r := []rune(s)
|
||||
if indent > len(r) {
|
||||
return ""
|
||||
}
|
||||
|
||||
return string(r[indent:])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user