mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-15 01:13:22 +00:00
wip: area
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
+23
-3
@@ -246,6 +246,8 @@ type Model struct {
|
||||
// there's no limit.
|
||||
MaxWidth int
|
||||
|
||||
SyntaxHighlighter func(string) string
|
||||
|
||||
// If promptFunc is set, it replaces Prompt as a generator for
|
||||
// prompt strings at the beginning of each line.
|
||||
promptFunc func(line int) string
|
||||
@@ -1182,7 +1184,13 @@ func (m Model) View() string {
|
||||
padding -= m.width - strwidth
|
||||
}
|
||||
if m.row == l && lineInfo.RowOffset == wl {
|
||||
s.WriteString(style.Render(string(wrappedLine[:lineInfo.ColumnOffset])))
|
||||
ln := string(wrappedLine[:lineInfo.ColumnOffset])
|
||||
if m.SyntaxHighlighter == nil {
|
||||
ln = style.Render(ln)
|
||||
} else {
|
||||
ln = m.SyntaxHighlighter(ln)
|
||||
}
|
||||
s.WriteString(ln)
|
||||
if m.col >= len(line) && lineInfo.CharOffset >= m.width {
|
||||
m.Cursor.SetChar(" ")
|
||||
s.WriteString(m.Cursor.View())
|
||||
@@ -1192,9 +1200,21 @@ func (m Model) View() string {
|
||||
s.WriteString(style.Render(string(wrappedLine[lineInfo.ColumnOffset+1:])))
|
||||
}
|
||||
} else {
|
||||
s.WriteString(style.Render(string(wrappedLine)))
|
||||
ln := string(wrappedLine)
|
||||
if m.SyntaxHighlighter == nil {
|
||||
ln = style.Render(ln)
|
||||
} else {
|
||||
ln = m.SyntaxHighlighter(ln)
|
||||
}
|
||||
s.WriteString(ln)
|
||||
}
|
||||
|
||||
pad := strings.Repeat(" ", max(0, padding))
|
||||
if m.SyntaxHighlighter == nil {
|
||||
s.WriteString(style.Render(pad))
|
||||
} else {
|
||||
s.WriteString(pad)
|
||||
}
|
||||
s.WriteString(style.Render(strings.Repeat(" ", max(0, padding))))
|
||||
s.WriteRune('\n')
|
||||
newLines++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user