I'm currently programming a proof of concept text editor for computerCraft, in Lua; one feature will be line counting. How would one count the lines in a string, or at least count the newline characters? There would also ideally be line numbers at the side of the display/terminal, which may work with the same code.
I couldn't find any good enough search results, would appreciate a link if it's been answered already.
I've no idea how to do this, the ideal results would be an array with all the lines of text separated into different entries; this would answer both problems; but more 'bespoke' options may be present
Hopefully with help I can achieve an output like this...
1 |while true do
2 |sleep(0)
3 |write("Example")
4 |write("Script\n\n")
5 |end
:
PPPe Code Editor ~ 5 lines
...refreshing when something changes