jroimartin / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
9.92k stars 608 forks source link

Add BufferLines and ViewBufferLines func to View #151

Closed gulyasm closed 6 years ago

gulyasm commented 6 years ago

What is the problem this PR tries to solve?

Many times you want to operate on the individual lines of a View. Example use cases:

Currently, the Buffer function returns a concatenated string, that has to be split to use the individual lines. It's unnecessary wasting of computational resource.

How this PR solves the problem?

By returning individual lines as strings in an array, you don't have to split the string.

How to manually test this?

For an existing use case try the new BufferLines or ViewBufferLines function.

Risk

None that I know of.

nemith commented 6 years ago

I have ran into this as well and it would be very welcome addition.

gulyasm commented 6 years ago

@jroimartin Is there anything I can do to move this PR forward?

jroimartin commented 6 years ago

First of all, thanks for the contribution and sorry for my late response.

It looks good to me. Should we also add a similar method for ViewBuffer? Something like ViewBufferLines()? It could be useful for wrapping views.

gulyasm commented 6 years ago

Thanks, @jroimartin, I updated the PR. 🍦

jroimartin commented 6 years ago

Thanks! Rebased and merged :)