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

feat(viewport): add SetLines method in Viewport #419

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

semihbkgr
Copy link

In certain use-cases I encountered, setting content by lines proved to be more advantageous both in terms of functionality and performance.

@maaslalani
Copy link
Member

I think this makes sense to me. What do you think @meowgorithm?

@meowgorithm
Copy link
Member

meowgorithm commented Feb 28, 2024

This is fairly off the cuff, but I wonder if SetContent would be better off accepting variadic args rather than increasing surface area of the API here.

func (m *Model) SetContent(s string) // before
func (m *Model) SetContent(line ...string) // after

@semihbkgr
Copy link
Author

@meowgorithm do you mean that the API should accept only lines instead of whole content?

I think it will break the backward-compatibility for anyone using the Viewport model and it may not be suitable for every use case.

@meowgorithm
Copy link
Member

I actually mean that SetContent would be able to accept multiple args, joining them with newlines as a convenience. This would be compatible with the current API.

vp := viewport.New(80, 40)
viewport.SetContent("a\nb", "c")
fmt.Println(viewport.View()) // outputs "a\nb\nc"

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 this pull request may close these issues.

None yet

3 participants