mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-16 13:19:11 +02:00
Unstyled indent (for now)
This commit is contained in:
parent
671eade0b5
commit
ae5e158bbd
2 changed files with 16 additions and 4 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
17
ui/ui.go
17
ui/ui.go
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue