This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
metron80's profile picture

Scroll through printed text

Started by metron80, 26 June 2014 - 07:13 PM
metron80 #1
Posted 26 June 2014 - 09:13 PM
I was looking through the forums and could not find how to do this. I want to find a way to print text, then scroll through it, like when you're editing a program. The text printed would be too long to fit on the screen so you have to scroll through it using the mouse_scroll event. But when you use that, it deletes the text that went off the screen. Is there any way to keep the text there?

Any help is appreciated, thanks! :)/>
AssossaGPB #2
Posted 26 June 2014 - 10:50 PM
The only way I can think of doing it is by storing each line in a table and have a variable storing what line your currently on, then each frame redraw the screen with the appropriate text.
Edited on 26 June 2014 - 08:50 PM
Bomb Bloke #3
Posted 27 June 2014 - 02:00 AM
I suppose if you're on CC1.6+, you could probably use the window API here. Very inefficient, but should be easy to code around.

Basically, it hands you a custom terminal object (dubbed a "window") that exists within an existing one. You can then redirect to that object and print/write stuff into it as usual. Everything you write into that window is stored in a buffer, and so if the window is later obscured, you can restore it later.

So the idea is to make a window that's larger than the display you're rendering it on - big enough to print your entire document into. Then all you have to do is respond to mouse scrolling events by moving that window up / down.

AssossaGPB's solution would require a bit more coding on your end, but it'd be far more efficient. You might find this thread useful in implementing it.
metron80 #4
Posted 08 July 2014 - 04:19 PM
Thanks for the help. :)/>
Edited on 08 July 2014 - 02:19 PM