Unstyled indent (for now)

This commit is contained in:
Christian Rocha 2020-05-27 11:55:00 -04:00 committed by Christian Muehlhaeuser
commit ae5e158bbd
2 changed files with 16 additions and 4 deletions

View file

@ -14,7 +14,6 @@ import (
"github.com/charmbracelet/charm"
"github.com/charmbracelet/charm/ui/common"
"github.com/dustin/go-humanize"
"github.com/muesli/reflow/indent"
te "github.com/muesli/termenv"
)
@ -438,7 +437,7 @@ func stashView(m stashModel) string {
stashHelpView(m),
)
}
return "\n" + indent.String(s, 1)
return "\n" + indent(s, 1)
}
func glowLogoView(text string) string {

View file

@ -3,13 +3,13 @@ package ui
import (
"errors"
"fmt"
"strings"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/charm"
"github.com/charmbracelet/charm/ui/common"
"github.com/charmbracelet/charm/ui/keygen"
"github.com/muesli/reflow/indent"
te "github.com/muesli/termenv"
)
@ -294,7 +294,7 @@ func view(mdl tea.Model) string {
return pagerView(m.pager)
}
return "\n" + indent.String(s, 2)
return "\n" + indent(s, 2)
}
// COMMANDS
@ -327,6 +327,19 @@ func newCharmClient() tea.Msg {
return newCharmClientMsg(cc)
}
func indent(s string, n int) string {
if n <= 0 || s == "" {
return s
}
l := strings.Split(s, "\n")
b := strings.Builder{}
i := strings.Repeat(" ", n)
for _, v := range l {
fmt.Fprintf(&b, "%s%s\n", i, v)
}
return b.String()
}
// ETC
func min(a, b int) int {