Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tea.Print[f/ln] does not wrap to a new line #460

Closed
Charliego3 opened this issue Sep 25, 2022 · 6 comments · Fixed by #490
Closed

tea.Print[f/ln] does not wrap to a new line #460

Charliego3 opened this issue Sep 25, 2022 · 6 comments · Fixed by #490

Comments

@Charliego3
Copy link

When using tea.Print[f/ln] the text is too long and the terminal does not wrap to a new line.
The same string, fmt.Println output is normal, but this problem occurs when tea.Println is used for output

go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/charlie/Library/Caches/go-build"
GOENV="/Users/charlie/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/charlie/dev/environment/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/charlie/dev/environment/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.19.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.19.1/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/charlie/dev/go/transerver/cli/go.mod"
GOWORK="/Users/charlie/dev/go/transerver/go.work"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/29/61lvvzb95pq774dthcv3rhnh0000gn/T/go-build1132523527=/tmp/go-build -gno-record-gcc-switches -fno-common"

OS: macOS 12.6
Terminal: kitty / mac's own terminal

type model struct {
	spinner spinner.Model
	done    bool
}

func (m *model) Init() tea.Cmd { return nil }

func (m *model) Update(tea.Msg) (tea.Model, tea.Cmd) {
	if m.done {
		return m, tea.Quit
	}
	return m, nil
}

func (m *model) View() string {
	if m.done {
		return ""
	}
	return m.spinner.View() + " Loading..."
}

func TestPrintln(t *testing.T) {
	txt := "Starting with Go 1.16, you can embed files into your Go binaries. It means that you can build and ship to your users a binary that already has all the necessary files from your hard drive. So, there is no need to ship them separately and place them at a certain location on the computer. And the next time you move the binary to another directory, you do not need to update the paths to these files."
	style := lipgloss.NewStyle().MarginLeft(2).Bold(true).Underline(true).Foreground(lipgloss.Color("#B22222"))
	txt = style.Render(txt)
	s := spinner.New()
	s.Spinner = spinner.Points
	s.Style = SpinnerStyle
	m := &model{s, false}
	pg := tea.NewProgram(m)
	go func() {
		pg.Println(txt)
		m.done = true
	}()
	_ = pg.Start()

	println()
	fmt.Println(txt)
}

kitty's output:
image

mac's own terminal output:
image

@amoghrajesh
Copy link

@meowgorithm @muesli @Charliego93 I would like to work on this as part of Hacktoberfest 2022

@muesli
Copy link
Contributor

muesli commented Oct 4, 2022

@amoghrajesh Go ahead!

@amoghrajesh
Copy link

@muesli can you tell me how to do it or the getting started guide?

@meowgorithm
Copy link
Member

The one may be better left as an exercise to the user as “managed” Bubble Tea output doesn’t wrap by default. It’s fairly simple to look at WindowSizeMsg and wrap lines yourself if desired with Lip Gloss or Reflow.

@amoghrajesh
Copy link

Sure. Can you assign the issue to me?

@amoghrajesh
Copy link

@meowgorithm not very clear still. Can you elaborate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants