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

A example of autoscrolling for line wrapping scene #325

Open
7yyo opened this issue Jun 17, 2023 · 0 comments
Open

A example of autoscrolling for line wrapping scene #325

7yyo opened this issue Jun 17, 2023 · 0 comments

Comments

@7yyo
Copy link

7yyo commented Jun 17, 2023

x := list.Size().X
text := splitByNChars(s, x-2)
for _, t := range text {
	list = append(list, t)
	list.ScrollDown()
}
ui.Render(w.L)
func splitByNChars(s string, n int) []string {
	var result []string
	for i := 0; i < len(s); i += n {
		end := i + n
		if end > len(s) {
			end = len(s)
		}
		result = append(result, s[i:end])
	}
	return result
}
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

No branches or pull requests

1 participant