Skip to content

A example of autoscrolling for line wrapping scene #325

Description

@7yyo
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
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions