Best Way to Implement an Infinite Text Console?
-
Does anyone know the best way to implement an infinite text console within a plugin?
Would it need to be a label or markdown tile, inside a viewport, where each time you write to it, you must increase the size of the label/tile?
Thanks.
-
@clevername27 If it's just plain text then a label or even a panel, inside a viewport as you suggested. Markdown panel might do it too but it depends on your needs.
-
@clevername27 I have made an infinite log using a panel.
The tricky part is to get the paragraph height when drawing. If the line exceeds the panel's width, then it should be truncated to another line so you keep track the Y position for drawing the next line/paragraph...
But this was before panels have been compatible with markdown so it might be a bit easier now
What I do on my side is to push new log entries in an array, then I repaint the whole panel with that array of strings.
Another thing I really struggled at that time is to keep the log showing the last line at the bottom of the panel (so keeping the viewport all all the way down). This is tricky because when repainting a panel, the parent viewport desperately want to go back to top. Alright, why not just set its
viewPositionY
to1
again then? Well, that causes all sorts of flickering that make the repaint very unprofessional...
If you hit this issue I will try to find that bit of code -
-
@d-healey Thank you, David.
-
@ustk Very cool - I gave up a lot quicker, lol. Thanks on the offer, very kind of you.